| 2281 | } |
| 2282 | |
| 2283 | bool StockpileSettingsSerializer::write_weapons(color_ostream& out, StockpileSettings::WeaponsSet* weapons) { |
| 2284 | auto & pweapons = mSettings->weapons; |
| 2285 | bool all = pweapons.unusable && pweapons.usable; |
| 2286 | |
| 2287 | weapons->set_unusable(pweapons.unusable); |
| 2288 | weapons->set_usable(pweapons.usable); |
| 2289 | |
| 2290 | all = serialize_list_itemdef(out, |
| 2291 | [&](const string& token) { weapons->add_weapon_type(token); }, |
| 2292 | pweapons.weapon_type, |
| 2293 | vector<df::itemdef*>(world->raws.itemdefs.weapons.begin(), world->raws.itemdefs.weapons.end()), |
| 2294 | item_type::WEAPON) && all; |
| 2295 | |
| 2296 | all = serialize_list_itemdef(out, |
| 2297 | [&](const string& token) { weapons->add_trapcomp_type(token); }, |
| 2298 | pweapons.trapcomp_type, |
| 2299 | vector<df::itemdef*>(world->raws.itemdefs.trapcomps.begin(), world->raws.itemdefs.trapcomps.end()), |
| 2300 | item_type::TRAPCOMP) && all; |
| 2301 | |
| 2302 | all = serialize_list_material(out, |
| 2303 | weapons_mat_is_allowed, |
| 2304 | [&](const string& token) { weapons->add_mats(token); }, |
| 2305 | pweapons.mats) && all; |
| 2306 | |
| 2307 | all = serialize_list_other_mats(out, |
| 2308 | mOtherMatsWeaponsArmor.mats, |
| 2309 | [&](const string& token) { weapons->add_other_mats(token); }, |
| 2310 | pweapons.other_mats) && all; |
| 2311 | |
| 2312 | all = serialize_list_quality(out, |
| 2313 | [&](const string& token) { weapons->add_quality_core(token); }, |
| 2314 | pweapons.quality_core) && all; |
| 2315 | |
| 2316 | all = serialize_list_quality(out, |
| 2317 | [&](const string& token) { weapons->add_quality_total(token); }, |
| 2318 | pweapons.quality_total) && all; |
| 2319 | |
| 2320 | return all; |
| 2321 | } |
| 2322 | |
| 2323 | void StockpileSettingsSerializer::read_weapons(color_ostream& out, DeserializeMode mode, const vector<string>& filters) { |
| 2324 | auto & pweapons = mSettings->weapons; |
nothing calls this directly
no test coverage detected