Allow using the money cheat with values greater than 32 bits

See: #536
pull/532/head
Jonathan G Rennison 1 year ago
parent d03465db59
commit 3151751eda

@ -58,7 +58,7 @@ static int32 _money_cheat_amount = 10000000;
*/
static int32 ClickMoneyCheat(int32 p1, int32 p2)
{
DoCommandP(0, (uint32)(p2 * _money_cheat_amount), 0, _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT);
DoCommandPEx(0, 0, 0, (uint64)(p2 * _money_cheat_amount), _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT);
return _money_cheat_amount;
}
@ -504,7 +504,7 @@ struct CheatWindow : Window {
}
if (ce->mode == CNM_MONEY) {
if (!_networking) *ce->been_used = true;
DoCommandP(0, (strtoll(str, nullptr, 10) / _currency->rate), 0, _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT);
DoCommandPEx(0, 0, 0, (std::strtoll(str, nullptr, 10) / _currency->rate), _network_server || _network_settings_access ? CMD_MONEY_CHEAT_ADMIN : CMD_MONEY_CHEAT);
return;
}

@ -178,8 +178,8 @@ CommandProc CmdCloneOrder;
CommandProc CmdClearArea;
CommandProc CmdGiveMoney;
CommandProc CmdMoneyCheat;
CommandProc CmdMoneyCheatAdmin;
CommandProcEx CmdMoneyCheat;
CommandProcEx CmdMoneyCheatAdmin;
CommandProc CmdChangeBankBalance;
CommandProc CmdCheatSetting;
CommandProc CmdBuildCanal;

@ -201,37 +201,39 @@ CommandCost CmdPause(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2,
* Change the financial flow of your company.
* @param tile unused
* @param flags operation to perform
* @param p1 the amount of money to receive (if positive), or spend (if negative)
* @param p1 unused
* @param p2 unused
* @param p3 the amount of money to receive (if positive), or spend (if negative)
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
CommandCost CmdMoneyCheat(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data)
{
if (_networking && !_settings_game.difficulty.money_cheat_in_multiplayer) return CMD_ERROR;
if (flags & DC_EXEC) {
_cheats.money.been_used = true;
SetWindowDirty(WC_CHEATS, 0);
}
return CommandCost(EXPENSES_OTHER, -(int32)p1);
return CommandCost(EXPENSES_OTHER, -(int64)p3);
}
/**
* Change the financial flow of your company (admin).
* @param tile unused
* @param flags operation to perform
* @param p1 the amount of money to receive (if positive), or spend (if negative)
* @param p1 unused
* @param p2 unused
* @param p3 the amount of money to receive (if positive), or spend (if negative)
* @param text unused
* @return the cost of this operation or an error
*/
CommandCost CmdMoneyCheatAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, const char *text)
CommandCost CmdMoneyCheatAdmin(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32 p2, uint64 p3, const char *text, const CommandAuxiliaryBase *aux_data)
{
if (flags & DC_EXEC) {
_cheats.money.been_used = true;
SetWindowDirty(WC_CHEATS, 0);
}
return CommandCost(EXPENSES_OTHER, -(int32)p1);
return CommandCost(EXPENSES_OTHER, -(int64)p3);
}
/**

Loading…
Cancel
Save