1
0
mirror of https://github.com/OpenRCT2/OpenRCT2 synced 2026-01-22 22:34:33 +01:00

Fix #20364: Adding too much money with cheats causes an overflow

This commit is contained in:
mrmbernardi
2023-06-27 15:29:48 +02:00
committed by GitHub
parent d40102aa9d
commit cf7c486c5f
7 changed files with 12 additions and 10 deletions

View File

@@ -221,6 +221,7 @@ The following people are not part of the development team, but have been contrib
* John Mulcahy (jayjay300)
* Chase Percy (Chase-Percy)
* Wenzhao Qiu (qwzhaox)
* Michael Bernardi (mrmbernardi)
## Toolchain
* (Balletie) - macOS

View File

@@ -18,6 +18,7 @@
- Fix: [#20413] Crash when attempting to navigate an empty console history.
- Fix: [#20417] Plugin/custom windows are missing the left border in the title bar.
- Fix: [#20429] Error window tooltip not closing after 8 seconds.
- Fix: [#20364] Adding too much money with cheats causes an overflow.
0.4.5 (2023-05-08)
------------------------------------------------------------------------

View File

@@ -85,7 +85,7 @@ void CheatsReset()
gCheatsMakeAllDestructible = false;
}
void CheatsSet(CheatType cheatType, int32_t param1 /* = 0*/, int32_t param2 /* = 0*/)
void CheatsSet(CheatType cheatType, int64_t param1 /* = 0*/, int64_t param2 /* = 0*/)
{
auto cheatSetAction = CheatSetAction(cheatType, param1, param2);
GameActions::Execute(&cheatSetAction);

View File

@@ -123,5 +123,5 @@ constexpr auto CHEATS_GIVE_GUESTS_MONEY = 1000.00_GBP;
void CheatsReset();
const char* CheatsGetName(CheatType cheatType);
void CheatsSet(CheatType cheatType, int32_t param1 = 0, int32_t param2 = 0);
void CheatsSet(CheatType cheatType, int64_t param1 = 0, int64_t param2 = 0);
void CheatsSerialise(class DataSerialiser& ds);

View File

@@ -39,9 +39,9 @@
#include "ParkSetLoanAction.h"
#include "ParkSetParameterAction.h"
using ParametersRange = std::pair<std::pair<int32_t, int32_t>, std::pair<int32_t, int32_t>>;
using ParametersRange = std::pair<std::pair<int64_t, int64_t>, std::pair<int64_t, int64_t>>;
CheatSetAction::CheatSetAction(CheatType cheatType, int32_t param1, int32_t param2)
CheatSetAction::CheatSetAction(CheatType cheatType, int64_t param1, int64_t param2)
: _cheatType(static_cast<int32_t>(cheatType))
, _param1(param1)
, _param2(param2)
@@ -320,7 +320,7 @@ ParametersRange CheatSetAction::GetParameterRange(CheatType cheatType) const
case CheatType::AddMoney:
[[fallthrough]];
case CheatType::SetMoney:
return { { std::numeric_limits<int32_t>::min(), std::numeric_limits<int32_t>::max() }, { 0, 0 } };
return { { std::numeric_limits<money64>::min(), std::numeric_limits<money64>::max() }, { 0, 0 } };
case CheatType::SetGuestParameter:
switch (_param1)
{

View File

@@ -13,16 +13,16 @@
class CheatSetAction final : public GameActionBase<GameCommand::Cheat>
{
using ParametersRange = std::pair<std::pair<int32_t, int32_t>, std::pair<int32_t, int32_t>>;
using ParametersRange = std::pair<std::pair<int64_t, int64_t>, std::pair<int64_t, int64_t>>;
private:
NetworkCheatType_t _cheatType{ EnumValue(CheatType::Count) };
int32_t _param1{};
int32_t _param2{};
int64_t _param1{};
int64_t _param2{};
public:
CheatSetAction() = default;
CheatSetAction(CheatType cheatType, int32_t param1 = 0, int32_t param2 = 0);
CheatSetAction(CheatType cheatType, int64_t param1 = 0, int64_t param2 = 0);
void AcceptParameters(GameActionParameterVisitor& visitor) override;

View File

@@ -43,7 +43,7 @@
// It is used for making sure only compatible builds get connected, even within
// single OpenRCT2 version.
#define NETWORK_STREAM_VERSION "9"
#define NETWORK_STREAM_VERSION "10"
#define NETWORK_STREAM_ID OPENRCT2_VERSION "-" NETWORK_STREAM_VERSION