From f6842a80b462ff9ec0c7a58fd598dc94a0d3f2e1 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Jul 2019 21:58:48 +0100 Subject: [PATCH 1/5] Fixes for menus: * add gamestate != GS_TIMEATTACK checks to prevent Record Attack or NiGHTS Mode losing their backgrounds * increase bgname to 9 to include the extra NULL byte? (is this a good idea actually) * make M_IterateMenuTree ignore menu levels without a menutype value --- src/f_finale.c | 2 +- src/f_finale.h | 2 +- src/m_menu.c | 8 +++++--- src/m_menu.h | 2 +- 4 files changed, 8 insertions(+), 6 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 27c9ebd68..134bc9fcc 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -67,7 +67,7 @@ static INT32 menuanimtimer; // Title screen: background animation timing mobj_t *titlemapcameraref = NULL; // menu presentation state -char curbgname[8]; +char curbgname[9]; SINT8 curfadevalue; boolean curhidepics; INT32 curbgcolor; diff --git a/src/f_finale.h b/src/f_finale.h index c0c6360c3..663a45412 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -84,7 +84,7 @@ typedef enum extern UINT8 titlemapinaction; extern mobj_t *titlemapcameraref; -extern char curbgname[8]; +extern char curbgname[9]; extern SINT8 curfadevalue; extern boolean curhidepics; extern INT32 curbgcolor; diff --git a/src/m_menu.c b/src/m_menu.c index dca2e552d..53e0182fd 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2247,6 +2247,8 @@ static INT32 M_IterateMenuTree(menutree_iterator itfunc, void *input) { bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); menutype = (activeMenuId & bitmask) >> (MENUBITS*i); + if (!menutype) + continue; if (itfunc(menutype, i, &retval, &input, false)) break; } @@ -2300,7 +2302,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, curbgyspeed = menupres[menutype].titlescrollyspeed != INT32_MAX ? menupres[menutype].titlescrollyspeed : titlescrollyspeed; return true; } - else if (menupres[menutype].bghide && titlemapinaction) // hide the background + else if (gamestate != GS_TIMEATTACK && menupres[menutype].bghide && titlemapinaction) // hide the background { curbghide = true; return true; @@ -2309,7 +2311,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, { if (M_GetYoungestChildMenu() == MN_SP_PLAYER || !defaultname || !defaultname[0]) curbgcolor = 31; - else if (titlemapinaction) // hide the background by default in titlemap + else if (gamestate != GS_TIMEATTACK && titlemapinaction) // hide the background by default in titlemap curbghide = true; else { @@ -2469,7 +2471,7 @@ static void M_HandleMenuPresState(menu_t *newMenu) curbgcolor = -1; curbgxspeed = titlescrollxspeed; curbgyspeed = titlescrollyspeed; - curbghide = true; + curbghide = (gamestate != GS_TIMEATTACK); // show in time attack, hide in other menus // don't do the below during the in-game menus if (gamestate != GS_TITLESCREEN && gamestate != GS_TIMEATTACK) diff --git a/src/m_menu.h b/src/m_menu.h index 04146ebdc..06631dc39 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -123,7 +123,7 @@ typedef enum typedef struct { - char bgname[8]; // name for background gfx lump; lays over titlemap if this is set + char bgname[9]; // name for background gfx lump; lays over titlemap if this is set SINT8 hidetitlepics; // hide title gfx per menu; -1 means undefined, inherits global setting INT32 titlescrollxspeed; // background gfx scroll per menu; inherits global setting INT32 titlescrollyspeed; // y scroll From a1e6f5bdb3406e578c5082908a03b15b592e5450 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Jul 2019 22:28:19 +0100 Subject: [PATCH 2/5] remove some of the GS_TIMEATTACK hacks I added because I now realise I can just turn titlemapinaction off when entering the menus \o/ --- src/m_menu.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 53e0182fd..932df65fe 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2302,7 +2302,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, curbgyspeed = menupres[menutype].titlescrollyspeed != INT32_MAX ? menupres[menutype].titlescrollyspeed : titlescrollyspeed; return true; } - else if (gamestate != GS_TIMEATTACK && menupres[menutype].bghide && titlemapinaction) // hide the background + else if (menupres[menutype].bghide && titlemapinaction) // hide the background { curbghide = true; return true; @@ -2311,7 +2311,7 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, { if (M_GetYoungestChildMenu() == MN_SP_PLAYER || !defaultname || !defaultname[0]) curbgcolor = 31; - else if (gamestate != GS_TIMEATTACK && titlemapinaction) // hide the background by default in titlemap + else if (titlemapinaction) // hide the background by default in titlemap curbghide = true; else { @@ -8236,6 +8236,7 @@ static void M_TimeAttack(INT32 choice) M_PatchSkinNameTable(); G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please M_SetupNextMenu(&SP_TimeAttackDef); if (!M_CanShowLevelInList(cv_nextmap.value-1, -1) && levelselect.rows[0].maplist[0]) CV_SetValue(&cv_nextmap, levelselect.rows[0].maplist[0]); @@ -8417,6 +8418,7 @@ static void M_NightsAttack(INT32 choice) G_SetGamestate(GS_TIMEATTACK); // do this before M_SetupNextMenu so that menu meta state knows that we're switching M_SetupNextMenu(&SP_NightsAttackDef); + titlemapinaction = TITLEMAP_OFF; // Nope don't give us HOMs please if (!M_CanShowLevelInList(cv_nextmap.value-1, -1) && levelselect.rows[0].maplist[0]) CV_SetValue(&cv_nextmap, levelselect.rows[0].maplist[0]); else From d44a8ab78ef5869575f545184f5147b39117cd20 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sun, 14 Jul 2019 22:36:14 +0100 Subject: [PATCH 3/5] Slightly unrelated tweak: bghide && titlemapinaction clearly takes precedence over bgname if both are present, so reorder these if statement blocks --- src/m_menu.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 932df65fe..adf2e0cdb 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2295,18 +2295,18 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, curbgcolor = menupres[menutype].bgcolor; return true; } - else if (menupres[menutype].bgname[0] && (!menupres[menutype].bghide || !titlemapinaction)) + else if (menupres[menutype].bghide && titlemapinaction) // hide the background + { + curbghide = true; + return true; + } + else if (menupres[menutype].bgname[0]) { strncpy(curbgname, menupres[menutype].bgname, 8); curbgxspeed = menupres[menutype].titlescrollxspeed != INT32_MAX ? menupres[menutype].titlescrollxspeed : titlescrollxspeed; curbgyspeed = menupres[menutype].titlescrollyspeed != INT32_MAX ? menupres[menutype].titlescrollyspeed : titlescrollyspeed; return true; } - else if (menupres[menutype].bghide && titlemapinaction) // hide the background - { - curbghide = true; - return true; - } else if (!level) { if (M_GetYoungestChildMenu() == MN_SP_PLAYER || !defaultname || !defaultname[0]) From 5ef4dda9b933e4a117582c78b259300f52a5ab27 Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Mon, 15 Jul 2019 20:25:57 +0100 Subject: [PATCH 4/5] Instead of ignoring blank menutypes in M_IterateMenuTree, ignore them in the MIT_ functions instead. (I'm doing this because MIT_GetMenuAtLevel appears to actually care about whether menutype is zero or not unlike the others; I don't want to break the code designed around that) --- src/m_menu.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index adf2e0cdb..d9d3a6ba0 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -2247,8 +2247,6 @@ static INT32 M_IterateMenuTree(menutree_iterator itfunc, void *input) { bitmask = ((1 << MENUBITS) - 1) << (MENUBITS*i); menutype = (activeMenuId & bitmask) >> (MENUBITS*i); - if (!menutype) - continue; if (itfunc(menutype, i, &retval, &input, false)) break; } @@ -2290,6 +2288,9 @@ static boolean MIT_SetCurBackground(UINT32 menutype, INT32 level, INT32 *retval, (void)retval; (void)fromoldest; + if (!menutype) // if there's nothing in this level, do nothing + return false; + if (menupres[menutype].bgcolor >= 0) { curbgcolor = menupres[menutype].bgcolor; @@ -2330,6 +2331,9 @@ static boolean MIT_ChangeMusic(UINT32 menutype, INT32 level, INT32 *retval, void (void)retval; (void)fromoldest; + if (!menutype) // if there's nothing in this level, do nothing + return false; + if (menupres[menutype].musname[0]) { S_ChangeMusic(menupres[menutype].musname, menupres[menutype].mustrack, menupres[menutype].muslooping); @@ -2354,6 +2358,9 @@ static boolean MIT_SetCurFadeValue(UINT32 menutype, INT32 level, INT32 *retval, (void)retval; (void)fromoldest; + if (!menutype) // if there's nothing in this level, do nothing + return false; + if (menupres[menutype].fadestrength >= 0) { curfadevalue = (menupres[menutype].fadestrength % 32); @@ -2370,6 +2377,9 @@ static boolean MIT_SetCurHideTitlePics(UINT32 menutype, INT32 level, INT32 *retv (void)retval; (void)fromoldest; + if (!menutype) // if there's nothing in this level, do nothing + return false; + if (menupres[menutype].hidetitlepics >= 0) { curhidepics = menupres[menutype].hidetitlepics; From 0f8c046c6f1a0d408d13173905fc2c40506e558c Mon Sep 17 00:00:00 2001 From: Monster Iestyn Date: Sat, 20 Jul 2019 16:30:30 +0100 Subject: [PATCH 5/5] On second thoughts I'll go back to 8 for length in these variables, since as far as I can tell the code doesn't need it to be longer anyway --- src/f_finale.c | 2 +- src/f_finale.h | 2 +- src/m_menu.h | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/f_finale.c b/src/f_finale.c index 134bc9fcc..27c9ebd68 100644 --- a/src/f_finale.c +++ b/src/f_finale.c @@ -67,7 +67,7 @@ static INT32 menuanimtimer; // Title screen: background animation timing mobj_t *titlemapcameraref = NULL; // menu presentation state -char curbgname[9]; +char curbgname[8]; SINT8 curfadevalue; boolean curhidepics; INT32 curbgcolor; diff --git a/src/f_finale.h b/src/f_finale.h index 663a45412..c0c6360c3 100644 --- a/src/f_finale.h +++ b/src/f_finale.h @@ -84,7 +84,7 @@ typedef enum extern UINT8 titlemapinaction; extern mobj_t *titlemapcameraref; -extern char curbgname[9]; +extern char curbgname[8]; extern SINT8 curfadevalue; extern boolean curhidepics; extern INT32 curbgcolor; diff --git a/src/m_menu.h b/src/m_menu.h index 06631dc39..04146ebdc 100644 --- a/src/m_menu.h +++ b/src/m_menu.h @@ -123,7 +123,7 @@ typedef enum typedef struct { - char bgname[9]; // name for background gfx lump; lays over titlemap if this is set + char bgname[8]; // name for background gfx lump; lays over titlemap if this is set SINT8 hidetitlepics; // hide title gfx per menu; -1 means undefined, inherits global setting INT32 titlescrollxspeed; // background gfx scroll per menu; inherits global setting INT32 titlescrollyspeed; // y scroll