From cfcd25f2cd1adcfe1d7bbb17451505f61b207c3c Mon Sep 17 00:00:00 2001 From: toasterbabe Date: Tue, 19 Jul 2016 01:03:40 +0100 Subject: [PATCH] Fixing a bug which could be caused by tapping up/down on the character select at high speeds by ensuring that o is never negative instead of assuming the one circumstance it may have been negative under. --- src/m_menu.c | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index 58f431afb..10f990275 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -4856,22 +4856,27 @@ static void M_DrawSetupChoosePlayerMenu(void) char_scroll = itemOn*128*FRACUNIT; // just be exact now. o = ((char_scroll / FRACUNIT) + 16); - if (lastdirection) - o += 128; // This one-directional hack is to prevent visual glitches when going from the (currentMenu->numitems)nd character to the 1st character. - i = (o / 128); - o = (o % 128); - // subtract 1 from i to counteract the +128 from the prior hack, if we made it happen - if (lastdirection) + if (o < 0) // This hack is to prevent visual glitches when looping from the last character to the 1st character. { + o += 128; + + i = (o / 128); + o = (o % 128); + j = i; - do + do // subtract 1 from i to counteract the +128 from the prior hack { i--; if (i < 0) i = (currentMenu->numitems - 1); } while (i != j && PlayerMenu[i].status & IT_DISABLED); } + else // Regular circumstances + { + i = (o / 128); + o = (o % 128); + } // Get prev character... prev = i;