From 87c31bbdf5dd27e92119166a179c846dd8c47232 Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sat, 10 Aug 2019 23:29:20 +0000 Subject: [PATCH] Fix bugs with unbound mouse and joystick controls not saving properly. git-svn-id: https://svn.eduke32.com/eduke32@7943 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/config.cpp | 31 +++++++++++++------------------ source/duke3d/src/config.h | 2 -- source/mact/src/control.cpp | 2 +- 3 files changed, 14 insertions(+), 21 deletions(-) diff --git a/source/duke3d/src/config.cpp b/source/duke3d/src/config.cpp index e6dab671e..1aaa4a750 100644 --- a/source/duke3d/src/config.cpp +++ b/source/duke3d/src/config.cpp @@ -53,10 +53,10 @@ int32_t CONFIG_FunctionNameToNum(const char *func) } -char *CONFIG_FunctionNumToName(int32_t func) +static char const * CONFIG_FunctionNumToName(int32_t func) { if ((unsigned)func >= (unsigned)NUMGAMEFUNCTIONS) - return NULL; + return ""; return gamefunctions[func]; } @@ -78,7 +78,7 @@ int32_t CONFIG_AnalogNameToNum(const char *func) } -const char *CONFIG_AnalogNumToName(int32_t func) +static char const * CONFIG_AnalogNumToName(int32_t func) { switch (func) { @@ -92,7 +92,7 @@ const char *CONFIG_AnalogNumToName(int32_t func) return "analog_lookingupanddown"; } - return NULL; + return ""; } @@ -441,20 +441,17 @@ void CONFIG_SetupMouse(void) Bsprintf(str,"MouseAnalogAxes%d",i); temp[0] = 0; if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp)) - if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1)) - ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp); + ud.config.MouseAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp); Bsprintf(str,"MouseDigitalAxes%d_0",i); temp[0] = 0; if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp)) - if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1)) - ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp); + ud.config.MouseDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp); Bsprintf(str,"MouseDigitalAxes%d_1",i); temp[0] = 0; if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp)) - if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1)) - ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp); + ud.config.MouseDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp); Bsprintf(str,"MouseAnalogScale%d",i); int32_t scale = ud.config.MouseAnalogueScale[i]; @@ -505,20 +502,17 @@ void CONFIG_SetupJoystick(void) Bsprintf(str,"JoystickAnalogAxes%d",i); temp[0] = 0; if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp)) - if (CONFIG_AnalogNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1)) - ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp); + ud.config.JoystickAnalogueAxes[i] = CONFIG_AnalogNameToNum(temp); Bsprintf(str,"JoystickDigitalAxes%d_0",i); temp[0] = 0; if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp)) - if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1)) - ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp); + ud.config.JoystickDigitalFunctions[i][0] = CONFIG_FunctionNameToNum(temp); Bsprintf(str,"JoystickDigitalAxes%d_1",i); temp[0] = 0; if (!SCRIPT_GetString(ud.config.scripthandle, "Controls", str,temp)) - if (CONFIG_FunctionNameToNum(temp) != -1 || (!temp[0] && CONFIG_FunctionNameToNum(temp) != -1)) - ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp); + ud.config.JoystickDigitalFunctions[i][1] = CONFIG_FunctionNameToNum(temp); Bsprintf(str,"JoystickAnalogScale%d",i); scale = ud.config.JoystickAnalogueScale[i]; @@ -703,10 +697,11 @@ void CONFIG_WriteSettings(void) // save binds and aliases to _settings. for (int i=0; i= (unsigned)analog_maxtype) + if ((unsigned)whichanalog >= (unsigned)analog_maxtype && whichanalog != -1) { //Error("CONTROL_MapAnalogAxis: analog function %d out of valid range for %d analog functions.", // whichanalog, analog_maxtype);