at least one member of the fort can reach a position adjacent to the given pos
| 231 | |
| 232 | // at least one member of the fort can reach a position adjacent to the given pos |
| 233 | static 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 | |
| 248 | static bool is_valid_tree(const df::plant *plant) { |
| 249 | // Skip all non-trees immediately. |