Add settings for minimum contiguous landmass size for town/city placement
This commit is contained in:
@@ -2108,7 +2108,7 @@ static void DoCreateTown(Town *t, TileIndex tile, uint32 townnameparts, TownSize
|
||||
* @param tile tile to check
|
||||
* @return error value or zero cost
|
||||
*/
|
||||
static CommandCost TownCanBePlacedHere(TileIndex tile)
|
||||
static CommandCost TownCanBePlacedHere(TileIndex tile, bool city)
|
||||
{
|
||||
/* Check if too close to the edge of map */
|
||||
if (DistanceFromEdge(tile) < 12) {
|
||||
@@ -2130,6 +2130,17 @@ static CommandCost TownCanBePlacedHere(TileIndex tile)
|
||||
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||
}
|
||||
|
||||
uint min_land_area = city ? _settings_game.economy.min_city_land_area : _settings_game.economy.min_town_land_area;
|
||||
if (min_land_area > 0) {
|
||||
if (!EnoughContiguousTilesMatchingCondition(tile, min_land_area, [](TileIndex t, void *data) -> bool {
|
||||
if (!HasTileWaterClass(t) || GetWaterClass(t) == WATER_CLASS_INVALID) return true;
|
||||
if (IsCoastTile(t) && !IsSlopeWithOneCornerRaised(GetTileSlope(t))) return true;
|
||||
return false;
|
||||
}, nullptr)) {
|
||||
return_cmd_error(STR_ERROR_SITE_UNSUITABLE);
|
||||
}
|
||||
}
|
||||
|
||||
return CommandCost(EXPENSES_OTHER);
|
||||
}
|
||||
|
||||
@@ -2197,7 +2208,7 @@ CommandCost CmdFoundTown(TileIndex tile, DoCommandFlag flags, uint32 p1, uint32
|
||||
if (!Town::CanAllocateItem()) return_cmd_error(STR_ERROR_TOO_MANY_TOWNS);
|
||||
|
||||
if (!random) {
|
||||
CommandCost ret = TownCanBePlacedHere(tile);
|
||||
CommandCost ret = TownCanBePlacedHere(tile, city);
|
||||
if (ret.Failed()) return ret;
|
||||
}
|
||||
|
||||
@@ -2408,7 +2419,7 @@ static Town *CreateRandomTown(uint attempts, uint32 townnameparts, TownSize size
|
||||
}
|
||||
|
||||
/* Make sure town can be placed here */
|
||||
if (TownCanBePlacedHere(tile).Failed()) continue;
|
||||
if (TownCanBePlacedHere(tile, city).Failed()) continue;
|
||||
|
||||
/* Allocate a town struct */
|
||||
Town *t = new Town(tile);
|
||||
|
Reference in New Issue
Block a user