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

Function job_duplicate

plugins/jobutils.cpp:242–274  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

240/* job-duplicate implementation */
241
242static command_result job_duplicate(color_ostream &out, vector <string> & parameters)
243{
244 if (!parameters.empty())
245 return CR_WRONG_USAGE;
246
247 df::job *job = Gui::getSelectedWorkshopJob(out);
248 if (!job)
249 return CR_FAILURE;
250
251 if (!job->specific_refs.empty() ||
252 (job->job_items.elements.empty() &&
253 job->job_type != job_type::CollectSand &&
254 job->job_type != job_type::CollectClay))
255 {
256 out.printerr("Cannot duplicate job {}\n", ENUM_KEY_STR(job_type,job->job_type));
257 return CR_FAILURE;
258 }
259
260 df::building *building = world->selected_building;
261 if (building->jobs.size() >= 10)
262 {
263 out.printerr("Job list is already full.\n");
264 return CR_FAILURE;
265 }
266
267 // Actually clone
268 df::job *pnew = Job::cloneJobStruct(job);
269
270 Job::linkIntoWorld(pnew);
271 vector_insert_at(building->jobs, ++*ui_workshop_job_cursor, pnew);
272
273 return CR_OK;
274}
275
276/* Main job command implementation */
277

Callers

nothing calls this directly

Calls 3

vector_insert_atFunction · 0.85
emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected