* 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 */
| 999 | * @return true if the tile can become a farm field |
| 1000 | */ |
| 1001 | static 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 |
no test coverage detected