From 143d4aa05348000e2d0841f1d45aa27b1ffb7354 Mon Sep 17 00:00:00 2001 From: toaster Date: Thu, 21 Nov 2019 23:38:33 +0000 Subject: [PATCH] Move all the visitation/emblems/record attack update stuff into a single function, and call that function in two different places depending on whether the tally screen is visited or not. --- src/g_game.c | 73 ++++++++++++++++++++++++++++++---------------------- 1 file changed, 42 insertions(+), 31 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index cc82f5d5c..a18967052 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3213,6 +3213,44 @@ static INT16 RandMap(INT16 tolflags, INT16 pprevmap) return ix; } +// +// G_UpdateVisited +// +static void G_UpdateVisited(void) +{ + boolean spec = G_IsSpecialStage(gamemap); + // Update visitation flags? + if ((!modifiedgame || savemoddata) // Not modified + && !multiplayer && !demoplayback && (gametype == GT_COOP) // SP/RA/NiGHTS mode + && !(spec && stagefailed)) // Not failed the special stage + { + UINT8 earnedEmblems; + + // Update visitation flags + mapvisited[gamemap-1] |= MV_BEATEN; + // eh, what the hell + if (ultimatemode) + mapvisited[gamemap-1] |= MV_ULTIMATE; + // may seem incorrect but IS possible in what the main game uses as special stages, and nummaprings will be -1 in NiGHTS + if (nummaprings > 0 && players[consoleplayer].rings >= nummaprings) + mapvisited[gamemap-1] |= MV_PERFECT; + if (!spec) + { + // not available to special stages because they can only really be done in one order in an unmodified game, so impossible for first six and trivial for seventh + if (ALL7EMERALDS(emeralds)) + mapvisited[gamemap-1] |= MV_ALLEMERALDS; + } + + if (modeattacking == ATTACKING_RECORD) + G_UpdateRecordReplays(); + else if (modeattacking == ATTACKING_NIGHTS) + G_SetNightsRecords(); + + if ((earnedEmblems = M_CompletionEmblems())) + CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); + } +} + // // G_DoCompleted // @@ -3342,43 +3380,16 @@ static void G_DoCompleted(void) if (nextmap < NUMMAPS && !mapheaderinfo[nextmap]) P_AllocMapHeader(nextmap); - // Update visitation flags? - if ((!modifiedgame || savemoddata) // Not modified - && !multiplayer && !demoplayback && (gametype == GT_COOP) // SP/RA/NiGHTS mode - && !(spec && stagefailed)) // Not failed the special stage - { - UINT8 earnedEmblems; - - // Update visitation flags - mapvisited[gamemap-1] |= MV_BEATEN; - // eh, what the hell - if (ultimatemode) - mapvisited[gamemap-1] |= MV_ULTIMATE; - // may seem incorrect but IS possible in what the main game uses as special stages, and nummaprings will be -1 in NiGHTS - if (nummaprings > 0 && players[consoleplayer].rings >= nummaprings) - mapvisited[gamemap-1] |= MV_PERFECT; - if (!spec) - { - // not available to special stages because they can only really be done in one order in an unmodified game, so impossible for first six and trivial for seventh - if (ALL7EMERALDS(emeralds)) - mapvisited[gamemap-1] |= MV_ALLEMERALDS; - } - - if (modeattacking == ATTACKING_RECORD) - G_UpdateRecordReplays(); - else if (modeattacking == ATTACKING_NIGHTS) - G_SetNightsRecords(); - - if ((earnedEmblems = M_CompletionEmblems())) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); - } - if ((skipstats && !modeattacking) || (spec && modeattacking && stagefailed)) + { + G_UpdateVisited(); G_AfterIntermission(); + } else { G_SetGamestate(GS_INTERMISSION); Y_StartIntermission(); + G_UpdateVisited(); } }