diff --git a/src/town_type.h b/src/town_type.h index 1759322fba..d86b947022 100644 --- a/src/town_type.h +++ b/src/town_type.h @@ -53,6 +53,7 @@ static constexpr int RATING_GROWTH_MAXIMUM = RATING_MEDIOCRE; ///< ... up to RAT static constexpr int RATING_STATION_UP_STEP = 12; ///< when a town grows, company gains reputation for all well serviced stations ... static constexpr int RATING_STATION_DOWN_STEP = -15; ///< ... but loses for badly serviced stations +static constexpr int RATING_TUNNEL_BRIDGE_UP_STEP = 50; ///< rating increase for improving a town-owned bridge static constexpr int RATING_TUNNEL_BRIDGE_DOWN_STEP = -250; ///< penalty for removing town owned tunnel or bridge static constexpr int RATING_TUNNEL_BRIDGE_MINIMUM = 0; ///< minimum rating after removing tunnel or bridge static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144; ///< rating needed, "Lenient" difficulty settings diff --git a/src/tunnelbridge_cmd.cpp b/src/tunnelbridge_cmd.cpp index 7ac7b37e8b..7efdfed1e2 100644 --- a/src/tunnelbridge_cmd.cpp +++ b/src/tunnelbridge_cmd.cpp @@ -373,23 +373,24 @@ CommandCost CmdBuildBridge(DoCommandFlag flags, TileIndex tile_end, TileIndex ti } } - /* Do not replace town bridges with lower speed bridges, unless in scenario editor. */ - if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) && - GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed && - _game_mode != GM_EDITOR) { - Town *t = ClosestTownFromTile(tile_start, UINT_MAX); - - if (t == nullptr) { - return CMD_ERROR; - } else { - SetDParam(0, t->index); - return_cmd_error(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS); + if (!(flags & DC_QUERY_COST)) { + /* Do not replace the bridge with the same bridge type. */ + if ((bridge_type == GetBridgeType(tile_start)) && (transport_type != TRANSPORT_ROAD || road_rt == roadtype || tram_rt == roadtype)) { + return_cmd_error(STR_ERROR_ALREADY_BUILT); } - } - /* Do not replace the bridge with the same bridge type. */ - if (!(flags & DC_QUERY_COST) && (bridge_type == GetBridgeType(tile_start)) && (transport_type != TRANSPORT_ROAD || road_rt == roadtype || tram_rt == roadtype)) { - return_cmd_error(STR_ERROR_ALREADY_BUILT); + /* Do not replace town bridges with lower speed bridges, unless in scenario editor. */ + if (IsTileOwner(tile_start, OWNER_TOWN) && _game_mode != GM_EDITOR) { + Town *t = ClosestTownFromTile(tile_start, UINT_MAX); + if (t == nullptr) return CMD_ERROR; + + if (GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed) { + SetDParam(0, t->index); + return_cmd_error(STR_ERROR_LOCAL_AUTHORITY_REFUSES_TO_ALLOW_THIS); + } else { + ChangeTownRating(t, RATING_TUNNEL_BRIDGE_UP_STEP, RATING_MAXIMUM, flags); + } + } } /* Do not allow replacing another company's bridges. */