From bde16b96a0492863f099acca03ff1e3054f1942a 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 1212ba904..a10a6dec7 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3841,15 +3841,23 @@ static INT16 G_GetNextMap(boolean advancemap) else { UINT32 tolflag = G_TOLFlag(gametype); + register INT16 cm; if (grandprixinfo.gp == true) { - 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]; @@ -3858,7 +3866,8 @@ static INT16 G_GetNextMap(boolean advancemap) 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 @@ -3904,26 +3913,27 @@ static INT16 G_GetNextMap(boolean advancemap) } else { - i = curmap; - if (++i >= nummapheaders) - i = 0; + cm = curmap; + if (++cm >= nummapheaders) + cm = 0; - while (i != curmap) + while (cm != curmap) { - 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; } - newmap = i; + newmap = cm; } if (advancemap && !marathonmode) diff --git a/src/m_cond.c b/src/m_cond.c index e9d2c71b2..64b580191 100644 --- a/src/m_cond.c +++ b/src/m_cond.c @@ -479,7 +479,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)