mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 15:21:51 +00:00
- Static NewGame events now fire before loading a map, and normal NewGame events fire after registering per-map handlers and before all other events.
- Static event handlers now unregister after per-map handlers. - All event handlers now unregister in reverse order.
This commit is contained in:
parent
2dec7bb1e5
commit
04ae32f6f9
7 changed files with 33 additions and 21 deletions
|
@ -301,7 +301,7 @@ void E_InitStaticHandlers(bool map)
|
|||
void E_Shutdown(bool map)
|
||||
{
|
||||
// delete handlers.
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
for (DStaticEventHandler* handler = E_LastEventHandler; handler; handler = handler->prev)
|
||||
{
|
||||
if (handler->IsStatic() == !map)
|
||||
handler->Destroy();
|
||||
|
@ -515,11 +515,16 @@ bool E_CheckReplacement( PClassActor *replacee, PClassActor **replacement )
|
|||
return final;
|
||||
}
|
||||
|
||||
void E_NewGame()
|
||||
void E_NewGame(bool map)
|
||||
{
|
||||
// Shut down all per-map event handlers before static NewGame events.
|
||||
if (!map)
|
||||
E_Shutdown(true);
|
||||
|
||||
for (DStaticEventHandler* handler = E_FirstEventHandler; handler; handler = handler->next)
|
||||
{
|
||||
handler->NewGame();
|
||||
if (handler->IsStatic() == !map)
|
||||
handler->NewGame();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -73,7 +73,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();
|
||||
void E_NewGame(bool map);
|
||||
|
||||
// send networked event. unified function.
|
||||
bool E_SendNetworkEvent(FString name, int arg1, int arg2, int arg3, bool manual);
|
||||
|
|
|
@ -1054,7 +1054,7 @@ void G_Ticker ()
|
|||
switch (gameaction)
|
||||
{
|
||||
case ga_loadlevel:
|
||||
G_DoLoadLevel (-1, false);
|
||||
G_DoLoadLevel (-1, false, false);
|
||||
break;
|
||||
case ga_recordgame:
|
||||
G_CheckDemoStatus();
|
||||
|
|
|
@ -526,11 +526,8 @@ void G_InitNew (const char *mapname, bool bTitleLevel)
|
|||
{
|
||||
gamestate = GS_LEVEL;
|
||||
}
|
||||
G_DoLoadLevel (0, false);
|
||||
if(!savegamerestore)
|
||||
{
|
||||
E_NewGame();
|
||||
}
|
||||
|
||||
G_DoLoadLevel (0, false, !savegamerestore);
|
||||
}
|
||||
|
||||
//
|
||||
|
@ -744,7 +741,7 @@ void G_DoCompleted (void)
|
|||
if (gamestate == GS_TITLELEVEL)
|
||||
{
|
||||
level.MapName = nextlevel;
|
||||
G_DoLoadLevel (startpos, false);
|
||||
G_DoLoadLevel (startpos, false, false);
|
||||
startpos = 0;
|
||||
viewactive = true;
|
||||
return;
|
||||
|
@ -919,7 +916,7 @@ void DAutosaver::Tick ()
|
|||
|
||||
extern gamestate_t wipegamestate;
|
||||
|
||||
void G_DoLoadLevel (int position, bool autosave)
|
||||
void G_DoLoadLevel (int position, bool autosave, bool newGame)
|
||||
{
|
||||
static int lastposition = 0;
|
||||
gamestate_t oldgs = gamestate;
|
||||
|
@ -1005,7 +1002,12 @@ void G_DoLoadLevel (int position, bool autosave)
|
|||
|
||||
level.maptime = 0;
|
||||
|
||||
P_SetupLevel (level.MapName, position);
|
||||
if (newGame)
|
||||
{
|
||||
E_NewGame(false);
|
||||
}
|
||||
|
||||
P_SetupLevel (level.MapName, position, newGame);
|
||||
|
||||
AM_LevelInit();
|
||||
|
||||
|
@ -1253,7 +1255,7 @@ void G_DoWorldDone (void)
|
|||
level.MapName = nextlevel;
|
||||
}
|
||||
G_StartTravel ();
|
||||
G_DoLoadLevel (startpos, true);
|
||||
G_DoLoadLevel (startpos, true, false);
|
||||
startpos = 0;
|
||||
gameaction = ga_nothing;
|
||||
viewactive = true;
|
||||
|
|
|
@ -507,7 +507,7 @@ void G_ChangeLevel(const char *levelname, int position, int flags, int nextSkill
|
|||
void G_StartTravel ();
|
||||
int G_FinishTravel ();
|
||||
|
||||
void G_DoLoadLevel (int position, bool autosave);
|
||||
void G_DoLoadLevel (int position, bool autosave, bool newGame);
|
||||
|
||||
void G_InitLevelLocals (void);
|
||||
|
||||
|
|
|
@ -3642,7 +3642,7 @@ void P_FreeExtraLevelData()
|
|||
//
|
||||
//===========================================================================
|
||||
|
||||
void P_SetupLevel (const char *lumpname, int position)
|
||||
void P_SetupLevel (const char *lumpname, int position, bool newGame)
|
||||
{
|
||||
cycle_t times[20];
|
||||
#if 0
|
||||
|
@ -3720,6 +3720,11 @@ void P_SetupLevel (const char *lumpname, int position)
|
|||
level.lumpnum = map->lumpnum;
|
||||
hasglnodes = false;
|
||||
|
||||
if (newGame)
|
||||
{
|
||||
E_NewGame(true);
|
||||
}
|
||||
|
||||
// [RH] Support loading Build maps (because I felt like it. :-)
|
||||
buildmap = false;
|
||||
#if 0
|
||||
|
@ -4298,13 +4303,13 @@ void P_Init ()
|
|||
}
|
||||
|
||||
static void P_Shutdown ()
|
||||
{
|
||||
// [ZZ] delete global event handlers
|
||||
DThinker::DestroyThinkersInList(STAT_STATIC);
|
||||
E_Shutdown(false);
|
||||
{
|
||||
DThinker::DestroyThinkersInList(STAT_STATIC);
|
||||
P_DeinitKeyMessages ();
|
||||
P_FreeLevelData ();
|
||||
P_FreeExtraLevelData ();
|
||||
// [ZZ] delete global event handlers
|
||||
E_Shutdown(false);
|
||||
ST_Clear();
|
||||
FS_Close();
|
||||
for (auto &p : players)
|
||||
|
|
|
@ -138,7 +138,7 @@ bool P_CheckMapData(const char * mapname);
|
|||
// [RH] The only parameter used is mapname, so I removed playermask and skill.
|
||||
// On September 1, 1998, I added the position to indicate which set
|
||||
// of single-player start spots should be spawned in the level.
|
||||
void P_SetupLevel (const char *mapname, int position);
|
||||
void P_SetupLevel (const char *mapname, int position, bool newGame);
|
||||
|
||||
void P_FreeLevelData();
|
||||
void P_FreeExtraLevelData();
|
||||
|
|
Loading…
Reference in a new issue