Merge branch 'jgrpp' into jgrpp-beta

# Conflicts:
#	src/network/core/packet.cpp
#	src/network/core/udp.cpp
This commit is contained in:
Jonathan G Rennison
2021-10-29 22:22:54 +01:00
45 changed files with 382 additions and 107 deletions

View File

@@ -2112,7 +2112,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) {
@@ -2134,6 +2134,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);
}
@@ -2201,7 +2212,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;
}
@@ -2412,7 +2423,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);