use new default_item_filters structure

so vector references aren't to items on the stack
also don't let query mode swallow all input
develop
Myk Taylor 2020-10-04 23:53:42 -07:00
parent 4d7f4d80ad
commit 5087b6d2ae
3 changed files with 10 additions and 9 deletions

@ -439,7 +439,7 @@ void Planner::initialize()
void Planner::reset()
{
debug("resetting Planner state");
item_filters.clear();
default_item_filters.clear();
planned_buildings.clear();
std::vector<PersistentDataItem> items;
@ -549,9 +549,9 @@ Planner::ItemFiltersWrapper Planner::getItemFilters(BuildingTypeKey key)
int nfilters = getNumFilters(key);
if (nfilters < 1)
return empty_ret;
std::vector<ItemFilter> ret;
ret.push_back(item_filters[std::get<0>(key)]);
return ItemFiltersWrapper(ret);
while (default_item_filters[key].size() < nfilters)
default_item_filters[key].push_back(ItemFilter());
return ItemFiltersWrapper(default_item_filters[key]);
}
void Planner::doCycle()

@ -119,7 +119,9 @@ public:
private:
std::map<df::building_type, df::item_type> item_for_building_type;
std::map<df::building_type, ItemFilter> item_filters;
std::unordered_map<BuildingTypeKey,
std::vector<ItemFilter>,
BuildingTypeKeyHash> default_item_filters;
std::map<df::item_type, std::vector<df::item *>> available_item_vectors;
std::map<df::item_type, bool> is_relevant_item_type; //Needed for fast check when looping over all items
std::vector<PlannedBuilding> planned_buildings;

@ -309,13 +309,12 @@ struct buildingplan_query_hook : public df::viewscreen_dwarfmodest
return true; // Don't unsuspend planned buildings
if (input->count(interface_key::DESTROYBUILDING))
{
// remove persistent data
// remove persistent data and allow the parent to handle the key
// so the building is removed
planner.getPlannedBuilding(world->selected_building)->remove();
// still allow the building to be removed
return false;
}
return true;
return false;
}
DEFINE_VMETHOD_INTERPOSE(void, feed, (set<df::interface_key> *input))