fix(Core/Creature): Move DespawnOnEvade() respawn handling to map level (#17806)

This commit is contained in:
Andrew
2023-11-20 12:18:48 -03:00
committed by GitHub
parent e8ccda12e4
commit e3a7613f56
3 changed files with 22 additions and 2 deletions

View File

@@ -2102,8 +2102,10 @@ void Creature::ForcedDespawn(uint32 timeMSToDespawn, Seconds forceRespawnTimer)
if (forceRespawnTimer > Seconds::zero())
{
m_respawnTime = GameTime::GetGameTime().count() + forceRespawnTimer.count();
m_respawnDelay = forceRespawnTimer.count();
if (GetMap())
{
GetMap()->ScheduleCreatureRespawn(GetGUID(), forceRespawnTimer);
}
}
}

View File

@@ -754,6 +754,8 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/)
}
}
_creatureRespawnScheduler.Update(t_diff);
if (!t_diff)
{
for (m_mapRefIter = m_mapRefMgr.begin(); m_mapRefIter != m_mapRefMgr.end(); ++m_mapRefIter)
@@ -3695,6 +3697,17 @@ void Map::RemoveOldCorpses()
}
}
void Map::ScheduleCreatureRespawn(ObjectGuid creatureGuid, Milliseconds respawnTimer)
{
_creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid](TaskContext)
{
if (Creature* creature = GetCreature(creatureGuid))
{
creature->Respawn();
}
});
}
void Map::SendZoneDynamicInfo(Player* player)
{
uint32 zoneId = player->GetZoneId();

View File

@@ -32,6 +32,7 @@
#include "PathGenerator.h"
#include "Position.h"
#include "SharedDefines.h"
#include "TaskScheduler.h"
#include "Timer.h"
#include <bitset>
#include <list>
@@ -594,6 +595,10 @@ public:
void DeleteRespawnTimes();
[[nodiscard]] time_t GetInstanceResetPeriod() const { return _instanceResetPeriod; }
TaskScheduler _creatureRespawnScheduler;
void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/);
void LoadCorpseData();
void DeleteCorpseData();
void AddCorpse(Corpse* corpse);