From 09841ef3a58111494981f581fce2756336dca7ef Mon Sep 17 00:00:00 2001 From: Misa Date: Sun, 7 Feb 2021 21:13:40 -0800 Subject: [PATCH] Don't mutate the decimal place in ss_toi() This fixes a bug where "12" gets properly evaluated as 12, but "148" gets evaluated as 1408. It's because `place` gets multiplied by `radix` again, so `retval` gets multipled by 100 instead of 10. There's no reason to have a `place` variable, so I've removed it entirely. This simplifies the function a little bit. --- desktop_version/src/UtilityClass.cpp | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/desktop_version/src/UtilityClass.cpp b/desktop_version/src/UtilityClass.cpp index 12c0d1f4..9ac02251 100644 --- a/desktop_version/src/UtilityClass.cpp +++ b/desktop_version/src/UtilityClass.cpp @@ -39,7 +39,6 @@ static const char* GCChar(const SDL_GameControllerButton button) int ss_toi(const std::string& str) { int retval = 0; - int place = 1; bool negative = false; const int radix = 10; @@ -55,9 +54,8 @@ int ss_toi(const std::string& str) if (SDL_isdigit(chr)) { - retval *= place; + retval *= radix; retval += chr - '0'; - place *= radix; } else {