fix(Core/Grids): Fix corpse loading after a server restart (#22594)

This commit is contained in:
Takenbacon
2025-07-30 18:49:09 -07:00
committed by GitHub
parent 4e8d0f565f
commit cd87350a17
3 changed files with 18 additions and 16 deletions

View File

@@ -1033,7 +1033,7 @@ void Map::UnloadAll()
_transports.clear();
for (auto& cellCorpsePair : _corpsesByCell)
for (auto& cellCorpsePair : _corpsesByGrid)
{
for (Corpse* corpse : cellCorpsePair.second)
{
@@ -1043,7 +1043,7 @@ void Map::UnloadAll()
}
}
_corpsesByCell.clear();
_corpsesByGrid.clear();
_corpsesByPlayer.clear();
_corpseBones.clear();
}
@@ -1848,6 +1848,12 @@ void Map::AddToActive(GameObject* d)
AddToActiveHelper(d);
}
template<>
void Map::AddToActive(Corpse* /*c*/)
{
// do nothing for corpses
}
template<class T>
void Map::RemoveFromActive(T* obj)
{
@@ -2667,7 +2673,8 @@ void Map::AddCorpse(Corpse* corpse)
{
corpse->SetMap(this);
_corpsesByCell[corpse->GetCellCoord().GetId()].insert(corpse);
GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
_corpsesByGrid[gridCoord.GetId()].insert(corpse);
if (corpse->GetType() != CORPSE_BONES)
_corpsesByPlayer[corpse->GetOwnerGUID()] = corpse;
else
@@ -2677,6 +2684,7 @@ void Map::AddCorpse(Corpse* corpse)
void Map::RemoveCorpse(Corpse* corpse)
{
ASSERT(corpse);
GridCoord const gridCoord = Acore::ComputeGridCoord(corpse->GetPositionX(), corpse->GetPositionY());
corpse->DestroyForNearbyPlayers();
if (corpse->IsInGrid())
@@ -2687,7 +2695,7 @@ void Map::RemoveCorpse(Corpse* corpse)
corpse->ResetMap();
}
_corpsesByCell[corpse->GetCellCoord().GetId()].erase(corpse);
_corpsesByGrid[gridCoord.GetId()].erase(corpse);
if (corpse->GetType() != CORPSE_BONES)
_corpsesByPlayer.erase(corpse->GetOwnerGUID());
else