| 2321 | } |
| 2322 | |
| 2323 | void StockpileSettingsSerializer::read_weapons(color_ostream& out, DeserializeMode mode, const vector<string>& filters) { |
| 2324 | auto & pweapons = mSettings->weapons; |
| 2325 | read_category<StockpileSettings_WeaponsSet>(out, "weapons", mode, |
| 2326 | std::bind(&StockpileSettings::has_weapons, mBuffer), |
| 2327 | std::bind(&StockpileSettings::weapons, mBuffer), |
| 2328 | mSettings->flags.whole, |
| 2329 | mSettings->flags.mask_weapons, |
| 2330 | [&]() { |
| 2331 | pweapons.unusable = false; |
| 2332 | pweapons.usable = false; |
| 2333 | pweapons.weapon_type.clear(); |
| 2334 | pweapons.trapcomp_type.clear(); |
| 2335 | pweapons.other_mats.clear(); |
| 2336 | pweapons.mats.clear(); |
| 2337 | quality_clear(pweapons.quality_core); |
| 2338 | quality_clear(pweapons.quality_total); |
| 2339 | }, |
| 2340 | [&](bool all, char val) { |
| 2341 | auto & bweapons = mBuffer.weapons(); |
| 2342 | |
| 2343 | set_flag(out, "nouse", filters, all, val, bweapons.unusable(), pweapons.unusable); |
| 2344 | set_flag(out, "canuse", filters, all, val, bweapons.usable(), pweapons.usable); |
| 2345 | |
| 2346 | unserialize_list_itemdef(out, "type/weapon", all, val, filters, |
| 2347 | [&](const size_t& idx) -> const string& { return bweapons.weapon_type(idx); }, |
| 2348 | bweapons.weapon_type_size(), pweapons.weapon_type, item_type::WEAPON); |
| 2349 | |
| 2350 | unserialize_list_itemdef(out, "type/trapcomp", all, val, filters, |
| 2351 | [&](const size_t& idx) -> const string& { return bweapons.trapcomp_type(idx); }, |
| 2352 | bweapons.trapcomp_type_size(), pweapons.trapcomp_type, item_type::TRAPCOMP); |
| 2353 | |
| 2354 | unserialize_list_material(out, "mats", all, val, filters, weapons_mat_is_allowed, |
| 2355 | [&](const size_t& idx) -> const string& { return bweapons.mats(idx); }, |
| 2356 | bweapons.mats_size(), pweapons.mats); |
| 2357 | |
| 2358 | unserialize_list_other_mats(out, "other", all, val, filters, mOtherMatsWeaponsArmor.mats, |
| 2359 | [&](const size_t& idx) -> const string& { return bweapons.other_mats(idx); }, |
| 2360 | bweapons.other_mats_size(), pweapons.other_mats); |
| 2361 | |
| 2362 | unserialize_list_quality(out, "core", all, val, filters, |
| 2363 | [&](const size_t& idx) -> const string& { return bweapons.quality_core(idx); }, |
| 2364 | bweapons.quality_core_size(), pweapons.quality_core); |
| 2365 | |
| 2366 | unserialize_list_quality(out, "total", all, val, filters, |
| 2367 | [&](const size_t& idx) -> const string& { return bweapons.quality_total(idx); }, |
| 2368 | bweapons.quality_total_size(), pweapons.quality_total); |
| 2369 | }); |
| 2370 | } |
| 2371 | |
| 2372 | static bool wood_mat_is_allowed(const df::plant_raw* plant) { |
| 2373 | return plant && plant->flags.is_set(plant_raw_flags::TREE); |
nothing calls this directly
no test coverage detected