From 654f798b83ea51a4777a42ccd275be2c4dc1aa11 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Fri, 8 Jun 2018 11:08:35 +0200 Subject: [PATCH 01/11] dead/killed flags --- plugins/advtools.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/advtools.cpp b/plugins/advtools.cpp index 50868560d..594b6cfe4 100644 --- a/plugins/advtools.cpp +++ b/plugins/advtools.cpp @@ -482,7 +482,7 @@ static void printCompanionHeader(color_ostream &out, size_t i, df::unit *unit) out << i; out << ": " << getUnitNameProfession(unit); - if (unit->flags1.bits.dead) + if (unit->flags2.bits.killed) out << " (DEAD)"; if (unit->flags3.bits.ghostly) out << " (GHOST)"; From 0ec3df6022b5b999f5371cab0f11eb3991a178f5 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Fri, 8 Jun 2018 11:09:11 +0200 Subject: [PATCH 02/11] dead/killed flags --- plugins/cursecheck.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/plugins/cursecheck.cpp b/plugins/cursecheck.cpp index e006bd17c..4a36f4841 100644 --- a/plugins/cursecheck.cpp +++ b/plugins/cursecheck.cpp @@ -160,8 +160,9 @@ command_result cursecheck (color_ostream &out, vector & parameters) { df::unit * unit = world->units.all[i]; + // filter out all "living" units that are currently removed from play // don't spam all completely dead creatures if not explicitly wanted - if(unit->flags1.bits.dead && ignoreDead) + if((unit->flags1.bits.dead && !unit->flags2.bits.killed) || (unit->flags2.bits.killed && ignoreDead)) { continue; } @@ -217,7 +218,7 @@ command_result cursecheck (color_ostream &out, vector & parameters) cursetype.c_str(), // technically most cursed creatures are undead, // therefore output 'active' if they are not completely dead - unit->flags1.bits.dead ? "deceased" : "active", + unit->flags2.bits.killed ? "deceased" : "active", unit->flags3.bits.ghostly ? "-ghostly" : "", missing ? "-missing" : "" ); From 897a818f4c3dd7ea9914ad9f78591ac112a8fab8 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 09:42:45 +0200 Subject: [PATCH 03/11] Switch to Units functions --- plugins/cursecheck.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/cursecheck.cpp b/plugins/cursecheck.cpp index 4a36f4841..dd820cd35 100644 --- a/plugins/cursecheck.cpp +++ b/plugins/cursecheck.cpp @@ -162,7 +162,7 @@ command_result cursecheck (color_ostream &out, vector & parameters) // filter out all "living" units that are currently removed from play // don't spam all completely dead creatures if not explicitly wanted - if((unit->flags1.bits.dead && !unit->flags2.bits.killed) || (unit->flags2.bits.killed && ignoreDead)) + if((!Units::isActive(unit) && !Units::isKilled(unit)) || (Units::isKilled(unit) && ignoreDead)) { continue; } From 6901c53bd5c3eb722007934e746cccb0fa4569f8 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:29:48 +0200 Subject: [PATCH 04/11] dead flag -> !isActive --- plugins/advtools.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/advtools.cpp b/plugins/advtools.cpp index 594b6cfe4..a1965cba0 100644 --- a/plugins/advtools.cpp +++ b/plugins/advtools.cpp @@ -482,9 +482,9 @@ static void printCompanionHeader(color_ostream &out, size_t i, df::unit *unit) out << i; out << ": " << getUnitNameProfession(unit); - if (unit->flags2.bits.killed) + if (Units::isDead(unit)) out << " (DEAD)"; - if (unit->flags3.bits.ghostly) + if (Units::isGhost(unit)) out << " (GHOST)"; out << endl; From aa361f3a0d1f9c4e785aca57043cf17f1c31cdee Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:30:41 +0200 Subject: [PATCH 05/11] dead flag -> !isActive --- plugins/diggingInvaders/diggingInvaders.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/diggingInvaders/diggingInvaders.cpp b/plugins/diggingInvaders/diggingInvaders.cpp index 9bbc5191e..88eed55e6 100644 --- a/plugins/diggingInvaders/diggingInvaders.cpp +++ b/plugins/diggingInvaders/diggingInvaders.cpp @@ -389,7 +389,7 @@ void findAndAssignInvasionJob(color_ostream& out, void* tickTime) { //find all locals and invaders for ( size_t a = 0; a < world->units.all.size(); a++ ) { df::unit* unit = world->units.all[a]; - if ( unit->flags1.bits.dead ) + if ( !Units::isActive(unit) ) continue; if ( Units::isCitizen(unit) ) { if ( localPts.find(unit->pos) != localPts.end() ) From da0aa85b05e855d36d9c30b619ef0f0a370659ec Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:31:15 +0200 Subject: [PATCH 06/11] dead flag -> !isActive --- plugins/dwarfvet.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/dwarfvet.cpp b/plugins/dwarfvet.cpp index 19f00e888..c4a97b629 100644 --- a/plugins/dwarfvet.cpp +++ b/plugins/dwarfvet.cpp @@ -383,7 +383,7 @@ void AnimalHospital::processPatients(color_ostream &out) { } // Check to make sure the unit hasn't expired before assigning a job, or if they've been healed - if (!real_unit || real_unit->flags1.bits.dead || !real_unit->health->flags.bits.needs_healthcare) { + if (!real_unit || !Units::isActive(real_unit) || !real_unit->health->flags.bits.needs_healthcare) { // discharge the patient from the hospital this->dischargePatient(*patient, out); return; @@ -624,7 +624,7 @@ processUnits: df::unit* unit = units[a]; /* As hilarious as it would be, lets not treat FB :) */ - if ( unit->flags1.bits.dead || unit->flags1.bits.active_invader || unit->flags2.bits.underworld || unit->flags2.bits.visitor_uninvited || unit->flags2.bits.visitor ) { + if ( !Units::isActive(unit) || unit->flags1.bits.active_invader || unit->flags2.bits.underworld || unit->flags2.bits.visitor_uninvited || unit->flags2.bits.visitor ) { continue; } From b38dfe2e434f0341d904de95e387af5875a4fd81 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:31:52 +0200 Subject: [PATCH 07/11] dead flag -> !isActive --- plugins/labormanager/labormanager.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/labormanager/labormanager.cpp b/plugins/labormanager/labormanager.cpp index 7c749edce..3ada1fc28 100644 --- a/plugins/labormanager/labormanager.cpp +++ b/plugins/labormanager/labormanager.cpp @@ -1224,7 +1224,7 @@ private: if (p1 || p2) { df::unit* other = p1 ? act->unit_noble : act->unit_actor; - if (other && !(other->flags1.bits.dead || + if (other && !(!Units::isActive(other) || (other->job.current_job && (other->job.current_job->job_type == df::job_type::Sleep || other->job.current_job->job_type == df::job_type::Rest)) || @@ -1247,7 +1247,7 @@ private: for (auto u2 = world->units.active.begin(); u2 != world->units.active.end(); ++u2) { if ((*u2)->relationship_ids[df::unit_relationship_type::Mother] == dwarf->dwarf->id && - !(*u2)->flags1.bits.dead && + Units::isActive(*u2) && ((*u2)->profession == df::profession::CHILD || (*u2)->profession == df::profession::BABY)) { dwarf->has_children = true; From f076d00ede77b810408b7c861d75e471e7af8bb4 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:32:38 +0200 Subject: [PATCH 08/11] dead flag -> !isActive --- plugins/manipulator.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/manipulator.cpp b/plugins/manipulator.cpp index 5dab2ab09..db560fa76 100644 --- a/plugins/manipulator.cpp +++ b/plugins/manipulator.cpp @@ -1157,7 +1157,7 @@ viewscreen_unitlaborsst::viewscreen_unitlaborsst(vector &src, int cur if (!Units::isOwnGroup(unit)) cur->allowEdit = false; - if (unit->flags1.bits.dead) + if (!Units::isActive(unit)) cur->allowEdit = false; if (unit->flags2.bits.visitor) From 3be27a49b51a7d8c7eaf27c195c140219fb0ff52 Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:33:18 +0200 Subject: [PATCH 09/11] dead flag -> !isInactive --- plugins/petcapRemover.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/petcapRemover.cpp b/plugins/petcapRemover.cpp index d35906a05..7504ab20e 100644 --- a/plugins/petcapRemover.cpp +++ b/plugins/petcapRemover.cpp @@ -64,7 +64,7 @@ void impregnateMany() { auto units = world->units.all; for ( size_t a = 0; a < units.size(); a++ ) { df::unit* unit = units[a]; - if ( unit->flags1.bits.dead || unit->flags1.bits.active_invader || unit->flags2.bits.underworld || unit->flags2.bits.visitor_uninvited || unit->flags2.bits.visitor ) + if ( !Units::isActive(unit) || unit->flags1.bits.active_invader || unit->flags2.bits.underworld || unit->flags2.bits.visitor_uninvited || unit->flags2.bits.visitor ) continue; popcount[unit->race]++; if ( unit->pregnancy_genes ) { From cac749429a110da9c25631dbd1a14fce9883364b Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:34:41 +0200 Subject: [PATCH 10/11] dead flag -> !isActive --- plugins/rendermax/renderer_light.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/plugins/rendermax/renderer_light.cpp b/plugins/rendermax/renderer_light.cpp index 90c38a06a..24c6bc751 100644 --- a/plugins/rendermax/renderer_light.cpp +++ b/plugins/rendermax/renderer_light.cpp @@ -798,7 +798,7 @@ void lightingEngineViewscreen::doOcupancyAndLights() if (DFHack::Units::isCitizen(u) && !u->counters.unconscious) addLight(getIndex(pos.x,pos.y),matCitizen.makeSource()); creatureLightDef *def=getCreatureDef(u); - if(def && !u->flags1.bits.dead) + if(def && Units::isActive(u)) { addLight(getIndex(pos.x,pos.y),def->light.makeSource()); } From cf780ce0353d9d7ec793f4e79f006345e87feb9a Mon Sep 17 00:00:00 2001 From: PatrikLundell Date: Thu, 14 Jun 2018 12:35:17 +0200 Subject: [PATCH 11/11] dead flag -> !isActive --- plugins/siege-engine.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/plugins/siege-engine.cpp b/plugins/siege-engine.cpp index 0d29e8c48..3df9edf29 100644 --- a/plugins/siege-engine.cpp +++ b/plugins/siege-engine.cpp @@ -1343,12 +1343,12 @@ static bool canTargetUnit(df::unit *unit) { CHECK_NULL_POINTER(unit); - if (unit->flags1.bits.dead || + if (!Units::isActive(unit) || unit->flags1.bits.caged || unit->flags1.bits.left || unit->flags1.bits.incoming || unit->flags1.bits.hidden_in_ambush || - unit->flags3.bits.ghostly) + Units::isGhost(unit)) return false; return true;