refactor(Core/Wintergrasp): Use helper to clear tracking references (#26003)
This commit is contained in:
@@ -74,19 +74,20 @@ Battlefield::~Battlefield()
|
|||||||
CapturePoints.clear();
|
CapturePoints.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
|
void Battlefield::RemovePlayerFromTracking(ObjectGuid playerGuid)
|
||||||
{
|
{
|
||||||
// Clear any stale entries from a prior visit that did not unwind cleanly.
|
|
||||||
// Runs before the script hook so scripts see a clean state if they read any
|
|
||||||
// of these containers.
|
|
||||||
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
|
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
|
||||||
{
|
{
|
||||||
PlayersInWar[i].erase(player->GetGUID());
|
InvitedPlayers[i].erase(playerGuid);
|
||||||
InvitedPlayers[i].erase(player->GetGUID());
|
PlayersInQueue[i].erase(playerGuid);
|
||||||
PlayersInQueue[i].erase(player->GetGUID());
|
PlayersWillBeKick[i].erase(playerGuid);
|
||||||
PlayersWillBeKick[i].erase(player->GetGUID());
|
Players[i].erase(playerGuid);
|
||||||
Players[i].erase(player->GetGUID());
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Battlefield::HandlePlayerEnterZone(Player* player, uint32 /*zone*/)
|
||||||
|
{
|
||||||
|
RemovePlayerFromTracking(player->GetGUID());
|
||||||
|
|
||||||
// Allow scripts to adjust the player's effective team or appearance before
|
// Allow scripts to adjust the player's effective team or appearance before
|
||||||
// any team-based battlefield containers (such as player lists or queues) are updated.
|
// any team-based battlefield containers (such as player lists or queues) are updated.
|
||||||
@@ -141,13 +142,7 @@ void Battlefield::HandlePlayerLeaveZone(Player* player, uint32 /*zone*/)
|
|||||||
for (BfCapturePoint* cp : CapturePoints)
|
for (BfCapturePoint* cp : CapturePoints)
|
||||||
cp->HandlePlayerLeave(player);
|
cp->HandlePlayerLeave(player);
|
||||||
|
|
||||||
for (uint8 i = 0; i < PVP_TEAMS_COUNT; ++i)
|
RemovePlayerFromTracking(player->GetGUID());
|
||||||
{
|
|
||||||
InvitedPlayers[i].erase(player->GetGUID());
|
|
||||||
PlayersInQueue[i].erase(player->GetGUID());
|
|
||||||
PlayersWillBeKick[i].erase(player->GetGUID());
|
|
||||||
Players[i].erase(player->GetGUID());
|
|
||||||
}
|
|
||||||
SendRemoveWorldStates(player);
|
SendRemoveWorldStates(player);
|
||||||
RemovePlayerFromResurrectQueue(player->GetGUID());
|
RemovePlayerFromResurrectQueue(player->GetGUID());
|
||||||
OnPlayerLeaveZone(player);
|
OnPlayerLeaveZone(player);
|
||||||
|
|||||||
@@ -444,6 +444,8 @@ protected:
|
|||||||
/// Returns true if the player is already tracked as actively in the war or invited to join it.
|
/// Returns true if the player is already tracked as actively in the war or invited to join it.
|
||||||
bool IsPlayerInWarOrInvited(Player* player) const;
|
bool IsPlayerInWarOrInvited(Player* player) const;
|
||||||
|
|
||||||
|
void RemovePlayerFromTracking(ObjectGuid playerGuid);
|
||||||
|
|
||||||
// Player-iteration helpers: resolve each GUID to a live Player* and call fn(player).
|
// Player-iteration helpers: resolve each GUID to a live Player* and call fn(player).
|
||||||
// Using templates avoids std::function overhead and works naturally with lambdas.
|
// Using templates avoids std::function overhead and works naturally with lambdas.
|
||||||
template<typename Func>
|
template<typename Func>
|
||||||
|
|||||||
Reference in New Issue
Block a user