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

Function job_material_in_build

plugins/jobutils.cpp:193–217  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

191}
192
193static command_result job_material_in_build(color_ostream &out, MaterialInfo &new_mat)
194{
195 df::ui_build_selector *sel = ui_build_selector;
196 df::ui_build_item_req *req = sel->requirements[ui_build_selector->req_index];
197
198 // Loop through matching choices
199 bool matches = build_choice_matches(req, sel->choices[sel->sel_index], new_mat, true);
200
201 size_t size = sel->choices.size();
202 int base = (matches ? sel->sel_index + 1 : 0);
203
204 for (size_t i = 0; i < size; i++)
205 {
206 int idx = (base + i) % size;
207
208 if (build_choice_matches(req, sel->choices[idx], new_mat, false))
209 {
210 sel->sel_index = idx;
211 return CR_OK;
212 }
213 }
214
215 out.printerr("Could not find material in list: {}\n", new_mat.toString());
216 return CR_FAILURE;
217}
218
219static command_result job_material(color_ostream &out, vector <string> & parameters)
220{

Callers 1

job_materialFunction · 0.85

Calls 3

build_choice_matchesFunction · 0.85
sizeMethod · 0.45
toStringMethod · 0.45

Tested by

no test coverage detected