diff --git a/src/lang/english.txt b/src/lang/english.txt index 52575bd4a3..b08372ccef 100644 --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4930,8 +4930,6 @@ STR_ERROR_CAN_T_BUILD_ROAD_HERE :{WHITE}Can't bu STR_ERROR_CAN_T_BUILD_TRAMWAY_HERE :{WHITE}Can't build tramway here... STR_ERROR_CAN_T_REMOVE_ROAD_FROM :{WHITE}Can't remove road from here... STR_ERROR_CAN_T_REMOVE_TRAMWAY_FROM :{WHITE}Can't remove tramway from here... -STR_ERROR_THERE_IS_NO_ROAD :{WHITE}... there is no road -STR_ERROR_THERE_IS_NO_TRAMWAY :{WHITE}... there is no tramway STR_ERROR_CAN_T_CONVERT_ROAD :{WHITE}Can't convert road type here... STR_ERROR_CAN_T_CONVERT_TRAMWAY :{WHITE}Can't convert tram type here... STR_ERROR_NO_SUITABLE_ROAD :{WHITE}No suitable road diff --git a/src/rail_cmd.cpp b/src/rail_cmd.cpp index a2c97af8b7..8683a13eb9 100644 --- a/src/rail_cmd.cpp +++ b/src/rail_cmd.cpp @@ -453,7 +453,12 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai ret = CheckTrackCombination(tile, trackbit, flags); if (ret.Succeeded()) ret = EnsureNoTrainOnTrack(tile, track); - if (ret.Failed()) return ret; + if (ret.Failed()) { + if (ret.GetErrorMessage() != STR_ERROR_ALREADY_BUILT) return ret; + + /* We don't have to pay for rail that already exists, and we can break out early. */ + return CommandCost(); + } ret = CheckRailSlope(tileh, trackbit, GetTrackBits(tile), tile); if (ret.Failed()) return ret; @@ -565,7 +570,7 @@ CommandCost CmdBuildSingleRail(DoCommandFlag flags, TileIndex tile, RailType rai } if (IsLevelCrossing(tile) && GetCrossingRailBits(tile) == trackbit) { - return_cmd_error(STR_ERROR_ALREADY_BUILT); + return CommandCost(); } FALLTHROUGH; } @@ -635,7 +640,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track switch (GetTileType(tile)) { case MP_ROAD: { - if (!IsLevelCrossing(tile) || GetCrossingRailBits(tile) != trackbit) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK); + if (!IsLevelCrossing(tile) || GetCrossingRailBits(tile) != trackbit) return CommandCost(); if (_current_company != OWNER_WATER) { CommandCost ret = CheckTileOwnership(tile); @@ -669,7 +674,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track case MP_RAILWAY: { TrackBits present; /* There are no rails present at depots. */ - if (!IsPlainRail(tile)) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK); + if (!IsPlainRail(tile)) return CommandCost(); if (_current_company != OWNER_WATER) { CommandCost ret = CheckTileOwnership(tile); @@ -680,7 +685,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track if (ret.Failed()) return ret; present = GetTrackBits(tile); - if ((present & trackbit) == 0) return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK); + if ((present & trackbit) == 0) return CommandCost(); if (present == (TRACK_BIT_X | TRACK_BIT_Y)) crossing = true; cost.AddCost(RailClearCost(GetRailType(tile))); @@ -728,7 +733,7 @@ CommandCost CmdRemoveSingleRail(DoCommandFlag flags, TileIndex tile, Track track break; } - default: return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK); + default: return CommandCost(); } if (flags & DC_EXEC) { @@ -1446,10 +1451,10 @@ CommandCost CmdBuildSignalTrack(DoCommandFlag flags, TileIndex tile, TileIndex e CommandCost CmdRemoveSingleSignal(DoCommandFlag flags, TileIndex tile, Track track) { if (!ValParamTrackOrientation(track) || !IsPlainRailTile(tile) || !HasTrack(tile, track)) { - return_cmd_error(STR_ERROR_THERE_IS_NO_RAILROAD_TRACK); + return CommandCost(); } if (!HasSignalOnTrack(tile, track)) { - return_cmd_error(STR_ERROR_THERE_ARE_NO_SIGNALS); + return CommandCost(); } /* Only water can remove signals from anyone */ diff --git a/src/road_cmd.cpp b/src/road_cmd.cpp index 6766a299f4..1a81ad1d90 100644 --- a/src/road_cmd.cpp +++ b/src/road_cmd.cpp @@ -336,7 +336,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec RoadType existing_rt = MayHaveRoad(tile) ? GetRoadType(tile, rtt) : INVALID_ROADTYPE; /* The tile doesn't have the given road type */ - if (existing_rt == INVALID_ROADTYPE) return_cmd_error((rtt == RTT_TRAM) ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD); + if (existing_rt == INVALID_ROADTYPE) return CommandCost(); switch (GetTileType(tile)) { case MP_ROAD: { @@ -374,7 +374,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec CommandCost cost(EXPENSES_CONSTRUCTION); if (IsTileType(tile, MP_TUNNELBRIDGE)) { /* Removing any roadbit in the bridge axis removes the roadtype (that's the behaviour remove-long-roads needs) */ - if ((AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) & pieces) == ROAD_NONE) return_cmd_error((rtt == RTT_TRAM) ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD); + if ((AxisToRoadBits(DiagDirToAxis(GetTunnelBridgeDirection(tile))) & pieces) == ROAD_NONE) return CommandCost(); TileIndex other_end = GetOtherTunnelBridgeEnd(tile); /* Pay for *every* tile of the bridge or tunnel */ @@ -441,7 +441,7 @@ static CommandCost RemoveRoad(TileIndex tile, DoCommandFlag flags, RoadBits piec /* limit the bits to delete to the existing bits. */ pieces &= present; - if (pieces == ROAD_NONE) return_cmd_error((rtt == RTT_TRAM) ? STR_ERROR_THERE_IS_NO_TRAMWAY : STR_ERROR_THERE_IS_NO_ROAD); + if (pieces == ROAD_NONE) return CommandCost(); /* Now set present what it will be after the remove */ present ^= pieces; @@ -692,7 +692,7 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R } return CommandCost(); } - return_cmd_error(STR_ERROR_ALREADY_BUILT); + return CommandCost(); } /* Disallow breaking end-of-line of someone else * so trams can still reverse on this tile. */ @@ -715,11 +715,11 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R if (pieces & ComplementRoadBits(other_bits)) goto do_clear; pieces = other_bits; // we need to pay for both roadbits - if (HasTileRoadType(tile, rtt)) return_cmd_error(STR_ERROR_ALREADY_BUILT); + if (HasTileRoadType(tile, rtt)) return CommandCost(); break; case ROAD_TILE_DEPOT: - if ((GetAnyRoadBits(tile, rtt) & pieces) == pieces) return_cmd_error(STR_ERROR_ALREADY_BUILT); + if ((GetAnyRoadBits(tile, rtt) & pieces) == pieces) return CommandCost(); goto do_clear; default: NOT_REACHED(); @@ -790,14 +790,14 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R } case MP_STATION: { - if ((GetAnyRoadBits(tile, rtt) & pieces) == pieces) return_cmd_error(STR_ERROR_ALREADY_BUILT); + if ((GetAnyRoadBits(tile, rtt) & pieces) == pieces) return CommandCost(); if (!IsDriveThroughStopTile(tile)) goto do_clear; RoadBits curbits = AxisToRoadBits(DiagDirToAxis(GetRoadStopDir(tile))); if (pieces & ~curbits) goto do_clear; pieces = curbits; // we need to pay for both roadbits - if (HasTileRoadType(tile, rtt)) return_cmd_error(STR_ERROR_ALREADY_BUILT); + if (HasTileRoadType(tile, rtt)) return CommandCost(); break; } @@ -805,7 +805,7 @@ CommandCost CmdBuildRoad(DoCommandFlag flags, TileIndex tile, RoadBits pieces, R if (GetTunnelBridgeTransportType(tile) != TRANSPORT_ROAD) goto do_clear; /* Only allow building the outern roadbit, so building long roads stops at existing bridges */ if (MirrorRoadBits(DiagDirToRoadBits(GetTunnelBridgeDirection(tile))) != pieces) goto do_clear; - if (HasTileRoadType(tile, rtt)) return_cmd_error(STR_ERROR_ALREADY_BUILT); + if (HasTileRoadType(tile, rtt)) return CommandCost(); /* Don't allow adding roadtype to the bridge/tunnel when vehicles are already driving on it */ CommandCost ret = TunnelBridgeIsFree(tile, GetOtherTunnelBridgeEnd(tile)); if (ret.Failed()) return ret;