| 246 | } |
| 247 | |
| 248 | static 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 | |
| 271 | static bool is_protected(const df::plant * plant, PersistentDataItem &c) { |
| 272 | const df::plant_raw *plant_raw = df::plant_raw::find(plant->material); |
no test coverage detected