fix(Core): Possible DF crashfix (#7684)

This commit is contained in:
UltraNix
2021-09-01 21:20:29 +02:00
committed by GitHub
parent d059788aaa
commit fb0c3b4cb2

View File

@@ -1530,7 +1530,7 @@ namespace lfg
void LFGMgr::MakeNewGroup(LfgProposal const& proposal)
{
LfgGuidList players;
LfgGuidList playersToTeleport;
GuidUnorderedSet playersToTeleport;
for (LfgProposalPlayerContainer::const_iterator it = proposal.players.begin(); it != proposal.players.end(); ++it)
{
@@ -1541,7 +1541,7 @@ namespace lfg
players.push_back(guid);
if (proposal.isNew || GetGroup(guid) != proposal.group)
playersToTeleport.push_back(guid);
playersToTeleport.insert(guid);
}
// Set the dungeon difficulty
@@ -1613,30 +1613,33 @@ namespace lfg
// Select a player inside to be teleported to
WorldLocation const* teleportLocation = nullptr;
bool leaderTeleportIncluded = false;
for (GroupReference* itr = grp->GetFirstMember(); itr != nullptr; itr = itr->next())
{
Player* plr = itr->GetSource();
if (plr && plr->GetMapId() == uint32(dungeon->map) && !proposal.isNew)
if (plr)
{
teleportLocation = plr;
break;
if (grp->IsLeader(plr->GetGUID()) && playersToTeleport.find(plr->GetGUID()) != playersToTeleport.end())
{
leaderTeleportIncluded = true;
}
if (plr->GetMapId() == uint32(dungeon->map) && !proposal.isNew)
{
teleportLocation = plr;
break;
}
}
}
bool randomDungeon = false;
// Teleport Player
for (LfgGuidList::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
for (GuidUnorderedSet::const_iterator it = playersToTeleport.begin(); it != playersToTeleport.end(); ++it)
if (Player* player = ObjectAccessor::FindPlayer(*it))
{
if (player->GetGroup() != grp) // pussywizard: could not add because group was full (some shitness happened)
continue;
if (player->GetMapId() == uint32(dungeon->map))
{
// Remove bind to that map
sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
}
// Add the cooldown spell if queued for a random dungeon
// xinef: add aura
if ((randomDungeon || selectedRandomLfgDungeon(player->GetGUID())) && !player->HasAura(LFG_SPELL_DUNGEON_COOLDOWN))
@@ -1645,6 +1648,25 @@ namespace lfg
player->AddAura(LFG_SPELL_DUNGEON_COOLDOWN, player);
}
if (player->GetMapId() == uint32(dungeon->map))
{
// check instance id with leader
if (!leaderTeleportIncluded)
{
if (InstancePlayerBind* ilb = sInstanceSaveMgr->PlayerGetBoundInstance(grp->GetLeaderGUID(), dungeon->map, player->GetDungeonDifficulty()))
{
if (player->GetInstanceId() == ilb->save->GetInstanceId())
{
// Do not teleport if in the same map and instance as leader
continue;
}
}
}
// Remove bind to that map
sInstanceSaveMgr->PlayerUnbindInstance(player->GetGUID(), dungeon->map, player->GetDungeonDifficulty(), true);
}
TeleportPlayer(player, false, teleportLocation);
}