MCPcopy Create free account
hub / github.com/DFHack/dfhack / is_valid_tree

Function is_valid_tree

plugins/autochop.cpp:248–269  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

246}
247
248static bool is_valid_tree(const df::plant *plant) {
249 // Skip all non-trees immediately.
250 if (!plant->tree_info)
251 return false;
252
253 // Skip plants with invalid tile.
254 df::map_block *block = Maps::getTileBlock(plant->pos);
255 if (!block)
256 return false;
257
258 int x = plant->pos.x % 16;
259 int y = plant->pos.y % 16;
260
261 // Skip all unrevealed plants.
262 if (block->designation[x][y].bits.hidden)
263 return false;
264
265 if (tileMaterial(block->tiletype[x][y]) != tiletype_material::TREE)
266 return false;
267
268 return true;
269}
270
271static bool is_protected(const df::plant * plant, PersistentDataItem &c) {
272 const df::plant_raw *plant_raw = df::plant_raw::find(plant->material);

Callers 2

scan_treeFunction · 0.85
autochop_undesignateFunction · 0.85

Calls 2

getTileBlockFunction · 0.85
tileMaterialFunction · 0.85

Tested by

no test coverage detected