From fa63ddda86fac929a4e6dea92eb0c627e8d6f090 Mon Sep 17 00:00:00 2001 From: mazmazz Date: Fri, 14 Dec 2018 06:05:31 -0500 Subject: [PATCH] Fix cv_usejoystick being reset to None when cv_usejoystick was > NumJoys and changing to already-used joystick --- src/m_menu.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/m_menu.c b/src/m_menu.c index a0712381..9b5e1098 100644 --- a/src/m_menu.c +++ b/src/m_menu.c @@ -6835,12 +6835,12 @@ static void M_Setup2PJoystickMenu(INT32 choice) static void M_AssignJoystick(INT32 choice) { #ifdef JOYSTICK_HOTPLUG - INT32 oldchoice; + INT32 oldchoice, oldstringchoice; INT32 numjoys = I_NumJoys(); if (setupcontrols_secondaryplayer) { - oldchoice = atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value; + oldchoice = oldstringchoice = atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value; CV_SetValue(&cv_usejoystick2, choice); // Just in case last-minute changes were made to cv_usejoystick.value, @@ -6856,10 +6856,10 @@ static void M_AssignJoystick(INT32 choice) if (oldchoice != choice) { - if (choice && oldchoice > numjoys) // if we did not select "None", we likely selected a used device - CV_SetValue(&cv_usejoystick2, oldchoice); + if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device + CV_SetValue(&cv_usejoystick2, (oldstringchoice > numjoys ? oldstringchoice : oldchoice)); - if (oldchoice == + if (oldstringchoice == (atoi(cv_usejoystick2.string) > numjoys ? atoi(cv_usejoystick2.string) : cv_usejoystick2.value)) M_StartMessage("This joystick is used by another\n" "player. Reset the joystick\n" @@ -6870,7 +6870,7 @@ static void M_AssignJoystick(INT32 choice) } else { - oldchoice = atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value; + oldchoice = oldstringchoice = atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value; CV_SetValue(&cv_usejoystick, choice); // Just in case last-minute changes were made to cv_usejoystick.value, @@ -6886,10 +6886,10 @@ static void M_AssignJoystick(INT32 choice) if (oldchoice != choice) { - if (choice && oldchoice > numjoys) // if we did not select "None", we likely selected a used device - CV_SetValue(&cv_usejoystick, oldchoice); + if (choice && oldstringchoice > numjoys) // if we did not select "None", we likely selected a used device + CV_SetValue(&cv_usejoystick, (oldstringchoice > numjoys ? oldstringchoice : oldchoice)); - if (oldchoice == + if (oldstringchoice == (atoi(cv_usejoystick.string) > numjoys ? atoi(cv_usejoystick.string) : cv_usejoystick.value)) M_StartMessage("This joystick is used by another\n" "player. Reset the joystick\n"