Merge pull request #3753 from myk002/myk_seedwatch

[seedwatch] fix crash on bad seed ids in configs
develop
Myk 2023-09-09 11:11:39 -07:00 committed by GitHub
commit fa36194f2b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 1 deletions

@ -57,6 +57,7 @@ Template for new versions:
## Fixes
- `buildingplan`: make the construction dimensions readout visible again
- `seedwatch`: fix a crash when reading data saved by very very old versions of the plugin
## Misc Improvements
- `sort`: sort by need for training on squad assignment screen

@ -102,7 +102,11 @@ static void remove_seed_config(color_ostream &out, int id) {
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);
auto plant = df::plant_raw::find(seed_id);
if (!plant) {
WARN(config, out).print("discarded invalid seed id: %d\n", seed_id);
return false;
}
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());