MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / IsSuitableForFarmField

Function IsSuitableForFarmField

src/industry_cmd.cpp:1001–1015  ·  view source on GitHub ↗

* Check whether the tile can be replaced by a farm field. * @param tile The tile to investigate. * @param allow_fields Can we replace an existing field? * @param allow_rough Can we build on rough tiles? (clear or trees) * @return true if the tile can become a farm field */

Source from the content-addressed store, hash-verified

999 * @return true if the tile can become a farm field
1000 */
1001static bool IsSuitableForFarmField(TileIndex tile, bool allow_fields, bool allow_rough)
1002{
1003 switch (GetTileType(tile)) {
1004 case MP_CLEAR:
1005 if (IsSnowTile(tile)) return false;
1006 switch (GetClearGround(tile)) {
1007 case CLEAR_DESERT: return false;
1008 case CLEAR_ROUGH: return allow_rough;
1009 case CLEAR_FIELDS: return allow_fields;
1010 default: return true;
1011 }
1012 case MP_TREES: return GetTreeGround(tile) != TREE_GROUND_SHORE && (allow_rough || GetTreeGround(tile) != TREE_GROUND_ROUGH);
1013 default: return false;
1014 }
1015}
1016
1017/**
1018 * Build farm field fence

Callers 1

PlantFarmFieldFunction · 0.85

Calls 4

GetTileTypeFunction · 0.85
IsSnowTileFunction · 0.85
GetClearGroundFunction · 0.85
GetTreeGroundFunction · 0.85

Tested by

no test coverage detected