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

Function orders_export_command

plugins/orders.cpp:307–514  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

305}
306
307static command_result orders_export_command(color_ostream & out, const std::string & name)
308{
309 if (!is_safe_filename(out, name))
310 {
311 return CR_WRONG_USAGE;
312 }
313
314 Json::Value orders(Json::arrayValue);
315
316 for (auto it : world->manager_orders.all)
317 {
318 Json::Value order(Json::objectValue);
319
320 order["id"] = it->id;
321 order["job"] = enum_item_key(it->job_type);
322 if (!it->reaction_name.empty())
323 {
324 order["reaction"] = it->reaction_name;
325 }
326
327 if (it->item_type != item_type::NONE)
328 {
329 order["item_type"] = enum_item_key(it->item_type);
330 }
331 if (it->item_subtype != -1)
332 {
333 df::itemdef *def = get_itemdef(out, it->item_type == item_type::NONE ? ENUM_ATTR(job_type, item, it->job_type) : it->item_type, it->item_subtype);
334
335 if (def)
336 {
337 order["item_subtype"] = def->id;
338 }
339 }
340
341 if (it->job_type == job_type::PrepareMeal)
342 {
343 order["meal_ingredients"] = it->mat_type;
344 }
345 else if (it->mat_type != -1 || it->mat_index != -1)
346 {
347 order["material"] = MaterialInfo(it).getToken();
348 }
349
350 if (it->specflag.encrust_flags.whole != 0)
351 {
352 bitfield_to_json_array(order["item_category"], it->specflag.encrust_flags);
353 }
354
355 if (it->specdata.hist_figure_id != -1)
356 {
357 order["hist_figure"] = it->specdata.hist_figure_id;
358 }
359
360 if (it->material_category.whole != 0)
361 {
362 bitfield_to_json_array(order["material_category"], it->material_category);
363 }
364

Callers 1

orders_commandFunction · 0.85

Calls 8

is_safe_filenameFunction · 0.85
enum_item_keyFunction · 0.85
get_itemdefFunction · 0.85
bitfield_to_json_arrayFunction · 0.85
MaterialInfoClass · 0.50
findFunction · 0.50
emptyMethod · 0.45
getTokenMethod · 0.45

Tested by

no test coverage detected