From ab243e6ffa737ceb985ded9ccfa1497ee6f29c98 Mon Sep 17 00:00:00 2001 From: toaster Date: Mon, 26 Sep 2022 17:15:34 +0100 Subject: [PATCH] Fix G_UpdateVisited, this time in a forward-thinking way - Check for if a single local player isn't spectator or no-contested. - Clean up code to return early if exclusionary conditions are met, rather than one long if conditional bundling them together --- src/g_game.c | 51 +++++++++++++++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 16 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index d598ce30c..740938394 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3738,27 +3738,46 @@ void G_AddMapToBuffer(INT16 map) // static void G_UpdateVisited(void) { - // Update visitation flags? - if (/*(!majormods || savemoddata) // Not modified - &&*/ !multiplayer && !demo.playback // SP/RA/NiGHTS mode - && !(modeattacking && (players[consoleplayer].pflags & PF_NOCONTEST))) // Not failed + UINT8 i; + UINT8 earnedEmblems; + + // No demos. + if (demo.playback) + return; + + // Check if every local player wiped out. + for (i = 0; i < MAXPLAYERS; i++) { - UINT8 earnedEmblems; + if (!playeringame[i]) // Not here. + continue; - // Update visitation flags - mapheaderinfo[gamemap-1]->mapvisited |= MV_BEATEN; + if (!P_IsLocalPlayer(&players[i])) // Not local. + continue; - if (encoremode == true) - { - mapheaderinfo[gamemap-1]->mapvisited |= MV_ENCORE; - } + if (players[i].spectator) // Not playing. + continue; - if (modeattacking) - G_UpdateRecordReplays(); - - if ((earnedEmblems = M_CompletionEmblems())) - CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); + if (players[i].pflags & PF_NOCONTEST) // Sonic after not surviving. + continue; + break; } + + if (i == MAXPLAYERS) // Not a single living local soul? + return; + + // Update visitation flags + mapheaderinfo[gamemap-1]->mapvisited |= MV_BEATEN; + + if (encoremode == true) + { + mapheaderinfo[gamemap-1]->mapvisited |= MV_ENCORE; + } + + if (modeattacking) + G_UpdateRecordReplays(); + + if ((earnedEmblems = M_CompletionEmblems())) + CONS_Printf(M_GetText("\x82" "Earned %hu emblem%s for level completion.\n"), (UINT16)earnedEmblems, earnedEmblems > 1 ? "s" : ""); } static boolean CanSaveLevel(INT32 mapnum)