diff options
author | Patric Stout <truebrain@openttd.org> | 2021-01-07 08:01:46 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2021-01-07 08:01:46 +0100 |
commit | 1b675e7075d1c2375cc8da5a928fb6b7be6317d5 (patch) | |
tree | af4842d36538d89c2df5c2b0c26123b610f742ae /src | |
parent | c7609e767fa87fbd77f7f3f4bdbc748f2b5e5ffb (diff) | |
download | openttd-1b675e7075d1c2375cc8da5a928fb6b7be6317d5.tar.xz |
Fix #8068: always allow removal of tram track if that generates money (#8509)
Even if you are completely broke, generating money should always
be allowed.
Diffstat (limited to 'src')
-rw-r--r-- | src/road_cmd.cpp | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 79048b9b5..c94beb0b1 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -1109,7 +1109,8 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 p2 ^= IsInsideMM(p2 & 3, 1, 3) ? 3 : 0; } - Money money = GetAvailableMoneyForCommand(); + Money money_available = GetAvailableMoneyForCommand(); + Money money_spent = 0; TileIndex tile = start_tile; CommandCost last_error = CMD_ERROR; bool had_success = false; @@ -1126,8 +1127,8 @@ CommandCost CmdRemoveLongRoad(TileIndex start_tile, DoCommandFlag flags, uint32 CommandCost ret = RemoveRoad(tile, flags & ~DC_EXEC, bits, rtt, true); if (ret.Succeeded()) { if (flags & DC_EXEC) { - money -= ret.GetCost(); - if (money < 0) { + money_spent += ret.GetCost(); + if (money_spent > 0 && money_spent > money_available) { _additional_cash_required = DoCommand(start_tile, end_tile, p2, flags & ~DC_EXEC, CMD_REMOVE_LONG_ROAD).GetCost(); return cost; } |