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

Method disconnectJobItem

library/modules/Job.cpp:346–369  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

344}
345
346void DFHack::Job::disconnectJobItem(df::job *job, df::job_item_ref *item_ref) {
347 if (!item_ref) return;
348
349 auto item = item_ref->item;
350 if (!item) return;
351
352 //Work backward through the specific refs & remove/delete all specific refs to this job
353 int refCount = item->specific_refs.size();
354 bool stillHasJobs = false;
355 for(int refIndex = refCount-1; refIndex >= 0; refIndex--) {
356 auto ref = item->specific_refs[refIndex];
357
358 if (ref->type == df::specific_ref_type::JOB) {
359 if (ref->data.job == job) {
360 vector_erase_at(item->specific_refs, refIndex);
361 delete ref;
362 } else {
363 stillHasJobs = true;
364 }
365 }
366 }
367
368 if (!stillHasJobs) item->flags.bits.in_job = false;
369}
370
371bool DFHack::Job::disconnectJobGeneralRef(df::job *job, df::general_ref *ref) {
372 if (ref == NULL) return true;

Callers

nothing calls this directly

Calls 2

vector_erase_atFunction · 0.85
sizeMethod · 0.45

Tested by

no test coverage detected