Core/Corpses: Fixed map crash happening during map unload when there are corpses inside

(cherry picked from commit 1d17475791)
This commit is contained in:
Shauren
2015-10-29 18:46:37 +01:00
committed by ariel-
parent fc9c587604
commit b7d37daa74
3 changed files with 10 additions and 3 deletions

View File

@@ -1580,11 +1580,18 @@ void Map::UnloadAll()
}
for (auto& cellCorpsePair : _corpsesByCell)
{
for (Corpse* corpse : cellCorpsePair.second)
{
corpse->RemoveFromWorld();
corpse->ResetMap();
delete corpse;
}
}
_corpsesByCell.clear();
_corpsesByPlayer.clear();
_corpseBones.clear();
}
// *****************************
@@ -3657,7 +3664,7 @@ Corpse* Map::ConvertCorpseToBones(ObjectGuid const& ownerGuid, bool insignia /*=
{
// Create bones, don't change Corpse
bones = new Corpse();
bones->Create(corpse->GetGUID().GetCounter(), this);
bones->Create(corpse->GetGUID().GetCounter());
for (uint8 i = OBJECT_FIELD_GUID + 4; i < CORPSE_END; ++i) // don't overwrite guid
bones->SetUInt32Value(i, corpse->GetUInt32Value(i));