1
0
mirror of https://github.com/TerryCavanagh/VVVVVV.git synced 2024-06-26 06:28:30 +02:00

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.
This commit is contained in:
Misa 2021-02-07 21:13:40 -08:00 committed by Ethan Lee
parent adbae16666
commit 09841ef3a5

View File

@ -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
{