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

Function link_job_constraint

plugins/workflow.cpp:815–863  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

813}
814
815static void link_job_constraint(ProtectedJob *pj, df::item_type itype, int16_t isubtype,
816 df::dfhack_material_category mat_mask,
817 int16_t mat_type, int32_t mat_index,
818 bool is_craft = false)
819{
820 MaterialInfo mat(mat_type, mat_index);
821
822 for (size_t i = 0; i < constraints.size(); i++)
823 {
824 ItemConstraint *ct = constraints[i];
825
826 if (is_craft)
827 {
828 if (!ct->is_craft && !isCraftItem(ct->item.type))
829 continue;
830 }
831 else
832 {
833 if (ct->item.type != itype ||
834 (ct->item.subtype != -1 && ct->item.subtype != isubtype))
835 continue;
836 }
837
838 if (!mat.matches(ct->material))
839 continue;
840 if (ct->mat_mask.whole)
841 {
842 if (mat.isValid())
843 {
844 if (!mat.matches(ct->mat_mask))
845 continue;
846 }
847 else
848 {
849 if (!(mat_mask.whole & ct->mat_mask.whole))
850 continue;
851 }
852 }
853
854 if (linear_index(pj->constraints, ct) >= 0)
855 continue;
856
857 ct->jobs.push_back(pj);
858 pj->constraints.push_back(ct);
859
860 if (!ct->is_active && pj->isResumed())
861 ct->is_active = true;
862 }
863}
864
865static void guess_job_material(df::job *job, MaterialInfo &mat, df::dfhack_material_category &mat_mask)
866{

Callers 1

cbEnumJobOutputsFunction · 0.85

Calls 6

isCraftItemFunction · 0.85
isResumedMethod · 0.80
linear_indexFunction · 0.50
sizeMethod · 0.45
matchesMethod · 0.45
isValidMethod · 0.45

Tested by

no test coverage detected