Core/Objects: Add overridable function UpdateObjectVisibilityOnDestroy

This commit is contained in:
Shauren
2022-01-29 15:18:27 +01:00
parent 2864efdc53
commit 472384e757
5 changed files with 10 additions and 9 deletions

View File

@@ -425,7 +425,7 @@ void Creature::RemoveCorpse(bool setSpawnTime, bool destroyForNearbyPlayers)
ai->CorpseRemoved(respawnDelay);
if (destroyForNearbyPlayers)
DestroyForNearbyPlayers();
UpdateObjectVisibilityOnDestroy();
// Should get removed later, just keep "compatibility" with scripts
if (setSpawnTime)
@@ -2201,7 +2201,7 @@ void Creature::Respawn(bool force)
if (m_respawnCompatibilityMode)
{
DestroyForNearbyPlayers();
UpdateObjectVisibilityOnDestroy();
RemoveCorpse(false, false);
if (getDeathState() == DEAD)
@@ -2266,7 +2266,7 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
uint32 respawnDelay = GetRespawnDelay();
// do it before killing creature
DestroyForNearbyPlayers();
UpdateObjectVisibilityOnDestroy();
bool overrideRespawnTime = false;
if (IsAlive())

View File

@@ -957,7 +957,7 @@ void GameObject::Update(uint32 diff)
m_respawnTime = 0;
if (m_spawnId)
DestroyForNearbyPlayers();
UpdateObjectVisibilityOnDestroy();
else
Delete();
@@ -974,7 +974,7 @@ void GameObject::Update(uint32 diff)
SaveRespawnTime();
if (m_respawnCompatibilityMode)
DestroyForNearbyPlayers();
UpdateObjectVisibilityOnDestroy();
else
AddObjectToRemoveList();

View File

@@ -910,7 +910,7 @@ void WorldObject::RemoveFromWorld()
if (!IsInWorld())
return;
DestroyForNearbyPlayers();
UpdateObjectVisibilityOnDestroy();
Object::RemoveFromWorld();
}

View File

@@ -656,6 +656,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
void DestroyForNearbyPlayers();
virtual void UpdateObjectVisibility(bool forced = true);
virtual void UpdateObjectVisibilityOnCreate() { UpdateObjectVisibility(true); }
virtual void UpdateObjectVisibilityOnDestroy() { DestroyForNearbyPlayers(); }
void UpdatePositionData();
void BuildUpdate(UpdateDataMapType&) override;

View File

@@ -1079,7 +1079,7 @@ void Map::RemovePlayerFromMap(Player* player, bool remove)
SendRemoveTransports(player);
if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
player->DestroyForNearbyPlayers(); // previous player->UpdateObjectVisibility(true)
player->UpdateObjectVisibilityOnDestroy();
if (player->IsInGrid())
player->RemoveFromGrid();
@@ -1101,7 +1101,7 @@ void Map::RemoveFromMap(T *obj, bool remove)
GetMultiPersonalPhaseTracker().UnregisterTrackedObject(obj);
if (!inWorld) // if was in world, RemoveFromWorld() called DestroyForNearbyPlayers()
obj->DestroyForNearbyPlayers(); // previous obj->UpdateObjectVisibility(true)
obj->UpdateObjectVisibilityOnDestroy();
obj->RemoveFromGrid();
@@ -4788,7 +4788,7 @@ void Map::RemoveCorpse(Corpse* corpse)
{
ASSERT(corpse);
corpse->DestroyForNearbyPlayers();
corpse->UpdateObjectVisibilityOnDestroy();
if (corpse->IsInGrid())
RemoveFromMap(corpse, false);
else