bounds check the choice data

old forts that persisted data before this attribute existed will have an
invalid value
develop
Myk Taylor 2023-03-29 15:09:18 -07:00
parent 12e7ae1207
commit 0db93762cf
No known key found for this signature in database
1 changed files with 3 additions and 0 deletions

@ -57,6 +57,9 @@ DefaultItemFilters::DefaultItemFilters(color_ostream &out, BuildingTypeKey key,
DefaultItemFilters::DefaultItemFilters(color_ostream &out, PersistentDataItem &filter_config, const std::vector<const df::job_item *> &jitems) DefaultItemFilters::DefaultItemFilters(color_ostream &out, PersistentDataItem &filter_config, const std::vector<const df::job_item *> &jitems)
: key(getKey(filter_config)), filter_config(filter_config) { : key(getKey(filter_config)), filter_config(filter_config) {
choose_items = get_config_val(filter_config, FILTER_CONFIG_CHOOSE_ITEMS); choose_items = get_config_val(filter_config, FILTER_CONFIG_CHOOSE_ITEMS);
if (choose_items < ItemSelectionChoice::ITEM_SELECTION_CHOICE_FILTER ||
choose_items > ItemSelectionChoice::ITEM_SELECTION_CHOICE_AUTOMATERIAL)
choose_items = ItemSelectionChoice::ITEM_SELECTION_CHOICE_FILTER;
auto &serialized = filter_config.val(); auto &serialized = filter_config.val();
DEBUG(status,out).print("deserializing default item filters for key %d,%d,%d: %s\n", DEBUG(status,out).print("deserializing default item filters for key %d,%d,%d: %s\n",
std::get<0>(key), std::get<1>(key), std::get<2>(key), serialized.c_str()); std::get<0>(key), std::get<1>(key), std::get<2>(key), serialized.c_str());