From 1ef427631e989ad4e611d20fcb043c2bf3d58e78 Mon Sep 17 00:00:00 2001 From: toaster Date: Sat, 18 Nov 2023 11:44:59 +0000 Subject: [PATCH] Review: Fix incorrect levelsearch apparatus - M_LevelListFromGametype: Correctly wipe tutorial status when changing from tutorial to gametype with cups - G_GetFirstMapOfGametype: Fix tutorial handling, gametype's datatype - M_InitExtras: to prevent duplicated code, use G_GetFirstMapOfGametype --- src/g_game.c | 4 ++-- src/g_game.h | 2 +- src/menus/extras-1.c | 13 +------------ src/menus/play-online-host.c | 1 - src/menus/transient/level-select.c | 20 ++++++++++---------- 5 files changed, 14 insertions(+), 26 deletions(-) diff --git a/src/g_game.c b/src/g_game.c index ca10a8791..467774a84 100644 --- a/src/g_game.c +++ b/src/g_game.c @@ -3358,7 +3358,7 @@ UINT32 G_TOLFlag(INT32 pgametype) return 0; } -UINT16 G_GetFirstMapOfGametype(UINT8 pgametype) +UINT16 G_GetFirstMapOfGametype(UINT16 pgametype) { UINT8 i = 0; UINT16 mapnum = NEXTMAP_INVALID; @@ -3368,7 +3368,7 @@ UINT16 G_GetFirstMapOfGametype(UINT8 pgametype) templevelsearch.typeoflevel = G_TOLFlag(pgametype); templevelsearch.cupmode = (!(gametypes[pgametype]->rules & GTR_NOCUPSELECT)); templevelsearch.timeattack = false; - templevelsearch.tutorial = false; + templevelsearch.tutorial = (pgametype == GT_TUTORIAL); templevelsearch.checklocked = true; if (templevelsearch.cupmode) diff --git a/src/g_game.h b/src/g_game.h index 1bcf1f024..6d050c75d 100644 --- a/src/g_game.h +++ b/src/g_game.h @@ -280,7 +280,7 @@ FUNCMATH INT32 G_TicsToMilliseconds(tic_t tics); // Don't split up TOL handling UINT32 G_TOLFlag(INT32 pgametype); -UINT16 G_GetFirstMapOfGametype(UINT8 pgametype); +UINT16 G_GetFirstMapOfGametype(UINT16 pgametype); UINT16 G_RandMap(UINT32 tolflags, UINT16 pprevmap, boolean ignoreBuffers, boolean callAgainSoon, UINT16 *extBuffer); void G_AddMapToBuffer(UINT16 map); diff --git a/src/menus/extras-1.c b/src/menus/extras-1.c index 24bf60c0f..cb371aec0 100644 --- a/src/menus/extras-1.c +++ b/src/menus/extras-1.c @@ -90,18 +90,7 @@ void M_InitExtras(INT32 choice) // Tutorial { - levelsearch_t templevelsearch; - UINT8 i = 0; - INT16 map; - - templevelsearch.cup = NULL; - templevelsearch.typeoflevel = G_TOLFlag(GT_TUTORIAL); - templevelsearch.cupmode = false; - templevelsearch.timeattack = false; - templevelsearch.tutorial = true; - templevelsearch.checklocked = true; - - map = M_GetFirstLevelInList(&i, &templevelsearch); + UINT16 map = G_GetFirstMapOfGametype(GT_TUTORIAL); EXTRAS_Main[extras_tutorial].status = (IT_STRING | ((map == NEXTMAP_INVALID) ? IT_TRANSTEXT : IT_CALL)); diff --git a/src/menus/play-online-host.c b/src/menus/play-online-host.c index 0b34f36b1..31c1f449a 100644 --- a/src/menus/play-online-host.c +++ b/src/menus/play-online-host.c @@ -110,7 +110,6 @@ void M_MPSetupNetgameMapSelect(INT32 choice) levellist.netgame = true; // Make sure we reset those levellist.levelsearch.timeattack = false; - levellist.levelsearch.tutorial = false; levellist.levelsearch.checklocked = true; cupgrid.grandprix = false; diff --git a/src/menus/transient/level-select.c b/src/menus/transient/level-select.c index bfaa7fa4a..8929e25b8 100644 --- a/src/menus/transient/level-select.c +++ b/src/menus/transient/level-select.c @@ -238,6 +238,7 @@ boolean M_LevelListFromGametype(INT16 gt) { static boolean first = true; UINT8 temp = 0; + boolean invalidatedcursor = false; if (gt != -1) { @@ -267,6 +268,15 @@ boolean M_LevelListFromGametype(INT16 gt) } levellist.levelsearch.cupmode = (!(gametypes[gt]->rules & GTR_NOCUPSELECT)); + if (!levellist.levelsearch.cupmode) + { + invalidatedcursor = ( + levellist.levelsearch.cup != NULL + || levellist.levelsearch.tutorial != (gt == GT_TUTORIAL) + ); + } + + levellist.levelsearch.tutorial = (gt == GT_TUTORIAL); CV_SetValue(&cv_dummyspbattack, 0); } @@ -435,16 +445,6 @@ boolean M_LevelListFromGametype(INT16 gt) // Okay, just a list of maps then. - boolean invalidatedcursor = false; - - if (gt != -1) - { - invalidatedcursor = ( - levellist.levelsearch.cup != NULL - || levellist.levelsearch.tutorial != (gt == GT_TUTORIAL) - ); - levellist.levelsearch.tutorial = (gt == GT_TUTORIAL); - } levellist.levelsearch.cup = NULL; UINT16 test = M_GetFirstLevelInList(&temp, &levellist.levelsearch);