Skip to content

Commit 2103ce7

Browse files
committed
Clean up naming convention and EventMgr destructor
1 parent 4de365c commit 2103ce7

File tree

7 files changed

+16
-18
lines changed

7 files changed

+16
-18
lines changed

ElunaEventMgr.cpp

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,15 @@ extern "C"
2020

2121
ElunaEventProcessor::ElunaEventProcessor(Eluna* _E, WorldObject* _obj) : m_time(0), obj(_obj), E(_E)
2222
{
23-
if (E->eventMgr)
23+
if (E && E->eventMgr)
2424
E->eventMgr->processors.insert(this);
2525
}
2626

2727
ElunaEventProcessor::~ElunaEventProcessor()
2828
{
2929
RemoveEvents_internal();
3030

31-
if (E->eventMgr)
31+
if (E && E->eventMgr)
3232
E->eventMgr->processors.erase(this);
3333
}
3434

@@ -192,10 +192,8 @@ EventMgr::EventMgr(Eluna* _E) : E(_E)
192192

193193
EventMgr::~EventMgr()
194194
{
195-
for (auto* processor : processors)
196-
processor->RemoveEvents_internal();
197-
198195
globalProcessors.clear();
196+
processors.clear();
199197
}
200198

201199
void EventMgr::UpdateProcessors(uint32 diff)
@@ -210,13 +208,13 @@ void EventMgr::UpdateProcessors(uint32 diff)
210208
}
211209
}
212210

213-
void EventMgr::SetStates(LuaEventState state)
211+
void EventMgr::SetAllEventStates(LuaEventState state)
214212
{
215213
for (auto* processor : processors)
216214
processor->SetStates(state);
217215
}
218216

219-
void EventMgr::SetState(int eventId, LuaEventState state)
217+
void EventMgr::SetEventState(int eventId, LuaEventState state)
220218
{
221219
for (auto* processor : processors)
222220
processor->SetState(eventId, state);

ElunaEventMgr.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ class EventMgr
125125
~EventMgr();
126126

127127
void UpdateProcessors(uint32 diff);
128-
void SetStates(LuaEventState state);
129-
void SetState(int eventId, LuaEventState state);
128+
void SetAllEventStates(LuaEventState state);
129+
void SetEventState(int eventId, LuaEventState state);
130130

131131
ElunaEventProcessor* GetGlobalProcessor(GlobalEventSpace space);
132132

LuaEngine.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ extern void RegisterMethods(Eluna* E);
3333
void Eluna::_ReloadEluna()
3434
{
3535
// Remove all timed events
36-
eventMgr->SetStates(LUAEVENT_STATE_ERASE);
36+
eventMgr->SetAllEventStates(LUAEVENT_STATE_ERASE);
3737

3838
#if defined ELUNA_TRINITY
3939
// Cancel all pending async queries

methods/CMangos/GlobalMethods.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1619,7 +1619,7 @@ namespace LuaGlobalFunctions
16191619

16201620
// not thread safe
16211621
if (all_Events)
1622-
E->eventMgr->SetState(eventId, LUAEVENT_STATE_ABORT);
1622+
E->eventMgr->SetEventState(eventId, LUAEVENT_STATE_ABORT);
16231623
else
16241624
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetState(eventId, LUAEVENT_STATE_ABORT);
16251625
return 0;
@@ -1636,7 +1636,7 @@ namespace LuaGlobalFunctions
16361636

16371637
// not thread safe
16381638
if (all_Events)
1639-
E->eventMgr->SetStates(LUAEVENT_STATE_ABORT);
1639+
E->eventMgr->SetAllEventStates(LUAEVENT_STATE_ABORT);
16401640
else
16411641
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetStates(LUAEVENT_STATE_ABORT);
16421642
return 0;

methods/Mangos/GlobalMethods.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1413,7 +1413,7 @@ namespace LuaGlobalFunctions
14131413

14141414
// not thread safe
14151415
if (all_Events)
1416-
E->eventMgr->SetState(eventId, LUAEVENT_STATE_ABORT);
1416+
E->eventMgr->SetEventState(eventId, LUAEVENT_STATE_ABORT);
14171417
else
14181418
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetState(eventId, LUAEVENT_STATE_ABORT);
14191419
return 0;
@@ -1430,7 +1430,7 @@ namespace LuaGlobalFunctions
14301430

14311431
// not thread safe
14321432
if (all_Events)
1433-
E->eventMgr->SetStates(LUAEVENT_STATE_ABORT);
1433+
E->eventMgr->SetAllEventStates(LUAEVENT_STATE_ABORT);
14341434
else
14351435
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetStates(LUAEVENT_STATE_ABORT);
14361436
return 0;

methods/TrinityCore/GlobalMethods.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1613,7 +1613,7 @@ namespace LuaGlobalFunctions
16131613

16141614
// not thread safe
16151615
if (all_Events)
1616-
E->eventMgr->SetState(eventId, LUAEVENT_STATE_ABORT);
1616+
E->eventMgr->SetEventState(eventId, LUAEVENT_STATE_ABORT);
16171617
else
16181618
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetState(eventId, LUAEVENT_STATE_ABORT);
16191619
return 0;
@@ -1630,7 +1630,7 @@ namespace LuaGlobalFunctions
16301630

16311631
// not thread safe
16321632
if (all_Events)
1633-
E->eventMgr->SetStates(LUAEVENT_STATE_ABORT);
1633+
E->eventMgr->SetAllEventStates(LUAEVENT_STATE_ABORT);
16341634
else
16351635
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetStates(LUAEVENT_STATE_ABORT);
16361636
return 0;

methods/VMangos/GlobalMethods.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1409,7 +1409,7 @@ namespace LuaGlobalFunctions
14091409

14101410
// not thread safe
14111411
if (all_Events)
1412-
E->eventMgr->SetState(eventId, LUAEVENT_STATE_ABORT);
1412+
E->eventMgr->SetEventState(eventId, LUAEVENT_STATE_ABORT);
14131413
else
14141414
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetState(eventId, LUAEVENT_STATE_ABORT);
14151415
return 0;
@@ -1426,7 +1426,7 @@ namespace LuaGlobalFunctions
14261426

14271427
// not thread safe
14281428
if (all_Events)
1429-
E->eventMgr->SetStates(LUAEVENT_STATE_ABORT);
1429+
E->eventMgr->SetAllEventStates(LUAEVENT_STATE_ABORT);
14301430
else
14311431
E->eventMgr->GetGlobalProcessor(GLOBAL_EVENTS)->SetStates(LUAEVENT_STATE_ABORT);
14321432
return 0;

0 commit comments

Comments
 (0)