| 344 | } |
| 345 | |
| 346 | void 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 | |
| 371 | bool DFHack::Job::disconnectJobGeneralRef(df::job *job, df::general_ref *ref) { |
| 372 | if (ref == NULL) return true; |
nothing calls this directly
no test coverage detected