| 247 | } |
| 248 | |
| 249 | bool designate(color_ostream& out, const df::plant* plant, bool farming) { |
| 250 | TRACE(log, out).print("Attempting to designate {} at ({}, {}, {})\n", world->raws.plants.all[plant->material]->id, plant->pos.x, plant->pos.y, plant->pos.z); |
| 251 | |
| 252 | if (!farming) { |
| 253 | bool istree = (tileMaterial(Maps::getTileBlock(plant->pos)->tiletype[plant->pos.x % 16][plant->pos.y % 16]) == tiletype_material::TREE); |
| 254 | if (istree) |
| 255 | return Designations::markPlant(plant); |
| 256 | } |
| 257 | |
| 258 | df::plant_raw* plant_raw = world->raws.plants.all[plant->material]; |
| 259 | const DFHack::MaterialInfo basic_mat = DFHack::MaterialInfo(plant_raw->material_defs.type[plant_material_def::basic_mat], plant_raw->material_defs.idx[plant_material_def::basic_mat]); |
| 260 | |
| 261 | if (basic_mat.material->flags.is_set(material_flags::EDIBLE_RAW) || |
| 262 | basic_mat.material->flags.is_set(material_flags::EDIBLE_COOKED)) { |
| 263 | return Designations::markPlant(plant); |
| 264 | } |
| 265 | |
| 266 | if (plant_raw->flags.is_set(plant_raw_flags::THREAD) || |
| 267 | plant_raw->flags.is_set(plant_raw_flags::MILL) || |
| 268 | plant_raw->flags.is_set(plant_raw_flags::EXTRACT_VIAL) || |
| 269 | plant_raw->flags.is_set(plant_raw_flags::EXTRACT_BARREL) || |
| 270 | plant_raw->flags.is_set(plant_raw_flags::EXTRACT_STILL_VIAL)) { |
| 271 | if (!farming) { |
| 272 | return Designations::markPlant(plant); |
| 273 | } |
| 274 | } |
| 275 | |
| 276 | if (basic_mat.material->reaction_product.id.size() > 0 || |
| 277 | basic_mat.material->reaction_class.size() > 0) { |
| 278 | if (!farming) { |
| 279 | return Designations::markPlant(plant); |
| 280 | } |
| 281 | } |
| 282 | |
| 283 | for (size_t i = 0; i < plant_raw->growths.size(); i++) { |
| 284 | TRACE(log, out).print("growth item type={}\n", ENUM_AS_STR(plant_raw->growths[i]->item_type)); |
| 285 | // Only trees have seed growths in vanilla, but raws can be modded... |
| 286 | if (plant_raw->growths[i]->item_type != df::item_type::SEEDS && |
| 287 | plant_raw->growths[i]->item_type != df::item_type::PLANT_GROWTH) |
| 288 | continue; |
| 289 | |
| 290 | const DFHack::MaterialInfo growth_mat = DFHack::MaterialInfo(plant_raw->growths[i]->mat_type, plant_raw->growths[i]->mat_index); |
| 291 | TRACE(log, out).print("edible_cooked={} edible_raw={} leaf_mat={}\n", |
| 292 | growth_mat.material->flags.is_set(material_flags::EDIBLE_COOKED), |
| 293 | growth_mat.material->flags.is_set(material_flags::EDIBLE_RAW), |
| 294 | growth_mat.material->flags.is_set(material_flags::STOCKPILE_PLANT_GROWTH)); |
| 295 | if (!(plant_raw->growths[i]->item_type == df::item_type::SEEDS && |
| 296 | (growth_mat.material->flags.is_set(material_flags::EDIBLE_COOKED) || |
| 297 | growth_mat.material->flags.is_set(material_flags::EDIBLE_RAW))) && |
| 298 | !(plant_raw->growths[i]->item_type == df::item_type::PLANT_GROWTH && |
| 299 | growth_mat.material->flags.is_set(material_flags::STOCKPILE_PLANT_GROWTH))) |
| 300 | continue; |
| 301 | |
| 302 | bool seedSource = plant_raw->growths[i]->item_type == df::item_type::SEEDS; |
| 303 | |
| 304 | if (plant_raw->growths[i]->item_type == df::item_type::PLANT_GROWTH) { |
| 305 | for (size_t k = 0; growth_mat.material->reaction_product.material.mat_type.size(); k++) { |
| 306 | if (growth_mat.material->reaction_product.material.mat_type[k] == plant_raw->material_defs.type[plant_material_def::seed] && |
no test coverage detected