|
|
@ -96,6 +96,20 @@ static void remove_seed_config(color_ostream &out, int id) {
|
|
|
|
watched_seeds.erase(id);
|
|
|
|
watched_seeds.erase(id);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// this validation removes configuration data from versions prior to 50.09-r3
|
|
|
|
|
|
|
|
// it can be removed once saves from 50.09 are no longer loadable
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
static bool validate_seed_config(color_ostream& out, PersistentDataItem c)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
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);
|
|
|
|
|
|
|
|
bool valid = (!plant->flags.is_set(df::enums::plant_raw_flags::TREE));
|
|
|
|
|
|
|
|
if (!valid) {
|
|
|
|
|
|
|
|
DEBUG(config, out).print("invalid configuration for %s discarded\n", plant->id.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return valid;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static const int32_t CYCLE_TICKS = 1200;
|
|
|
|
static const int32_t CYCLE_TICKS = 1200;
|
|
|
|
static int32_t cycle_timestamp = 0; // world->frame_counter at last cycle
|
|
|
|
static int32_t cycle_timestamp = 0; // world->frame_counter at last cycle
|
|
|
|
|
|
|
|
|
|
|
@ -171,7 +185,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,6 +196,7 @@ 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];
|
|
|
|
|
|
|
|
if (validate_seed_config(out, c))
|
|
|
|
watched_seeds.emplace(get_config_val(c, SEED_CONFIG_ID), c);
|
|
|
|
watched_seeds.emplace(get_config_val(c, SEED_CONFIG_ID), c);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|