mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
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:
@@ -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());
|
||||
|
||||
Reference in New Issue
Block a user