From ed85fb2e79130df00e0cac10c1a3bc16aa2fa922 Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 18 Dec 2022 13:20:50 +0000 Subject: [PATCH] Clean up cup-related conditions for M_CanShowLevelInList --- src/k_menu.h | 2 +- src/k_menufunc.c | 27 +++++++++------------------ 2 files changed, 10 insertions(+), 19 deletions(-) diff --git a/src/k_menu.h b/src/k_menu.h index 99120b97d..ad76890ff 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -701,7 +701,7 @@ extern struct levellist_s { boolean netgame; // Start the game in an actual server } 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_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup); INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup); diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 0ee5c95a3..06176cf26 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -3337,9 +3337,8 @@ void M_SetupDifficultySelect(INT32 choice) // M_CanShowLevelInList // // 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) return false; @@ -3371,17 +3370,9 @@ boolean M_CanShowLevelInList(INT16 mapnum, UINT32 tol) if (levellist.timeattack && (mapheaderinfo[mapnum]->menuflags & LF2_NOTIMEATTACK)) return false; -#if 0 - if (gametypedefaultrules[gt] & GTR_CAMPAIGN && levellist.selectedcup) - { - if (mapheaderinfo[mapnum]->cup != levellist.selectedcup) - return false; - } -#else - // Don't permit cups if not cupmode - if (!levellist.cupmode && (mapheaderinfo[mapnum]->cup != NULL)) + // Don't permit cup when no cup requested + if (levellist.cupmode && !cup && mapheaderinfo[mapnum]->cup) return false; -#endif // Survived our checks. return true; @@ -3395,7 +3386,7 @@ INT16 M_CountLevelsToShowInList(UINT32 tol, cupheader_t *cup) { for (i = 0; i < CUPCACHE_MAX; i++) { - if (!M_CanShowLevelInList(cup->cachedlevels[i], tol)) + if (!M_CanShowLevelInList(cup->cachedlevels[i], tol, cup)) continue; count++; } @@ -3404,7 +3395,7 @@ INT16 M_CountLevelsToShowInList(UINT32 tol, cupheader_t *cup) } for (i = 0; i < nummapheaders; i++) - if (M_CanShowLevelInList(i, tol)) + if (M_CanShowLevelInList(i, tol, NULL)) count++; return count; @@ -3420,7 +3411,7 @@ INT16 M_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup) mapnum = NEXTMAP_INVALID; for (; *i < CUPCACHE_MAX; (*i)++) { - if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol)) + if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol, cup)) continue; mapnum = cup->cachedlevels[*i]; break; @@ -3429,7 +3420,7 @@ INT16 M_GetFirstLevelInList(UINT8 *i, UINT32 tol, cupheader_t *cup) else { for (mapnum = 0; mapnum < nummapheaders; mapnum++) - if (M_CanShowLevelInList(mapnum, tol)) + if (M_CanShowLevelInList(mapnum, tol, NULL)) break; } @@ -3444,7 +3435,7 @@ INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup) (*i)++; for (; *i < CUPCACHE_MAX; (*i)++) { - if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol)) + if (!M_CanShowLevelInList(cup->cachedlevels[*i], tol, cup)) continue; map = cup->cachedlevels[*i]; break; @@ -3453,7 +3444,7 @@ INT16 M_GetNextLevelInList(INT16 map, UINT8 *i, UINT32 tol, cupheader_t *cup) else { map++; - while (!M_CanShowLevelInList(map, tol) && map < nummapheaders) + while (!M_CanShowLevelInList(map, tol, NULL) && map < nummapheaders) map++; }