1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-24 23:34:37 +01:00

Fix #20365: Money cheat supports negative value entry (#20478)

This commit is contained in:
mrmbernardi
2023-06-29 22:47:51 +02:00
committed by GitHub
parent 756d3deb29
commit b02fad3404
2 changed files with 4 additions and 7 deletions

View File

@@ -414,14 +414,10 @@ money64 StringToMoney(const char* string_to_monetise)
if (numNumbers == 0)
return MONEY64_UNDEFINED;
int64_t sign = 1;
if (hasMinus)
if (hasMinus && processedString[0] != '-')
{
// If there is a minus sign, it has to be at position 0 in order to be valid.
if (processedString[0] == '-')
sign = -1;
else
return MONEY64_UNDEFINED;
return MONEY64_UNDEFINED;
}
// Due to the nature of strstr and strtok, decimals at the very beginning will be ignored, causing
@@ -436,7 +432,7 @@ money64 StringToMoney(const char* string_to_monetise)
auto number = std::stod(processedString, nullptr);
number /= (currencyDesc->rate / 10.0);
return ToMoney64FromGBP(number) * sign;
return ToMoney64FromGBP(number);
}
/**