Core/LFG: Fix a crash

Fix a crash in case a player is recognized as in a LFG dungeon, but without a valid group
This commit is contained in:
Machiavelli
2013-02-14 15:01:33 +01:00
parent 203cf7cbf0
commit 8befbdcc56

View File

@@ -95,6 +95,20 @@ void LFGPlayerScript::OnMapChanged(Player* player)
if (sLFGMgr->inLfgDungeonMap(player->GetGUID(), map->GetId(), map->GetDifficulty()))
{
Group* group = player->GetGroup();
// This function is also called when players log in
// if for some reason the LFG system recognises the player as being in a LFG dungeon,
// but the player was loaded without a valid group, we'll teleport to homebind to prevent
// crashes or other undefined behaviour
if (!group)
{
sLFGMgr->LeaveLfg(player->GetGUID());
player->RemoveAurasDueToSpell(LFG_SPELL_LUCK_OF_THE_DRAW);
player->TeleportTo(player->m_homebindMapId, player->m_homebindX, player->m_homebindY, player->m_homebindZ, 0.0f);
sLog->outError(LOG_FILTER_LFG, "LFGPlayerScript::OnMapChanged, Player %s (%u) is in LFG dungeon map but does not have a valid group! "
"Teleporting to homebind.", player->GetName().c_str(), player->GetGUIDLow());
return;
}
for (GroupReference* itr = group->GetFirstMember(); itr != NULL; itr = itr->next())
if (Player* member = itr->getSource())
player->GetSession()->SendNameQueryOpcode(member->GetGUID());