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
{
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)

View file

@ -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)