Skip to content

Commit 5aa0d5d

Browse files
ShaurenOvahlord
authored andcommitted
Core/Objects: Move EventProcessor update to WorldObject::Update
(cherry picked from commit 6965b2)
1 parent 38d4e08 commit 5aa0d5d

5 files changed

Lines changed: 13 additions & 7 deletions

File tree

src/server/game/Entities/GameObject/GameObject.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -452,8 +452,6 @@ bool GameObject::Create(ObjectGuid::LowType guidlow, uint32 name_id, Map* map, u
452452

453453
void GameObject::Update(uint32 diff)
454454
{
455-
m_Events.Update(diff);
456-
457455
WorldObject::Update(diff);
458456

459457
if (AI())

src/server/game/Entities/Object/Object.cpp

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -957,6 +957,11 @@ WorldObject::~WorldObject()
957957
}
958958
}
959959

960+
void WorldObject::Update(uint32 diff)
961+
{
962+
m_Events.Update(diff);
963+
}
964+
960965
void WorldObject::SetIsStoredInWorldObjectGridContainer(bool on)
961966
{
962967
if (!IsInWorld())
@@ -1023,6 +1028,8 @@ void WorldObject::CleanupsBeforeDelete(bool /*finalCleanup*/)
10231028

10241029
if (Transport* transport = GetTransport())
10251030
transport->RemovePassenger(this);
1031+
1032+
m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
10261033
}
10271034

10281035
void WorldObject::UpdatePositionData()

src/server/game/Entities/Object/Object.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -339,7 +339,7 @@ class TC_GAME_API WorldObject : public Object, public WorldLocation
339339
public:
340340
virtual ~WorldObject();
341341

342-
virtual void Update(uint32 /*time_diff*/) { }
342+
virtual void Update(uint32 diff);
343343

344344
void AddToWorld() override;
345345
void RemoveFromWorld() override;

src/server/game/Entities/Unit/Unit.cpp

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -434,7 +434,7 @@ void Unit::Update(uint32 p_time)
434434
// WARNING! Order of execution here is important, do not change.
435435
// Spells must be processed with event system BEFORE they go to _UpdateSpells.
436436
// Or else we may have some SPELL_STATE_FINISHED spells stalled in pointers, that is bad.
437-
m_Events.Update(p_time);
437+
WorldObject::Update(p_time);
438438

439439
CheckPendingMovementAcks();
440440

@@ -443,8 +443,6 @@ void Unit::Update(uint32 p_time)
443443

444444
_UpdateSpells(p_time);
445445

446-
WorldObject::Update(p_time);
447-
448446
// If this is set during update SetCantProc(false) call is missing somewhere in the code
449447
// Having this would prevent spells from being proced, so let's crash
450448
ASSERT(!m_procDeep);
@@ -9668,7 +9666,6 @@ void Unit::CleanupBeforeRemoveFromMap(bool finalCleanup)
96689666
if (finalCleanup)
96699667
m_cleanupDone = true;
96709668

9671-
m_Events.KillAllEvents(false); // non-delatable (currently cast spells) will not deleted now but it will deleted at call in Map::RemoveAllObjectsInRemoveList
96729669
CombatStop();
96739670
ClearComboPoints();
96749671
ClearComboPointHolders();

src/server/game/Scripting/ScriptMgr.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -404,6 +404,10 @@ class CreatureGameObjectScriptRegistrySwapHooks
404404
// Hook which is called before a gameobject is swapped
405405
static void UnloadResetScript(GameObject* gameobject)
406406
{
407+
// Remove deletable events only,
408+
// otherwise it causes crashes with non-deletable spell events.
409+
gameobject->m_Events.KillAllEvents(false);
410+
407411
gameobject->AI()->Reset();
408412
}
409413

0 commit comments

Comments
 (0)