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

Method disconnectJobGeneralRef

library/modules/Job.cpp:371–402  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

369}
370
371bool 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
404bool DFHack::Job::removeJob(df::job* job) {
405 using df::global::world;

Callers

nothing calls this directly

Calls 3

vector_erase_atFunction · 0.85
getTypeMethod · 0.80
linear_indexFunction · 0.50

Tested by

no test coverage detected