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

Function is_valid_item

plugins/autochop.cpp:461–490  ·  view source on GitHub ↗

TODO: does this actually catch anything above the bad_flag check?

Source from the content-addressed store, hash-verified

459
460// TODO: does this actually catch anything above the bad_flag check?
461static bool is_valid_item(df::item *item) {
462 for (size_t i = 0; i < item->general_refs.size(); i++) {
463 df::general_ref *ref = item->general_refs[i];
464
465 switch (ref->getType()) {
466 case general_ref_type::CONTAINED_IN_ITEM:
467 return false;
468
469 case general_ref_type::UNIT_HOLDER:
470 return false;
471
472 case general_ref_type::BUILDING_HOLDER:
473 return false;
474
475 default:
476 break;
477 }
478 }
479
480 for (size_t i = 0; i < item->specific_refs.size(); i++) {
481 df::specific_ref *ref = item->specific_refs[i];
482
483 if (ref->type == specific_ref_type::JOB) {
484 // Ignore any items assigned to a job
485 return false;
486 }
487 }
488
489 return true;
490}
491
492struct BadFlags
493{

Callers 1

scan_logsFunction · 0.85

Calls 2

getTypeMethod · 0.80
sizeMethod · 0.45

Tested by

no test coverage detected