From b9f18ffc2406ba68498cf0859d0bc424578f715c Mon Sep 17 00:00:00 2001 From: toaster Date: Sun, 18 Dec 2022 13:57:39 +0000 Subject: [PATCH] More things use the menu map selection rules * G_GetFirstMapOfGametype now uses the menu functions instead of repeating the effort * GTR_NOCUPSELECT - allows gametypes to opt out of cup selection --- src/doomstat.h | 2 ++ src/g_game.c | 29 +++++++++++++---------------- src/k_menufunc.c | 2 +- 3 files changed, 16 insertions(+), 17 deletions(-) diff --git a/src/doomstat.h b/src/doomstat.h index 320e29c13..ade6a4bb2 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -502,6 +502,8 @@ enum GameTypeRules GTR_LIVES = 1<<18, // Lives system, players are forced to spectate during Game Over. GTR_SPECIALBOTS = 1<<19, // Bot difficulty gets stronger between rounds, and the rival system is enabled. + GTR_NOCUPSELECT = 1<<20, // Your maps are not selected via cup. ...mutually exclusive with GTR_CAMPAIGN. + // free: to and including 1<<31 }; diff --git a/src/g_game.c b/src/g_game.c index 1bcbd5555..3371979d0 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3416,29 +3416,26 @@ UINT32 G_TOLFlag(INT32 pgametype) INT16 G_GetFirstMapOfGametype(UINT8 pgametype) { + UINT8 i = 0; INT16 mapnum = NEXTMAP_INVALID; + UINT32 tol = G_TOLFlag(pgametype); - if ((gametypedefaultrules[pgametype] & GTR_CAMPAIGN) && kartcupheaders) - { - mapnum = kartcupheaders->cachedlevels[0]; - } + levellist.cupmode = (!(gametypedefaultrules[pgametype] & GTR_NOCUPSELECT)); + levellist.timeattack = false; - if (mapnum >= nummapheaders) + if (levellist.cupmode) { - UINT32 tolflag = G_TOLFlag(pgametype); - for (mapnum = 0; mapnum < nummapheaders; mapnum++) + cupheader_t *cup = kartcupheaders; + while (cup && mapnum >= nummapheaders) { - if (!mapheaderinfo[mapnum]) - continue; - if (mapheaderinfo[mapnum]->lumpnum == LUMPERROR) - continue; - if (!(mapheaderinfo[mapnum]->typeoflevel & tolflag)) - continue; - if (mapheaderinfo[mapnum]->menuflags & LF2_HIDEINMENU) - continue; - break; + mapnum = M_GetFirstLevelInList(&i, tol, cup); + i = 0; } } + else + { + mapnum = M_GetFirstLevelInList(&i, tol, NULL); + } return mapnum; } diff --git a/src/k_menufunc.c b/src/k_menufunc.c index 06176cf26..18716b9b9 100644 --- a/src/k_menufunc.c +++ b/src/k_menufunc.c @@ -3475,7 +3475,7 @@ static void M_LevelListFromGametype(INT16 gt) { levellist.newgametype = gt; levellist.typeoflevel = G_TOLFlag(gt); - levellist.cupmode = true; // todo some way to choose going direct to a long consecutive list..? + levellist.cupmode = (!(gametypedefaultrules[gt] & GTR_NOCUPSELECT)); levellist.selectedcup = NULL; first = false; }