Changeset - r24006:df38d9f4f3a2
[Not reviewed]
master
0 1 0
Daniel Lee - 5 years ago 2019-06-26 03:30:04
dan.ddm999@gmail.com
Fix #7625: Road infrastructure cost is correctly updated on upgrading your own roads.
1 file changed with 5 insertions and 5 deletions:
0 comments (0 inline, 0 general)
src/road_cmd.cpp
Show inline comments
 
@@ -2269,12 +2269,12 @@ static Vehicle *UpdateRoadVehPowerProc(V
 
}
 

	
 
/**
 
 * 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 til
 

	
 
		/* 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 til
 

	
 
			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 til
 

	
 
			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);
0 comments (0 inline, 0 general)