diff options
author | Shauren <shauren.trinity@gmail.com> | 2015-10-30 17:53:00 +0100 |
---|---|---|
committer | Shauren <shauren.trinity@gmail.com> | 2015-10-30 18:05:35 +0100 |
commit | d72293bdf794ee7a66e40f4910f440c5f2b527c5 (patch) | |
tree | 94234f385dc359796ba9bcb51059825c69586335 /src | |
parent | b96bb1504222ddbadbee1df062450502e0dbd8a0 (diff) |
Core/Corpses: Fixed a crash happening when a corpse is added to a grid that was not yet fully loaded
Closes #15684
(cherry picked from commit 8c9ea7782a4eb251933f43d57bf8271c11a0e6a6)
Diffstat (limited to 'src')
-rw-r--r-- | src/server/game/Maps/Map.cpp | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 62ba6b9ff07..0316215996a 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -298,6 +298,25 @@ void Map::AddToGrid(DynamicObject* obj, Cell const& cell) obj->SetCurrentCell(cell); } +template<> +void Map::AddToGrid(Corpse* obj, Cell const& cell) +{ + NGridType* grid = getNGrid(cell.GridX(), cell.GridY()); + if (obj->IsWorldObject()) + { + // Corpses are a special object type - they can be added to grid via a call to AddToMap + // or loaded through ObjectGridLoader. + // Both corpses loaded from database and these freshly generated by Player::CreateCoprse are added to _corpsesByCell + // ObjectGridLoader loads all corpses from _corpsesByCell even if they were already added to grid before it was loaded + // so we need to explicitly check it here (Map::AddToGrid is only called from Player::BuildPlayerRepop, not from ObjectGridLoader) + // to avoid failing an assertion in GridObject::AddToGrid + if (grid->isGridObjectDataLoaded()) + grid->GetGridType(cell.CellX(), cell.CellY()).AddWorldObject(obj); + } + else + grid->GetGridType(cell.CellX(), cell.CellY()).AddGridObject(obj); // bones. nothing special here +} + template<class T> void Map::SwitchGridContainers(T* /*obj*/, bool /*on*/) { } |