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

Method attachJobItem

library/modules/Job.cpp:602–637  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

600}
601
602bool DFHack::Job::attachJobItem(df::job *job, df::item *item,
603 df::job_role_type role,
604 int filter_idx, int insert_idx)
605{
606 CHECK_NULL_POINTER(job);
607 CHECK_NULL_POINTER(item);
608
609 /*
610 * Functionality 100% reverse-engineered from DF code.
611 */
612
613 if (role != df::job_role_type::TargetContainer)
614 {
615 if (item->flags.bits.in_job)
616 return false;
617
618 item->flags.bits.in_job = true;
619 }
620
621 auto item_link = new df::specific_ref();
622 item_link->type = specific_ref_type::JOB;
623 item_link->data.job = job;
624 item->specific_refs.push_back(item_link);
625
626 auto job_link = new df::job_item_ref();
627 job_link->item = item;
628 job_link->role = role;
629 job_link->job_item_idx = filter_idx;
630
631 if (size_t(insert_idx) < job->items.size())
632 vector_insert_at(job->items, insert_idx, job_link);
633 else
634 job->items.push_back(job_link);
635
636 return true;
637}
638
639bool Job::isSuitableItem(const df::job_item *jitem, df::item_type itype, int isubtype)
640{

Callers

nothing calls this directly

Calls 2

vector_insert_atFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected