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

Function IsTileForestIndustry

src/industry_cmd.cpp:978–990  ·  view source on GitHub ↗

* Check whether the tile is a forest. * @param tile the tile to investigate. * @return true if and only if the tile is a forest */

Source from the content-addressed store, hash-verified

976 * @return true if and only if the tile is a forest
977 */
978bool IsTileForestIndustry(TileIndex tile)
979{
980 /* Check for industry tile */
981 if (!IsTileType(tile, MP_INDUSTRY)) return false;
982
983 const Industry *ind = Industry::GetByTile(tile);
984
985 /* Check for organic industry (i.e. not processing or extractive) */
986 if (!GetIndustrySpec(ind->type)->life_type.Test(IndustryLifeType::Organic)) return false;
987
988 /* Check for wood production */
989 return std::any_of(std::begin(ind->produced), std::end(ind->produced), [](const auto &p) { return IsValidCargoType(p.cargo) && CargoSpec::Get(p.cargo)->label == CT_WOOD; });
990}
991
992static const uint8_t _plantfarmfield_type[] = {1, 1, 1, 1, 1, 3, 3, 4, 4, 4, 5, 5, 5, 6, 6, 6};
993

Callers 1

Calls 6

IsTileTypeFunction · 0.85
GetIndustrySpecFunction · 0.85
IsValidCargoTypeFunction · 0.85
TestMethod · 0.80
beginFunction · 0.50
endFunction · 0.50

Tested by

no test coverage detected