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

Function job_cmd

plugins/jobutils.cpp:292–391  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

290}
291
292static command_result job_cmd(color_ostream &out, vector <string> & parameters)
293{
294 std::string cmd = (parameters.empty() ? "query" : parameters[0]);
295 if (cmd == "query" || cmd == "list")
296 {
297 df::job *job = Gui::getSelectedJob(out);
298 if (!job)
299 return CR_WRONG_USAGE;
300
301 if (cmd == "query") {
302 Job::printJobDetails(out, job);
303 } else {
304 if (!Gui::workshop_job_hotkey(Core::getTopViewscreen()))
305 return CR_WRONG_USAGE;
306
307 df::building *selected = world->selected_building;
308 for (size_t i = 0; i < selected->jobs.size(); i++)
309 Job::printJobDetails(out, selected->jobs[i]);
310 }
311 }
312 else if (cmd == "item-material")
313 {
314 if (parameters.size() != 3)
315 return CR_WRONG_USAGE;
316
317 df::job *job = Gui::getSelectedJob(out);
318 df::job_item *item = getJobItem(out, job, parameters[1]);
319 if (!item)
320 return CR_WRONG_USAGE;
321
322 ItemTypeInfo iinfo(item);
323 MaterialInfo minfo;
324
325 if (!minfo.find(parameters[2])) {
326 out.printerr("Could not find the specified material.\n");
327 return CR_FAILURE;
328 }
329
330 if (minfo.isValid() && !iinfo.matches(*item, &minfo)) {
331 out.printerr("Material does not match the requirements.\n");
332 Job::printJobDetails(out, job);
333 return CR_FAILURE;
334 }
335
336 if (job->mat_type != -1 &&
337 job->mat_type == item->mat_type &&
338 job->mat_index == item->mat_index)
339 {
340 job->mat_type = minfo.type;
341 job->mat_index = minfo.index;
342 }
343
344 item->mat_type = minfo.type;
345 item->mat_index = minfo.index;
346
347 out << "Job item updated." << endl;
348
349 if (item->item_type < (df::item_type)0 && minfo.isValid())

Callers

nothing calls this directly

Calls 7

getSelectedJobFunction · 0.85
getJobItemFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45
findMethod · 0.45
isValidMethod · 0.45
matchesMethod · 0.45

Tested by

no test coverage detected