seedwatch: ignore tree seeds

develop
Kelly Kinkade 2023-08-29 22:23:13 -05:00
parent f2a5d82b90
commit fa9d2e2175
2 changed files with 10 additions and 3 deletions

@ -30,6 +30,7 @@ Template for new versions:
## Fixes ## Fixes
- `tailor`: remove crash caused by clothing items with an invalid ``maker_race`` - `tailor`: remove crash caused by clothing items with an invalid ``maker_race``
- `seedwatch`: seedwatch will now ignore tree seeds entirely
## Misc Improvements ## Misc Improvements

@ -171,7 +171,8 @@ DFhackCExport command_result plugin_load_data (color_ostream &out) {
world_plant_ids.clear(); world_plant_ids.clear();
for (size_t i = 0; i < world->raws.plants.all.size(); ++i) { for (size_t i = 0; i < world->raws.plants.all.size(); ++i) {
auto & plant = world->raws.plants.all[i]; auto & plant = world->raws.plants.all[i];
if (plant->material_defs.type[plant_material_def::seed] != -1) if (plant->material_defs.type[plant_material_def::seed] != -1 &&
!plant->flags.is_set(df::enums::plant_raw_flags::TREE))
world_plant_ids[plant->id] = i; world_plant_ids[plant->id] = i;
} }
@ -181,7 +182,12 @@ DFhackCExport command_result plugin_load_data (color_ostream &out) {
const size_t num_seed_configs = seed_configs.size(); const size_t num_seed_configs = seed_configs.size();
for (size_t idx = 0; idx < num_seed_configs; ++idx) { for (size_t idx = 0; idx < num_seed_configs; ++idx) {
auto& c = seed_configs[idx]; auto& c = seed_configs[idx];
int seed_id = get_config_val(c, SEED_CONFIG_ID);
auto plant = binsearch_in_vector(world->raws.plants.all, &df::plant_raw::index, seed_id);
if (!plant->flags.is_set(df::enums::plant_raw_flags::TREE))
watched_seeds.emplace(get_config_val(c, SEED_CONFIG_ID), c); watched_seeds.emplace(get_config_val(c, SEED_CONFIG_ID), c);
else
DEBUG(config, out).print("reference to tree seed in saved config discarded\n");
} }
config = World::GetPersistentData(CONFIG_KEY); config = World::GetPersistentData(CONFIG_KEY);