| 979 | } |
| 980 | |
| 981 | bool StockpileSettingsSerializer::write_ammo(color_ostream& out, StockpileSettings::AmmoSet* ammo) { |
| 982 | bool all = serialize_list_itemdef(out, |
| 983 | [&](const string& token) { ammo->add_type(token); }, |
| 984 | mSettings->ammo.type, |
| 985 | vector<df::itemdef*>(world->raws.itemdefs.ammo.begin(), world->raws.itemdefs.ammo.end()), |
| 986 | item_type::AMMO); |
| 987 | |
| 988 | all = serialize_list_material(out, |
| 989 | ammo_mat_is_allowed, |
| 990 | [&](const string& token) { ammo->add_mats(token); }, |
| 991 | mSettings->ammo.mats) && all; |
| 992 | |
| 993 | if (mSettings->ammo.other_mats.size() > 2) { |
| 994 | WARN(log, out).print("ammo other materials > 2: {}\n", |
| 995 | mSettings->ammo.other_mats.size()); |
| 996 | } |
| 997 | |
| 998 | size_t num_other_mats = std::min(size_t(2), |
| 999 | mSettings->ammo.other_mats.size()); |
| 1000 | for (size_t i = 0; i < num_other_mats; ++i) { |
| 1001 | if (!mSettings->ammo.other_mats.at(i)) { |
| 1002 | all = false; |
| 1003 | continue; |
| 1004 | } |
| 1005 | const string token = i == 0 ? "WOOD" : "BONE"; |
| 1006 | ammo->add_other_mats(token); |
| 1007 | DEBUG(log, out).print("other mats {} is {}\n", i, token); |
| 1008 | } |
| 1009 | |
| 1010 | all = serialize_list_quality(out, |
| 1011 | [&](const string& token) { ammo->add_quality_core(token); }, |
| 1012 | mSettings->ammo.quality_core) && all; |
| 1013 | |
| 1014 | all = serialize_list_quality(out, |
| 1015 | [&](const string& token) { ammo->add_quality_total(token); }, |
| 1016 | mSettings->ammo.quality_total) && all; |
| 1017 | |
| 1018 | return all; |
| 1019 | } |
| 1020 | |
| 1021 | void StockpileSettingsSerializer::read_ammo(color_ostream& out, DeserializeMode mode, const vector<string>& filters) { |
| 1022 | auto & pammo = mSettings->ammo; |
nothing calls this directly
no test coverage detected