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

Function is_accessible_tree

plugins/autochop.cpp:233–246  ·  view source on GitHub ↗

at least one member of the fort can reach a position adjacent to the given pos

Source from the content-addressed store, hash-verified

231
232// at least one member of the fort can reach a position adjacent to the given pos
233static bool is_accessible_tree(const df::coord &pos, const vector<df::unit *> &citizens) {
234 for (auto &unit : citizens) {
235 if (Maps::canWalkBetween(unit->pos, df::coord(pos.x-1, pos.y-1, pos.z))
236 || Maps::canWalkBetween(unit->pos, df::coord(pos.x, pos.y-1, pos.z))
237 || Maps::canWalkBetween(unit->pos, df::coord(pos.x+1, pos.y-1, pos.z))
238 || Maps::canWalkBetween(unit->pos, df::coord(pos.x-1, pos.y, pos.z))
239 || Maps::canWalkBetween(unit->pos, df::coord(pos.x+1, pos.y, pos.z))
240 || Maps::canWalkBetween(unit->pos, df::coord(pos.x-1, pos.y+1, pos.z))
241 || Maps::canWalkBetween(unit->pos, df::coord(pos.x, pos.y+1, pos.z))
242 || Maps::canWalkBetween(unit->pos, df::coord(pos.x+1, pos.y+1, pos.z)))
243 return true;
244 }
245 return false;
246}
247
248static bool is_valid_tree(const df::plant *plant) {
249 // Skip all non-trees immediately.

Callers 1

scan_treeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected