diff --git a/src/events.cpp b/src/events.cpp index 0b8802c910..19034d4957 100755 --- a/src/events.cpp +++ b/src/events.cpp @@ -515,15 +515,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 cacc78ce70..392ae0680e 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 69514f6907..05c41614ab 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1004,7 +1004,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 a9414a776b..32d3dd5ff8 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3722,7 +3722,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. :-)