diff options
author | UltraNix <80540499+UltraNix@users.noreply.github.com> | 2021-09-01 21:20:29 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-09-01 21:20:29 +0200 |
commit | fb0c3b4cb2f6f40a3307d1f4acb2c8fe0f5344b5 (patch) | |
tree | 4f14d890b03a7d44c6e7f5b03e26e95e15d38728 /src | |
parent | d059788aaafd7c310441436b346911559a5d2f93 (diff) |
fix(Core): Possible DF crashfix (#7684)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/DungeonFinding/LFGMgr.cpp | 46 |
1 files changed, 34 insertions, 12 deletions
diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 9e28314073..4bf81bf707 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -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); } |