| 369 | } |
| 370 | |
| 371 | bool DFHack::Job::disconnectJobGeneralRef(df::job *job, df::general_ref *ref) { |
| 372 | if (ref == NULL) return true; |
| 373 | |
| 374 | df::building *building = NULL; |
| 375 | df::unit *unit = NULL; |
| 376 | |
| 377 | switch (ref->getType()) { |
| 378 | case general_ref_type::BUILDING_HOLDER: |
| 379 | building = ref->getBuilding(); |
| 380 | |
| 381 | if (building != NULL) { |
| 382 | int jobIndex = linear_index(building->jobs, job); |
| 383 | if (jobIndex >= 0) { |
| 384 | vector_erase_at(building->jobs, jobIndex); |
| 385 | } |
| 386 | } |
| 387 | break; |
| 388 | case general_ref_type::UNIT_WORKER: |
| 389 | unit = ref->getUnit(); |
| 390 | |
| 391 | if (unit != NULL) { |
| 392 | if (unit->job.current_job == job) { |
| 393 | unit->job.current_job = NULL; |
| 394 | } |
| 395 | } |
| 396 | break; |
| 397 | default: |
| 398 | return false; |
| 399 | } |
| 400 | |
| 401 | return true; |
| 402 | } |
| 403 | |
| 404 | bool DFHack::Job::removeJob(df::job* job) { |
| 405 | using df::global::world; |
nothing calls this directly
no test coverage detected