1
0
Fork 0

Add: Improving town-owned bridges increases company rating (#13036)

pull/12979/head
Thomas Winwood 2024-11-07 13:14:04 +00:00 committed by GitHub
parent 7b3525954c
commit b1bba967a1
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 17 additions and 15 deletions

View File

@ -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_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_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_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_MINIMUM = 0; ///< minimum rating after removing tunnel or bridge
static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144; ///< rating needed, "Lenient" difficulty settings static constexpr int RATING_TUNNEL_BRIDGE_NEEDED_LENIENT = 144; ///< rating needed, "Lenient" difficulty settings

View File

@ -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)) {
if (!(flags & DC_QUERY_COST) && IsTileOwner(tile_start, OWNER_TOWN) && /* Do not replace the bridge with the same bridge type. */
GetBridgeSpec(bridge_type)->speed < GetBridgeSpec(GetBridgeType(tile_start))->speed && if ((bridge_type == GetBridgeType(tile_start)) && (transport_type != TRANSPORT_ROAD || road_rt == roadtype || tram_rt == roadtype)) {
_game_mode != GM_EDITOR) { return_cmd_error(STR_ERROR_ALREADY_BUILT);
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);
} }
}
/* Do not replace the bridge with the same bridge type. */ /* Do not replace town bridges with lower speed bridges, unless in scenario editor. */
if (!(flags & DC_QUERY_COST) && (bridge_type == GetBridgeType(tile_start)) && (transport_type != TRANSPORT_ROAD || road_rt == roadtype || tram_rt == roadtype)) { if (IsTileOwner(tile_start, OWNER_TOWN) && _game_mode != GM_EDITOR) {
return_cmd_error(STR_ERROR_ALREADY_BUILT); 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. */ /* Do not allow replacing another company's bridges. */