mirror of
https://github.com/azerothcore/azerothcore-wotlk.git
synced 2025-11-10 21:04:26 +08:00
Compare commits
35 Commits
c83a9d2d42
...
014c571b31
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
014c571b31 | ||
|
|
90583a88fd | ||
|
|
01bea93901 | ||
|
|
8bc5a60d11 | ||
|
|
3aea01ab79 | ||
|
|
cbe83969db | ||
|
|
f8cc64e51d | ||
|
|
3b1eb7a127 | ||
|
|
4a086361b7 | ||
|
|
14e5b72793 | ||
|
|
c585d034b3 | ||
|
|
7cabf14f0d | ||
|
|
7b98bdaa2d | ||
|
|
c14f7c698e | ||
|
|
ece853f680 | ||
|
|
6471af26d7 | ||
|
|
e3be601d35 | ||
|
|
832b3091f0 | ||
|
|
12c56e2a3b | ||
|
|
5e2dd4bf41 | ||
|
|
cf5d1b8bde | ||
|
|
e3d8396182 | ||
|
|
ad5b615e28 | ||
|
|
08a21b16c8 | ||
|
|
c888ab9325 | ||
|
|
052d8b1cae | ||
|
|
f3fc1b6e49 | ||
|
|
dc246b145d | ||
|
|
1ac11e13e4 | ||
|
|
1ee1d6cd6b | ||
|
|
a620b29b57 | ||
|
|
d931498c70 | ||
|
|
131613c770 | ||
|
|
eb05f05b48 | ||
|
|
bcee010ef3 |
@ -120,7 +120,7 @@ class EventProcessor
|
||||
[[nodiscard]] uint64 CalculateQueueTime(uint64 delay) const;
|
||||
|
||||
void CancelEventGroup(uint8 group);
|
||||
bool HaveEventList() const { return !m_events.empty(); }
|
||||
bool HasEvents() const { return !m_events.empty(); }
|
||||
|
||||
protected:
|
||||
uint64 m_time{0};
|
||||
|
||||
@ -54,6 +54,10 @@ Map::~Map()
|
||||
{
|
||||
// UnloadAll must be called before deleting the map
|
||||
|
||||
// Kill all scheduled events without executing them, since the map and its objects are being destroyed.
|
||||
// This prevents events from running on invalid or deleted objects during map destruction.
|
||||
Events.KillAllEvents(false);
|
||||
|
||||
sScriptMgr->OnDestroyMap(this);
|
||||
|
||||
if (!m_scriptSchedule.empty())
|
||||
@ -447,7 +451,7 @@ void Map::Update(const uint32 t_diff, const uint32 s_diff, bool /*thread*/)
|
||||
}
|
||||
}
|
||||
|
||||
_creatureRespawnScheduler.Update(t_diff);
|
||||
Events.Update(t_diff);
|
||||
|
||||
if (!t_diff)
|
||||
{
|
||||
@ -2758,13 +2762,13 @@ void Map::RemoveOldCorpses()
|
||||
|
||||
void Map::ScheduleCreatureRespawn(ObjectGuid creatureGuid, Milliseconds respawnTimer, Position pos)
|
||||
{
|
||||
_creatureRespawnScheduler.Schedule(respawnTimer, [this, creatureGuid, pos](TaskContext)
|
||||
Events.AddEventAtOffset([this, creatureGuid, pos]()
|
||||
{
|
||||
if (Creature* creature = GetCreature(creatureGuid))
|
||||
creature->Respawn();
|
||||
else
|
||||
SummonCreature(creatureGuid.GetEntry(), pos);
|
||||
});
|
||||
}, respawnTimer);
|
||||
}
|
||||
|
||||
/// Send a packet to all players (or players selected team) in the zone (except self if mentioned)
|
||||
|
||||
@ -23,6 +23,7 @@
|
||||
#include "DataMap.h"
|
||||
#include "Define.h"
|
||||
#include "DynamicTree.h"
|
||||
#include "EventProcessor.h"
|
||||
#include "GameObjectModel.h"
|
||||
#include "GridDefines.h"
|
||||
#include "GridRefMgr.h"
|
||||
@ -33,7 +34,6 @@
|
||||
#include "PathGenerator.h"
|
||||
#include "Position.h"
|
||||
#include "SharedDefines.h"
|
||||
#include "TaskScheduler.h"
|
||||
#include "Timer.h"
|
||||
#include "GridTerrainData.h"
|
||||
#include <bitset>
|
||||
@ -172,7 +172,7 @@ public:
|
||||
// currently unused for normal maps
|
||||
bool CanUnload(uint32 diff)
|
||||
{
|
||||
if (!m_unloadTimer)
|
||||
if (!m_unloadTimer || Events.HasEvents())
|
||||
return false;
|
||||
|
||||
if (m_unloadTimer <= diff)
|
||||
@ -430,7 +430,7 @@ public:
|
||||
void UpdatePlayerZoneStats(uint32 oldZone, uint32 newZone);
|
||||
[[nodiscard]] uint32 ApplyDynamicModeRespawnScaling(WorldObject const* obj, uint32 respawnDelay) const;
|
||||
|
||||
TaskScheduler _creatureRespawnScheduler;
|
||||
EventProcessor Events;
|
||||
|
||||
void ScheduleCreatureRespawn(ObjectGuid /*creatureGuid*/, Milliseconds /*respawnTimer*/, Position pos = Position());
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user