From de0e211e07dbc0e044096efbaf783d31d9759046 Mon Sep 17 00:00:00 2001 From: Stephen Baynham Date: Thu, 24 Nov 2016 23:35:03 -0800 Subject: [PATCH] Figured I could like test my code. --- library/modules/Job.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/library/modules/Job.cpp b/library/modules/Job.cpp index b1f262f09..531c85773 100644 --- a/library/modules/Job.cpp +++ b/library/modules/Job.cpp @@ -332,9 +332,12 @@ void DFHack::Job::disconnectJobItem(df::job_item_ref *ref, df::job *job) { bool DFHack::Job::disconnectJobGeneralRef(df::general_ref *ref, df::job *job) { if (ref == NULL) return true; + df::building *building = NULL; + df::unit *unit = NULL; + switch (ref->getType()) { case general_ref_type::BUILDING_HOLDER: - auto building = ref->getBuilding(); + building = ref->getBuilding(); if (building != NULL) { int jobIndex = linear_index(building->jobs, job); @@ -344,7 +347,7 @@ bool DFHack::Job::disconnectJobGeneralRef(df::general_ref *ref, df::job *job) { } break; case general_ref_type::UNIT_WORKER: - auto unit = ref->getUnit(); + unit = ref->getUnit(); if (unit != NULL) { if (unit->job.current_job == job) { @@ -385,7 +388,9 @@ bool DFHack::Job::removeJob(df::job *job) { //Our code above should have ensured that this won't return false- if it does, there's not //a great way of recovering since we can't properly destroy the job & we can't leave it //around. Better to know the moment that becomes a problem. - assert(disconnectJobGeneralRef(ref, job)); + bool success = disconnectJobGeneralRef(ref, job); + assert(success); + vector_erase_at(job->general_refs, 0); if (ref != NULL) delete ref; }