mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
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 8c9ea7782a)
This commit is contained in:
@@ -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*/) { }
|
||||
|
||||
|
||||
Reference in New Issue
Block a user