mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Corpses: Fixed map crash happening during map unload when there are corpses inside
(cherry picked from commit 1d17475791)
This commit is contained in:
@@ -59,7 +59,7 @@ void Corpse::RemoveFromWorld()
|
||||
WorldObject::RemoveFromWorld();
|
||||
}
|
||||
|
||||
bool Corpse::Create(ObjectGuid::LowType guidlow, Map* map)
|
||||
bool Corpse::Create(ObjectGuid::LowType guidlow)
|
||||
{
|
||||
Object::_Create(ObjectGuid::Create<HighGuid::Corpse>(map->GetId(), 0, guidlow));
|
||||
return true;
|
||||
|
||||
@@ -55,7 +55,7 @@ class Corpse : public WorldObject, public GridObject<Corpse>
|
||||
void AddToWorld() override;
|
||||
void RemoveFromWorld() override;
|
||||
|
||||
bool Create(ObjectGuid::LowType guidlow, Map* map);
|
||||
bool Create(ObjectGuid::LowType guidlow);
|
||||
bool Create(ObjectGuid::LowType guidlow, Player* owner);
|
||||
|
||||
void SaveToDB();
|
||||
|
||||
@@ -1614,11 +1614,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();
|
||||
}
|
||||
|
||||
// *****************************
|
||||
@@ -3716,7 +3723,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));
|
||||
|
||||
Reference in New Issue
Block a user