diff --git a/src/k_menu.h b/src/k_menu.h index 84fcba3f6..6ee320f92 100644 --- a/src/k_menu.h +++ b/src/k_menu.h @@ -737,6 +737,7 @@ extern struct levellist_s { UINT16 y; UINT16 dest; UINT16 choosemap; + UINT16 mapcount; UINT8 newgametype; UINT8 guessgt; levelsearch_t levelsearch; diff --git a/src/menus/transient/cup-select.c b/src/menus/transient/cup-select.c index b4ef37493..cca546f9e 100644 --- a/src/menus/transient/cup-select.c +++ b/src/menus/transient/cup-select.c @@ -161,7 +161,7 @@ void M_CupSelectHandler(INT32 choice) restoreMenu = &PLAY_CupSelectDef; } - else if (count == 1) + else if (count == 1 && levellist.levelsearch.timeattack == true) { PLAY_TimeAttackDef.transitionID = currentMenu->transitionID+1; M_LevelSelected(0); @@ -174,6 +174,7 @@ void M_CupSelectHandler(INT32 choice) levellist.cursor = 0; } + levellist.mapcount = count; M_LevelSelectScrollDest(); levellist.y = levellist.dest; diff --git a/src/menus/transient/level-select.c b/src/menus/transient/level-select.c index f0e012855..11a62e944 100644 --- a/src/menus/transient/level-select.c +++ b/src/menus/transient/level-select.c @@ -195,14 +195,14 @@ UINT16 M_GetNextLevelInList(UINT16 mapnum, UINT8 *i, levelsearch_t *levelsearch) void M_LevelSelectScrollDest(void) { - UINT16 m = M_CountLevelsToShowInList(&levellist.levelsearch)-1; + UINT16 m = levellist.mapcount-1; levellist.dest = (6*levellist.cursor); if (levellist.dest < 3) levellist.dest = 3; - if (levellist.dest > (6*m)-3) + if (m && levellist.dest > (6*m)-3) levellist.dest = (6*m)-3; } @@ -400,6 +400,7 @@ boolean M_LevelListFromGametype(INT16 gt) levellist.levelsearch.cup = NULL; } + levellist.mapcount = M_CountLevelsToShowInList(&levellist.levelsearch); M_LevelSelectScrollDest(); levellist.y = levellist.dest; @@ -562,7 +563,6 @@ void M_LevelSelected(INT16 add) void M_LevelSelectHandler(INT32 choice) { - INT16 maxlevels = M_CountLevelsToShowInList(&levellist.levelsearch); const UINT8 pid = 0; (void)choice; @@ -575,7 +575,7 @@ void M_LevelSelectHandler(INT32 choice) if (menucmd[pid].dpad_ud > 0) { levellist.cursor++; - if (levellist.cursor >= maxlevels) + if (levellist.cursor >= levellist.mapcount) levellist.cursor = 0; S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); @@ -584,7 +584,7 @@ void M_LevelSelectHandler(INT32 choice) { levellist.cursor--; if (levellist.cursor < 0) - levellist.cursor = maxlevels-1; + levellist.cursor = levellist.mapcount-1; S_StartSound(NULL, sfx_s3k5b); M_SetMenuDelay(pid); }