Clean up cup-related conditions for M_CanShowLevelInList

This commit is contained in:
toaster 2022-12-18 13:20:50 +00:00
parent d703a02e6c
commit ed85fb2e79
2 changed files with 10 additions and 19 deletions

View file

@ -701,7 +701,7 @@ extern struct levellist_s {
boolean netgame; // Start the game in an actual server boolean netgame; // Start the game in an actual server
} levellist; } levellist;
boolean M_CanShowLevelInList(INT16 mapnum, UINT32 tol); boolean M_CanShowLevelInList(INT16 mapnum, UINT32 tol, cupheader_t *cup);
INT16 M_CountLevelsToShowInList(UINT32 tol, cupheader_t *cup); INT16 M_CountLevelsToShowInList(UINT32 tol, cupheader_t *cup);
INT16 M_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup); INT16 M_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup);
INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup); INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup);

View file

@ -3337,9 +3337,8 @@ void M_SetupDifficultySelect(INT32 choice)
// M_CanShowLevelInList // M_CanShowLevelInList
// //
// Determines whether to show a given map in the various level-select lists. // Determines whether to show a given map in the various level-select lists.
// Set gt = -1 to ignore gametype.
// //
boolean M_CanShowLevelInList(INT16 mapnum, UINT32 tol) boolean M_CanShowLevelInList(INT16 mapnum, UINT32 tol, cupheader_t *cup)
{ {
if (mapnum >= nummapheaders) if (mapnum >= nummapheaders)
return false; return false;
@ -3371,17 +3370,9 @@ boolean M_CanShowLevelInList(INT16 mapnum, UINT32 tol)
if (levellist.timeattack && (mapheaderinfo[mapnum]->menuflags & LF2_NOTIMEATTACK)) if (levellist.timeattack && (mapheaderinfo[mapnum]->menuflags & LF2_NOTIMEATTACK))
return false; return false;
#if 0 // Don't permit cup when no cup requested
if (gametypedefaultrules[gt] & GTR_CAMPAIGN && levellist.selectedcup) if (levellist.cupmode && !cup && mapheaderinfo[mapnum]->cup)
{
if (mapheaderinfo[mapnum]->cup != levellist.selectedcup)
return false;
}
#else
// Don't permit cups if not cupmode
if (!levellist.cupmode && (mapheaderinfo[mapnum]->cup != NULL))
return false; return false;
#endif
// Survived our checks. // Survived our checks.
return true; return true;
@ -3395,7 +3386,7 @@ INT16 M_CountLevelsToShowInList(UINT32 tol, cupheader_t *cup)
{ {
for (i = 0; i < CUPCACHE_MAX; i++) for (i = 0; i < CUPCACHE_MAX; i++)
{ {
if (!M_CanShowLevelInList(cup->cachedlevels[i], tol)) if (!M_CanShowLevelInList(cup->cachedlevels[i], tol, cup))
continue; continue;
count++; count++;
} }
@ -3404,7 +3395,7 @@ INT16 M_CountLevelsToShowInList(UINT32 tol, cupheader_t *cup)
} }
for (i = 0; i < nummapheaders; i++) for (i = 0; i < nummapheaders; i++)
if (M_CanShowLevelInList(i, tol)) if (M_CanShowLevelInList(i, tol, NULL))
count++; count++;
return count; return count;
@ -3420,7 +3411,7 @@ INT16 M_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup)
mapnum = NEXTMAP_INVALID; mapnum = NEXTMAP_INVALID;
for (; *i < CUPCACHE_MAX; (*i)++) for (; *i < CUPCACHE_MAX; (*i)++)
{ {
if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol)) if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol, cup))
continue; continue;
mapnum = cup->cachedlevels[*i]; mapnum = cup->cachedlevels[*i];
break; break;
@ -3429,7 +3420,7 @@ INT16 M_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup)
else else
{ {
for (mapnum = 0; mapnum < nummapheaders; mapnum++) for (mapnum = 0; mapnum < nummapheaders; mapnum++)
if (M_CanShowLevelInList(mapnum, tol)) if (M_CanShowLevelInList(mapnum, tol, NULL))
break; break;
} }
@ -3444,7 +3435,7 @@ INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup)
(*i)++; (*i)++;
for (; *i < CUPCACHE_MAX; (*i)++) for (; *i < CUPCACHE_MAX; (*i)++)
{ {
if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol)) if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol, cup))
continue; continue;
map = cup->cachedlevels[*i]; map = cup->cachedlevels[*i];
break; break;
@ -3453,7 +3444,7 @@ INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup)
else else
{ {
map++; map++;
while (!M_CanShowLevelInList(map, tol) && map < nummapheaders) while (!M_CanShowLevelInList(map, tol, NULL) && map < nummapheaders)
map++; map++;
} }