summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorterkhen <terkhen@openttd.org>2010-02-05 14:11:25 +0000
committerterkhen <terkhen@openttd.org>2010-02-05 14:11:25 +0000
commit9cf602c7c13b8e58564a7ae8e9d90a74e63fc1a7 (patch)
treeb818b876a5c12f6e51711091250f791433f36965
parent5d78e734459f7c49abc59025fea1e2fc6c69891b (diff)
downloadopenttd-9cf602c7c13b8e58564a7ae8e9d90a74e63fc1a7.tar.xz
(svn r19016) -Fix [FS#3591]: When removing roads, the player was also charged for removing the foundations.
-rw-r--r--src/road_cmd.cpp10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index aa5c14943..4b2f0957d 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -312,9 +312,11 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec
}
}
- /* If we change the foundation we have to pay for it. */
- return CommandCost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price[PR_CLEAR_ROAD] +
- ((GetRoadFoundation(tileh, present) != f) ? _price[PR_BUILD_FOUNDATION] : (Money)0));
+ CommandCost cost(EXPENSES_CONSTRUCTION, CountBits(pieces) * _price[PR_CLEAR_ROAD]);
+ /* If we build a foundation we have to pay for it. */
+ if (f == FOUNDATION_NONE && GetRoadFoundation(tileh, present) != FOUNDATION_NONE) cost.AddCost(_price[PR_BUILD_FOUNDATION]);
+
+ return cost;
}
case ROAD_TILE_CROSSING: {
@@ -420,7 +422,7 @@ static CommandCost CheckRoadSlope(Slope tileh, RoadBits *pieces, RoadBits existi
return CommandCost();
}
} else {
- if (CountBits(existing) == 1) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
+ if (CountBits(existing) == 1 && GetRoadFoundation(tileh, existing) == FOUNDATION_NONE) return CommandCost(EXPENSES_CONSTRUCTION, _price[PR_BUILD_FOUNDATION]);
return CommandCost();
}
}