From f5998c7624d831c29060e1c79591cbdaeb45a232 Mon Sep 17 00:00:00 2001 From: toaster Date: Fri, 23 Sep 2022 20:52:51 +0100 Subject: [PATCH] Skip over locked maps/cups when getting nextmap (carve out an exception for marathon mode, although we will probably want to lock that behind all cups available) --- src/g_game.c | 36 +++++++++++++++++++++++------------- src/m_cond.c | 3 ++- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index 19834d0ed..e038ea9ff 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3709,15 +3709,23 @@ static void G_GetNextMap(void) else { UINT32 tolflag = G_TOLFlag(gametype); + register INT16 cm; if (gametyperules & GTR_CAMPAIGN) { - register INT16 cm; cupheader_t *cup = mapheaderinfo[gamemap-1]->cup; UINT8 gettingresult = 0; while (cup) { + // Not unlocked? Grab the next result afterwards + if (!marathonmode && cup->unlockrequired != -1 && !unlockables[cup->unlockrequired].unlocked) + { + cup = cup->next; + gettingresult = 1; + continue; + } + for (i = 0; i < cup->numlevels; i++) { cm = cup->cachedlevels[i]; @@ -3726,7 +3734,8 @@ static void G_GetNextMap(void) if (cm >= nummapheaders || !mapheaderinfo[cm] || mapheaderinfo[cm]->lumpnum == LUMPERROR - || !(mapheaderinfo[cm]->typeoflevel & tolflag)) + || !(mapheaderinfo[cm]->typeoflevel & tolflag) + || (!marathonmode && M_MapLocked(cm+1))) continue; // Grab the first valid after the map you're on @@ -3772,26 +3781,27 @@ static void G_GetNextMap(void) } else { - i = prevmap; - if (++i >= nummapheaders) - i = 0; + cm = prevmap; + if (++cm >= nummapheaders) + cm = 0; - while (i != prevmap) + while (cm != prevmap) { - if (!mapheaderinfo[i] - || mapheaderinfo[i]->lumpnum == LUMPERROR - || !(mapheaderinfo[i]->typeoflevel & tolflag) - || (mapheaderinfo[i]->menuflags & LF2_HIDEINMENU)) + if (!mapheaderinfo[cm] + || mapheaderinfo[cm]->lumpnum == LUMPERROR + || !(mapheaderinfo[cm]->typeoflevel & tolflag) + || (mapheaderinfo[cm]->menuflags & LF2_HIDEINMENU) + || M_MapLocked(cm+1)) { - if (++i >= nummapheaders) - i = 0; + if (++cm >= nummapheaders) + cm = 0; continue; } break; } - nextmap = i; + nextmap = cm; } if (!marathonmode) diff --git a/src/m_cond.c b/src/m_cond.c index 94169936c..4dd42edca 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -432,7 +432,8 @@ UINT8 M_MapLocked(INT32 mapnum) if (1) return false; #endif - + if (!mapnum || mapnum > nummapheaders) + return false; if (!mapheaderinfo[mapnum-1] || mapheaderinfo[mapnum-1]->unlockrequired < 0) return false; if (!unlockables[mapheaderinfo[mapnum-1]->unlockrequired].unlocked)