summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDaniel Lee <dan.ddm999@gmail.com>2019-06-26 04:30:04 +0100
committerCharles Pigott <charlespigott@googlemail.com>2019-12-31 19:17:56 +0000
commit24bace32badeafd97df2bc849cf9fb93f3cfbce0 (patch)
treeadad8725f952adcbb3c57aaba080da035a2e71eb
parentf6ce5c45637273e8692261c66ed646753fb31971 (diff)
downloadopenttd-24bace32badeafd97df2bc849cf9fb93f3cfbce0.tar.xz
Fix #7625: Road infrastructure cost is correctly updated on upgrading your own roads.
-rw-r--r--src/road_cmd.cpp10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp
index ae328a065..ace8edff7 100644
--- a/src/road_cmd.cpp
+++ b/src/road_cmd.cpp
@@ -2269,12 +2269,12 @@ static Vehicle *UpdateRoadVehPowerProc(Vehicle *v, void *data)
}
/**
- * Checks the tile and returns whether the current player is allowed to convert the roadtype to another roadtype
+ * Checks the tile and returns whether the current player is allowed to convert the roadtype to another roadtype without taking ownership
* @param owner the tile owner.
* @param rtt Road/tram type.
* @return whether the road is convertible
*/
-static bool CanConvertRoadType(Owner owner, RoadTramType rtt)
+static bool CanConvertUnownedRoadType(Owner owner, RoadTramType rtt)
{
return (owner == OWNER_NONE || (owner == OWNER_TOWN && rtt == RTT_ROAD));
}
@@ -2370,7 +2370,7 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
/* Trying to convert other's road */
Owner owner = GetRoadOwner(tile, rtt);
- if (!CanConvertRoadType(owner, rtt)) {
+ if (!CanConvertUnownedRoadType(owner, rtt)) {
CommandCost ret = CheckOwnership(owner, tile);
if (ret.Failed()) {
error = ret;
@@ -2400,7 +2400,7 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (flags & DC_EXEC) { // we can safely convert, too
/* Update the company infrastructure counters. */
- if (!IsRoadStopTile(tile) && CanConvertRoadType(owner, rtt) && owner != OWNER_TOWN) {
+ if (!IsRoadStopTile(tile) && owner == _current_company) {
ConvertRoadTypeOwner(tile, num_pieces, owner, from_type, to_type);
}
@@ -2447,7 +2447,7 @@ CommandCost CmdConvertRoad(TileIndex tile, DoCommandFlag flags, uint32 p1, uint3
if (flags & DC_EXEC) {
/* Update the company infrastructure counters. */
- if (CanConvertRoadType(owner, rtt) && owner != OWNER_TOWN) {
+ if (owner == _current_company) {
ConvertRoadTypeOwner(tile, num_pieces, owner, from_type, to_type);
ConvertRoadTypeOwner(endtile, num_pieces, owner, from_type, to_type);
SetTunnelBridgeOwner(tile, endtile, _current_company);