# HG changeset patch # User Tyler Trahan # Date 2023-10-19 21:01:45 # Node ID 73a9fc784247b405db02f0d549146171d0dc5bdf # Parent c5cd3e96ecce73da56bbebdf768d847634d034f1 Change: Always allow expanding towns in Scenario Editor to build new roads (#11377) diff --git a/src/lang/english.txt b/src/lang/english.txt --- a/src/lang/english.txt +++ b/src/lang/english.txt @@ -4866,7 +4866,6 @@ STR_ERROR_TOO_CLOSE_TO_EDGE_OF_MAP_SUB STR_ERROR_TOO_CLOSE_TO_ANOTHER_TOWN :{WHITE}... too close to another town STR_ERROR_TOO_MANY_TOWNS :{WHITE}... too many towns STR_ERROR_NO_SPACE_FOR_TOWN :{WHITE}... there is no more space on the map -STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS :{WHITE}The town will not build roads. You can enable building of roads via Settings->Environment->Towns STR_ERROR_ROAD_WORKS_IN_PROGRESS :{WHITE}Road works in progress STR_ERROR_TOWN_CAN_T_DELETE :{WHITE}Can't delete this town...{}A station or depot is referring to the town or a town owned tile can't be removed STR_ERROR_STATUE_NO_SUITABLE_PLACE :{WHITE}... there is no suitable place for a statue in the centre of this town diff --git a/src/town_cmd.cpp b/src/town_cmd.cpp --- a/src/town_cmd.cpp +++ b/src/town_cmd.cpp @@ -1375,6 +1375,15 @@ static bool TownCanGrowRoad(TileIndex ti } /** + * Check if the town is allowed to build roads. + * @return true If the town is allowed to build roads. + */ +static inline bool TownAllowedToBuildRoads() +{ + return _settings_game.economy.allow_town_roads || _generating_world || _game_mode == GM_EDITOR; +} + +/** * Grows the given town. * There are at the moment 3 possible way's for * the town expansion: @@ -1403,7 +1412,7 @@ static void GrowTownInTile(TileIndex *ti * to say that this is the last iteration. */ _grow_town_result = GROWTH_SEARCH_STOPPED; - if (!_settings_game.economy.allow_town_roads && !_generating_world) return; + if (!TownAllowedToBuildRoads()) return; if (!_settings_game.economy.allow_town_level_crossings && IsTileType(tile, MP_RAILWAY)) return; /* Remove hills etc */ @@ -1457,7 +1466,7 @@ static void GrowTownInTile(TileIndex *ti * the fitting RoadBits */ _grow_town_result = GROWTH_SEARCH_STOPPED; - if (!_settings_game.economy.allow_town_roads && !_generating_world) return; + if (!TownAllowedToBuildRoads()) return; switch (t1->layout) { default: NOT_REACHED(); @@ -1528,7 +1537,7 @@ static void GrowTownInTile(TileIndex *ti if (!IsValidTile(house_tile)) return; - if (target_dir != DIAGDIR_END && (_settings_game.economy.allow_town_roads || _generating_world)) { + if (target_dir != DIAGDIR_END && TownAllowedToBuildRoads()) { switch (t1->layout) { default: NOT_REACHED(); @@ -1606,7 +1615,7 @@ static bool CanFollowRoad(TileIndex tile if (HasTileWaterGround(target_tile)) return false; RoadBits target_rb = GetTownRoadBits(target_tile); - if (_settings_game.economy.allow_town_roads || _generating_world) { + if (TownAllowedToBuildRoads()) { /* Check whether a road connection exists or can be build. */ switch (GetTileType(target_tile)) { case MP_ROAD: @@ -1773,7 +1782,7 @@ static bool GrowTown(Town *t) /* No road available, try to build a random road block by * clearing some land and then building a road there. */ - if (_settings_game.economy.allow_town_roads || _generating_world) { + if (TownAllowedToBuildRoads()) { tile = t->xy; for (ptr = _town_coord_mod; ptr != endof(_town_coord_mod); ++ptr) { /* Only work with plain land that not already has a house */ @@ -2437,7 +2446,7 @@ static bool CheckFree2x2Area(TileIndex t static inline bool TownLayoutAllowsHouseHere(Town *t, TileIndex tile) { /* Allow towns everywhere when we don't build roads */ - if (!_settings_game.economy.allow_town_roads && !_generating_world) return true; + if (!TownAllowedToBuildRoads()) return true; TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile); @@ -2468,7 +2477,7 @@ static inline bool TownLayoutAllowsHouse static inline bool TownLayoutAllows2x2HouseHere(Town *t, TileIndex tile) { /* Allow towns everywhere when we don't build roads */ - if (!_settings_game.economy.allow_town_roads && !_generating_world) return true; + if (!TownAllowedToBuildRoads()) return true; /* Compute relative position of tile. (Positive offsets are towards north) */ TileIndexDiffC grid_pos = TileIndexToTileIndexDiffC(t->xy, tile); diff --git a/src/town_gui.cpp b/src/town_gui.cpp --- a/src/town_gui.cpp +++ b/src/town_gui.cpp @@ -500,14 +500,6 @@ public: break; case WID_TV_EXPAND: { // expand town - only available on Scenario editor - /* Warn the user if towns are not allowed to build roads, but do this only once per OpenTTD run. */ - static bool _warn_town_no_roads = false; - - if (!_settings_game.economy.allow_town_roads && !_warn_town_no_roads) { - ShowErrorMessage(STR_ERROR_TOWN_EXPAND_WARN_NO_ROADS, INVALID_STRING_ID, WL_WARNING); - _warn_town_no_roads = true; - } - Command::Post(STR_ERROR_CAN_T_EXPAND_TOWN, this->window_number, 0); break; }