MCPcopy Create free account
hub / github.com/DFHack/dfhack / serialize_list_itemdef

Function serialize_list_itemdef

plugins/stockpiles/StockpileSerializer.cpp:273–294  ·  view source on GitHub ↗

* There are many repeated (un)serialization cases throughout the stockpile_settings structure, * so the most common cases have been generalized into generic functions using lambdas. * * The basic process to serialize a stockpile_settings structure is: * 1. loop through the list * 2. for every element that is TRUE: * 3. map the specific stockpile_settings index into a general material, crea

Source from the content-addressed store, hash-verified

271 * The unserialization process is the same in reverse.
272 */
273static bool serialize_list_itemdef(color_ostream& out, FuncWriteExport add_value,
274 vector<char> list,
275 vector<df::itemdef*> items,
276 item_type::item_type type) {
277 bool all = true;
278 for (size_t i = 0; i < list.size(); ++i) {
279 if (!list.at(i)) {
280 all = false;
281 continue;
282 }
283 const df::itemdef* a = items.at(i);
284 // skip procedurally generated items
285 if (a->base_flags.is_set(df::itemdef_flags::GENERATED))
286 continue;
287 ItemTypeInfo ii;
288 if (!ii.decode(type, i))
289 continue;
290 DEBUG(log, out).print("adding itemdef type {}\n", ii.getToken());
291 add_value(ii.getToken());
292 }
293 return all;
294}
295
296static void unserialize_list_itemdef(color_ostream& out, const char* subcat, bool all, char val, const vector<string>& filters,
297 FuncReadImport read_value, int32_t list_size, vector<char>& pile_list, item_type::item_type type) {

Callers 3

write_ammoMethod · 0.85
write_armorMethod · 0.85
write_weaponsMethod · 0.85

Calls 6

add_valueFunction · 0.85
is_setMethod · 0.80
sizeMethod · 0.45
decodeMethod · 0.45
printMethod · 0.45
getTokenMethod · 0.45

Tested by

no test coverage detected