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)
This commit is contained in:
toaster 2022-09-23 20:52:51 +01:00
parent 3dd4394d70
commit f5998c7624
2 changed files with 25 additions and 14 deletions

View file

@ -3709,15 +3709,23 @@ static void G_GetNextMap(void)
else else
{ {
UINT32 tolflag = G_TOLFlag(gametype); UINT32 tolflag = G_TOLFlag(gametype);
register INT16 cm;
if (gametyperules & GTR_CAMPAIGN) if (gametyperules & GTR_CAMPAIGN)
{ {
register INT16 cm;
cupheader_t *cup = mapheaderinfo[gamemap-1]->cup; cupheader_t *cup = mapheaderinfo[gamemap-1]->cup;
UINT8 gettingresult = 0; UINT8 gettingresult = 0;
while (cup) 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++) for (i = 0; i < cup->numlevels; i++)
{ {
cm = cup->cachedlevels[i]; cm = cup->cachedlevels[i];
@ -3726,7 +3734,8 @@ static void G_GetNextMap(void)
if (cm >= nummapheaders if (cm >= nummapheaders
|| !mapheaderinfo[cm] || !mapheaderinfo[cm]
|| mapheaderinfo[cm]->lumpnum == LUMPERROR || mapheaderinfo[cm]->lumpnum == LUMPERROR
|| !(mapheaderinfo[cm]->typeoflevel & tolflag)) || !(mapheaderinfo[cm]->typeoflevel & tolflag)
|| (!marathonmode && M_MapLocked(cm+1)))
continue; continue;
// Grab the first valid after the map you're on // Grab the first valid after the map you're on
@ -3772,26 +3781,27 @@ static void G_GetNextMap(void)
} }
else else
{ {
i = prevmap; cm = prevmap;
if (++i >= nummapheaders) if (++cm >= nummapheaders)
i = 0; cm = 0;
while (i != prevmap) while (cm != prevmap)
{ {
if (!mapheaderinfo[i] if (!mapheaderinfo[cm]
|| mapheaderinfo[i]->lumpnum == LUMPERROR || mapheaderinfo[cm]->lumpnum == LUMPERROR
|| !(mapheaderinfo[i]->typeoflevel & tolflag) || !(mapheaderinfo[cm]->typeoflevel & tolflag)
|| (mapheaderinfo[i]->menuflags & LF2_HIDEINMENU)) || (mapheaderinfo[cm]->menuflags & LF2_HIDEINMENU)
|| M_MapLocked(cm+1))
{ {
if (++i >= nummapheaders) if (++cm >= nummapheaders)
i = 0; cm = 0;
continue; continue;
} }
break; break;
} }
nextmap = i; nextmap = cm;
} }
if (!marathonmode) if (!marathonmode)

View file

@ -432,7 +432,8 @@ UINT8 M_MapLocked(INT32 mapnum)
if (1) if (1)
return false; return false;
#endif #endif
if (!mapnum || mapnum > nummapheaders)
return false;
if (!mapheaderinfo[mapnum-1] || mapheaderinfo[mapnum-1]->unlockrequired < 0) if (!mapheaderinfo[mapnum-1] || mapheaderinfo[mapnum-1]->unlockrequired < 0)
return false; return false;
if (!unlockables[mapheaderinfo[mapnum-1]->unlockrequired].unlocked) if (!unlockables[mapheaderinfo[mapnum-1]->unlockrequired].unlocked)