mirror of
https://github.com/mod-playerbots/azerothcore-wotlk.git
synced 2026-01-16 10:30:27 +00:00
fix(Core/Creature): Move DespawnOnEvade() respawn handling to map level (#17806)
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user