From 3120364aff2fa0bd2962fffc130aef74ab7902c5 Mon Sep 17 00:00:00 2001 From: Spp Date: Thu, 25 Oct 2012 11:33:14 +0200 Subject: Core/Dungeon Finder: Prevent crash when Teleport opcode is received from client when is not supposed. Note: In order to get teleported in/out you need to be in group Closes #8183 --- src/server/game/DungeonFinding/LFGMgr.cpp | 21 ++++++++++++++------- 1 file changed, 14 insertions(+), 7 deletions(-) (limited to 'src/server') diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 25c6b25676e..2001ddd07b2 100755 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -1385,11 +1385,19 @@ void LFGMgr::UpdateBoot(uint64 guid, bool accept) */ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false*/) { - Group* grp = player->GetGroup(); - uint64 gguid = grp->GetGUID(); - LFGDungeonData const* dungeon = GetLFGDungeon(GetDungeon(gguid)); + LFGDungeonData const* dungeon = NULL; + Group* group = player->GetGroup(); + + if (group && group->isLFGGroup()) + dungeon = GetLFGDungeon(GetDungeon(group->GetGUID())); + if (!dungeon) + { + sLog->outDebug(LOG_FILTER_LFG, "TeleportPlayer: Player %s not in group/lfggroup or dungeon not found!", + player->GetName().c_str()); + player->GetSession()->SendLfgTeleportError(uint8(LFG_TELEPORTERROR_INVALID_LOCATION)); return; + } if (out) { @@ -1406,9 +1414,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* LfgTeleportError error = LFG_TELEPORTERROR_OK; - if (!grp || !grp->isLFGGroup()) // should never happen, but just in case... - error = LFG_TELEPORTERROR_INVALID_LOCATION; - else if (!player->isAlive()) + if (!player->isAlive()) error = LFG_TELEPORTERROR_PLAYER_DEAD; else if (player->IsFalling() || player->HasUnitState(UNIT_STATE_JUMPING)) error = LFG_TELEPORTERROR_FALLING; @@ -1429,7 +1435,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* if (!fromOpcode) { // Select a player inside to be teleported to - for (GroupReference* itr = grp->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) + for (GroupReference* itr = group->GetFirstMember(); itr != NULL && !mapid; itr = itr->next()) { Player* plrg = itr->getSource(); if (plrg && plrg != player && plrg->GetMapId() == uint32(dungeon->map)) @@ -1439,6 +1445,7 @@ void LFGMgr::TeleportPlayer(Player* player, bool out, bool fromOpcode /*= false* y = plrg->GetPositionY(); z = plrg->GetPositionZ(); orientation = plrg->GetOrientation(); + break; } } } -- cgit v1.2.3