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

Method setJobCooldown

library/modules/Job.cpp:322–344  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

320}
321
322void DFHack::Job::setJobCooldown(df::building *workshop, df::unit *worker, int cooldown)
323{
324 CHECK_NULL_POINTER(workshop);
325 CHECK_NULL_POINTER(worker);
326
327 if (cooldown <= 0)
328 return;
329
330 int idx = linear_index(workshop->job_claim_suppress, &df::job_restrictionst::unit, worker);
331
332 if (idx < 0)
333 {
334 auto obj = new df::job_restrictionst;
335 obj->unit = worker;
336 obj->timer = cooldown;
337 workshop->job_claim_suppress.push_back(obj);
338 }
339 else
340 {
341 auto obj = workshop->job_claim_suppress[idx];
342 obj->timer = std::max(obj->timer, cooldown);
343 }
344}
345
346void DFHack::Job::disconnectJobItem(df::job *job, df::job_item_ref *item_ref) {
347 if (!item_ref) return;

Callers

nothing calls this directly

Calls 1

linear_indexFunction · 0.50

Tested by

no test coverage detected