mirror of
https://git.do.srb2.org/STJr/SRB2.git
synced 2025-01-30 21:20:54 +00:00
Merge branch 'endgame-code-refactor' into 'master'
Endgame code refactor This is mostly just some code cleanup and moving about: * `Y_EndGame` was moved from from y_inter.c/h to g_game.c/h, and renamed to `G_EndGame`. Frankly the old place that function lived didn't make sense, since it has nothing to do with tally screens directly. * Most of `Y_FollowIntermission`'s code was removed, because `G_AfterIntermission` does it all already. * And lastly, `G_ExitLevel` uses `HU_ClearCEcho()` instead of `HU_CEcho("")` to clear CEchos from the screen. The only visible changes in-game from the above should be just that log.txt stops adding empty new lines when you complete a level, and CEchos will always be cleared after tally screens when a level goes to credits/evaluation next. See merge request !98
This commit is contained in:
commit
448014097e
5 changed files with 41 additions and 51 deletions
|
@ -1723,7 +1723,7 @@ static void F_AdvanceToNextScene(void)
|
||||||
|
|
||||||
void F_EndCutScene(void)
|
void F_EndCutScene(void)
|
||||||
{
|
{
|
||||||
cutsceneover = true; // do this first, just in case Y_EndGame or something wants to turn it back false later
|
cutsceneover = true; // do this first, just in case G_EndGame or something wants to turn it back false later
|
||||||
if (runningprecutscene)
|
if (runningprecutscene)
|
||||||
{
|
{
|
||||||
if (server)
|
if (server)
|
||||||
|
@ -1738,7 +1738,7 @@ void F_EndCutScene(void)
|
||||||
else if (nextmap < 1100-1)
|
else if (nextmap < 1100-1)
|
||||||
G_NextLevel();
|
G_NextLevel();
|
||||||
else
|
else
|
||||||
Y_EndGame();
|
G_EndGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
36
src/g_game.c
36
src/g_game.c
|
@ -2633,7 +2633,7 @@ void G_ExitLevel(void)
|
||||||
CONS_Printf(M_GetText("The round has ended.\n"));
|
CONS_Printf(M_GetText("The round has ended.\n"));
|
||||||
|
|
||||||
// Remove CEcho text on round end.
|
// Remove CEcho text on round end.
|
||||||
HU_DoCEcho("");
|
HU_ClearCEcho();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2927,7 +2927,7 @@ void G_AfterIntermission(void)
|
||||||
if (nextmap < 1100-1)
|
if (nextmap < 1100-1)
|
||||||
G_NextLevel();
|
G_NextLevel();
|
||||||
else
|
else
|
||||||
Y_EndGame();
|
G_EndGame();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3013,6 +3013,38 @@ static void G_DoContinued(void)
|
||||||
gameaction = ga_nothing;
|
gameaction = ga_nothing;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
|
// G_EndGame (formerly Y_EndGame)
|
||||||
|
// Frankly this function fits better in g_game.c than it does in y_inter.c
|
||||||
|
//
|
||||||
|
// ...Gee, (why) end the game?
|
||||||
|
// Because G_AfterIntermission and F_EndCutscene would
|
||||||
|
// both do this exact same thing *in different ways* otherwise,
|
||||||
|
// which made it so that you could only unlock Ultimate mode
|
||||||
|
// if you had a cutscene after the final level and crap like that.
|
||||||
|
// This function simplifies it so only one place has to be updated
|
||||||
|
// when something new is added.
|
||||||
|
void G_EndGame(void)
|
||||||
|
{
|
||||||
|
// Only do evaluation and credits in coop games.
|
||||||
|
if (gametype == GT_COOP)
|
||||||
|
{
|
||||||
|
if (nextmap == 1102-1) // end game with credits
|
||||||
|
{
|
||||||
|
F_StartCredits();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (nextmap == 1101-1) // end game with evaluation
|
||||||
|
{
|
||||||
|
F_StartGameEvaluation();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// 1100 or competitive multiplayer, so go back to title screen.
|
||||||
|
D_StartTitle();
|
||||||
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
// G_LoadGameSettings
|
// G_LoadGameSettings
|
||||||
//
|
//
|
||||||
|
|
|
@ -174,6 +174,7 @@ void G_NextLevel(void);
|
||||||
void G_Continue(void);
|
void G_Continue(void);
|
||||||
void G_UseContinue(void);
|
void G_UseContinue(void);
|
||||||
void G_AfterIntermission(void);
|
void G_AfterIntermission(void);
|
||||||
|
void G_EndGame(void); // moved from y_inter.c/h and renamed
|
||||||
|
|
||||||
void G_Ticker(boolean run);
|
void G_Ticker(boolean run);
|
||||||
boolean G_Responder(event_t *ev);
|
boolean G_Responder(event_t *ev);
|
||||||
|
|
|
@ -1823,37 +1823,6 @@ void Y_EndIntermission(void)
|
||||||
usebuffer = false;
|
usebuffer = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
|
||||||
// Y_EndGame
|
|
||||||
//
|
|
||||||
// Why end the game?
|
|
||||||
// Because Y_FollowIntermission and F_EndCutscene would
|
|
||||||
// both do this exact same thing *in different ways* otherwise,
|
|
||||||
// which made it so that you could only unlock Ultimate mode
|
|
||||||
// if you had a cutscene after the final level and crap like that.
|
|
||||||
// This function simplifies it so only one place has to be updated
|
|
||||||
// when something new is added.
|
|
||||||
void Y_EndGame(void)
|
|
||||||
{
|
|
||||||
// Only do evaluation and credits in coop games.
|
|
||||||
if (gametype == GT_COOP)
|
|
||||||
{
|
|
||||||
if (nextmap == 1102-1) // end game with credits
|
|
||||||
{
|
|
||||||
F_StartCredits();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (nextmap == 1101-1) // end game with evaluation
|
|
||||||
{
|
|
||||||
F_StartGameEvaluation();
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// 1100 or competitive multiplayer, so go back to title screen.
|
|
||||||
D_StartTitle();
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// Y_FollowIntermission
|
// Y_FollowIntermission
|
||||||
//
|
//
|
||||||
|
@ -1865,21 +1834,10 @@ static void Y_FollowIntermission(void)
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (nextmap < 1100-1)
|
// This handles whether to play a post-level cutscene, end the game,
|
||||||
{
|
// or simply go to the next level.
|
||||||
// normal level
|
// No need to duplicate the code here!
|
||||||
G_AfterIntermission();
|
G_AfterIntermission();
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Start a custom cutscene if there is one.
|
|
||||||
if (mapheaderinfo[gamemap-1]->cutscenenum && !modeattacking)
|
|
||||||
{
|
|
||||||
F_StartCustomCutscene(mapheaderinfo[gamemap-1]->cutscenenum-1, false, false);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
Y_EndGame();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL
|
#define UNLOAD(x) Z_ChangeTag(x, PU_CACHE); x = NULL
|
||||||
|
|
|
@ -15,7 +15,6 @@ void Y_IntermissionDrawer(void);
|
||||||
void Y_Ticker(void);
|
void Y_Ticker(void);
|
||||||
void Y_StartIntermission(void);
|
void Y_StartIntermission(void);
|
||||||
void Y_EndIntermission(void);
|
void Y_EndIntermission(void);
|
||||||
void Y_EndGame(void);
|
|
||||||
|
|
||||||
typedef enum
|
typedef enum
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue