diff --git a/src/events.cpp b/src/events.cpp index 22dbbbbcc..f34cb37e3 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -516,15 +516,17 @@ bool E_CheckReplacement( PClassActor *replacee, PClassActor **replacement ) return final; } -void E_NewGame(bool map) +void E_NewGame(EventHandlerType handlerType) { + bool isStatic = handlerType == EventHandlerType::Global; + // Shut down all per-map event handlers before static NewGame events. - if (!map) + if (isStatic) E_Shutdown(true); for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next) { - if (handler->IsStatic() == !map) + if (handler->IsStatic() == isStatic) handler->NewGame(); } } diff --git a/src/events.h b/src/events.h index cacc78ce7..392ae0680 100755 --- a/src/events.h +++ b/src/events.h @@ -9,6 +9,12 @@ class DStaticEventHandler; +enum class EventHandlerType +{ + Global, + PerMap +}; + // register bool E_RegisterHandler(DStaticEventHandler* handler); // unregister @@ -73,7 +79,7 @@ void E_Console(int player, FString name, int arg1, int arg2, int arg3, bool manu bool E_CheckReplacement(PClassActor* replacee, PClassActor** replacement); // called on new game -void E_NewGame(bool map); +void E_NewGame(EventHandlerType handlerType); // send networked event. unified function. bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual); diff --git a/src/g_level.cpp b/src/g_level.cpp index e2ed4e280..fb0d8ed29 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -993,7 +993,7 @@ void G_DoLoadLevel (int position, bool autosave, bool newGame) if (newGame) { - E_NewGame(false); + E_NewGame(EventHandlerType::Global); } P_SetupLevel (level.MapName, position, newGame); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index fecc4aa54..a0a68cdf4 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3699,7 +3699,7 @@ void P_SetupLevel (const char *lumpname, int position, bool newGame) if (newGame) { - E_NewGame(true); + E_NewGame(EventHandlerType::PerMap); } // [RH] Support loading Build maps (because I felt like it. :-)