MCPcopy Create free account
hub / github.com/DFHack/dfhack / command_result plugin_load_site_data

Function command_result plugin_load_site_data

plugins/autoclothing.cpp:237–263  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

235}
236
237DFhackCExport command_result plugin_load_site_data(color_ostream &out) {
238 cycle_timestamp = 0;
239 auto enabled = World::GetPersistentSiteData(CONFIG_KEY);
240 if (!enabled.isValid()) {
241 DEBUG(control, out).print("no config found in this save; initializing\n");
242 enabled = World::AddPersistentSiteData(CONFIG_KEY);
243 enabled.set_bool(CONFIG_IS_ENABLED, is_enabled);
244 }
245
246 is_enabled = enabled.get_bool(CONFIG_IS_ENABLED);
247 DEBUG(control, out).print("loading persisted enabled state: {}\n",
248 is_enabled ? "true" : "false");
249
250 // Parse constraints
251 vector<PersistentDataItem> items;
252 World::GetPersistentSiteData(&items, "autoclothing/clothingItems");
253
254 for (auto &item : items) {
255 if (!item.isValid())
256 continue;
257 ClothingRequirement req;
258 req.Deserialize(item.get_str());
259 clothingOrders.push_back(req);
260 out << "autoclothing added " << req.ToReadableLabel() << endl;
261 }
262 return CR_OK;
263}
264
265DFhackCExport command_result plugin_save_site_data(color_ostream &out) {
266 for (auto &order : clothingOrders)

Callers

nothing calls this directly

Calls 4

DeserializeMethod · 0.80
ToReadableLabelMethod · 0.80
isValidMethod · 0.45
printMethod · 0.45

Tested by

no test coverage detected