- Introduced an enum named EventHandlerType and changed the bool argument in E_NewGame to this type.

This commit is contained in:
Player701 2018-10-31 17:52:39 +03:00 committed by Christoph Oelckers
parent 04ae32f6f9
commit 3e609f2b87
4 changed files with 14 additions and 6 deletions

View file

@ -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();
}
}

View file

@ -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);

View file

@ -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);

View file

@ -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. :-)