From 2e39637db226f1326da7c2f0814b2dbb320191a1 Mon Sep 17 00:00:00 2001 From: Michael Lutz Date: Wed, 1 Dec 2021 00:17:05 +0100 Subject: Codechange: Don't use a global for the 'not enough cash' message. --- src/command.cpp | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/command.cpp') diff --git a/src/command.cpp b/src/command.cpp index 08fe7b265..c02796fef 100644 --- a/src/command.cpp +++ b/src/command.cpp @@ -287,9 +287,6 @@ void CommandHelperBase::LogCommandExecution(Commands cmd, StringID err_message, */ bool CommandHelperBase::InternalExecutePrepTest(CommandFlags cmd_flags, TileIndex tile, Backup &cur_company) { - /* Reset the state. */ - _additional_cash_required = 0; - /* Do not even think about executing out-of-bounds tile-commands */ if (tile != 0 && (tile >= MapSize() || (!IsValidTile(tile) && (cmd_flags & CMD_ALL_TILES) == 0))) return false; @@ -356,11 +353,12 @@ std::tuple CommandHelperBase::InternalExecuteValidateTestAndPr * @param cmd_flags Command flags. * @param res_test Command result of test run. * @param tes_exec Command result of real run. + * @param extra_cash Additional cash required for successful command execution. * @param tile Tile of command execution. * @param[in,out] cur_company Backup of current company at start of command execution. * @return Final command result. */ -CommandCost CommandHelperBase::InternalExecuteProcessResult(Commands cmd, CommandFlags cmd_flags, const CommandCost &res_test, const CommandCost &res_exec, TileIndex tile, Backup &cur_company) +CommandCost CommandHelperBase::InternalExecuteProcessResult(Commands cmd, CommandFlags cmd_flags, const CommandCost &res_test, const CommandCost &res_exec, Money extra_cash, TileIndex tile, Backup &cur_company) { BasePersistentStorageArray::SwitchMode(PSM_LEAVE_COMMAND); @@ -389,11 +387,11 @@ CommandCost CommandHelperBase::InternalExecuteProcessResult(Commands cmd, Comman /* If we're needing more money and we haven't done * anything yet, ask for the money! */ - if (_additional_cash_required != 0 && res_exec.GetCost() == 0) { + if (extra_cash != 0 && res_exec.GetCost() == 0) { /* It could happen we removed rail, thus gained money, and deleted something else. * So make sure the signal buffer is empty even in this case */ UpdateSignalsInBuffer(); - SetDParam(0, _additional_cash_required); + SetDParam(0, extra_cash); return CommandCost(STR_ERROR_NOT_ENOUGH_CASH_REQUIRES_CURRENCY); } -- cgit v1.2.3-54-g00ecf