diff options
-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; } |