Adapted to changed Units functions

Squashed version of #1307

Closes #1307
develop
lethosor 2018-06-14 10:30:35 -04:00
parent ee3a726c29
commit aac892c560
6 changed files with 22 additions and 24 deletions

@ -590,6 +590,8 @@ static command_result ListUnits(color_ostream &stream,
{ {
auto unit = vec[i]; auto unit = vec[i];
if (!Units::isActive(unit) && !Units::isKilled(unit))
continue;
if (in->has_race() && unit->race != in->race()) if (in->has_race() && unit->race != in->race())
continue; continue;
if (in->has_civ_id() && unit->civ_id != in->civ_id()) if (in->has_civ_id() && unit->civ_id != in->civ_id())

@ -537,7 +537,7 @@ static void manageUnitDeathEvent(color_ostream& out) {
for ( size_t a = 0; a < df::global::world->units.all.size(); a++ ) { for ( size_t a = 0; a < df::global::world->units.all.size(); a++ ) {
df::unit* unit = df::global::world->units.all[a]; df::unit* unit = df::global::world->units.all[a];
//if ( unit->counters.death_id == -1 ) { //if ( unit->counters.death_id == -1 ) {
if ( ! unit->flags1.bits.dead ) { if ( Units::isActive(unit) ) {
livingUnits.insert(unit->id); livingUnits.insert(unit->id);
continue; continue;
} }
@ -927,7 +927,7 @@ static void manageUnitAttackEvent(color_ostream& out) {
} }
} }
if ( unit1->flags1.bits.dead ) { if ( Units::isKilled(unit1) ) {
UnitAttackData data; UnitAttackData data;
data.attacker = unit2->id; data.attacker = unit2->id;
data.defender = unit1->id; data.defender = unit1->id;
@ -939,7 +939,7 @@ static void manageUnitAttackEvent(color_ostream& out) {
} }
} }
if ( unit2->flags1.bits.dead ) { if ( Units::isKilled(unit2) ) {
UnitAttackData data; UnitAttackData data;
data.attacker = unit1->id; data.attacker = unit1->id;
data.defender = unit2->id; data.defender = unit2->id;

@ -300,7 +300,7 @@ bool ReservedRoom::checkRoomAssignment()
if (!Units::isCitizen(unit)) if (!Units::isCitizen(unit))
continue; continue;
if (DFHack::Units::isDead(unit)) if (!Units::isActive(unit))
continue; continue;
np = getUniqueNoblePositions(unit); np = getUniqueNoblePositions(unit);

@ -338,7 +338,7 @@ public:
for (auto it = work_history.begin(); it != work_history.end();) for (auto it = work_history.begin(); it != work_history.end();)
{ {
auto unit = it->first; auto unit = it->first;
if (Units::isDead(unit)) if (!Units::isActive(unit))
{ {
work_history.erase(it++); work_history.erase(it++);
continue; continue;
@ -583,7 +583,7 @@ public:
for (auto it = work_history.begin(); it != work_history.end();) for (auto it = work_history.begin(); it != work_history.end();)
{ {
auto unit = it->first; auto unit = it->first;
if (Units::isDead(unit)) if (!Units::isActive(unit))
{ {
work_history.erase(it++); work_history.erase(it++);
continue; continue;
@ -1372,7 +1372,7 @@ public:
if (!Units::isCitizen(unit)) if (!Units::isCitizen(unit))
continue; continue;
if (DFHack::Units::isDead(unit)) if (!DFHack::Units::isActive(unit))
continue; continue;
if (!unit->status.current_soul) if (!unit->status.current_soul)
@ -1788,7 +1788,7 @@ static void update_dwarf_stats(bool is_paused)
if (!Units::isCitizen(unit)) if (!Units::isCitizen(unit))
continue; continue;
if (DFHack::Units::isDead(unit)) if (!DFHack::Units::isActive(unit))
{ {
auto it = work_history.find(unit); auto it = work_history.find(unit);
if (it != work_history.end()) if (it != work_history.end())

@ -44,7 +44,7 @@ const int STRENGTH_MULTIPLIER = 100;
bool is_valid_unit (df::unit *unit) { bool is_valid_unit (df::unit *unit) {
if (!Units::isOwnRace(unit) || !Units::isOwnCiv(unit)) if (!Units::isOwnRace(unit) || !Units::isOwnCiv(unit))
return false; return false;
if (Units::isDead(unit)) if (!Units::isActive(unit))
return false; return false;
return true; return true;
} }

@ -789,7 +789,7 @@ df::building* findFreeNestboxZone()
bool isFreeEgglayer(df::unit * unit) bool isFreeEgglayer(df::unit * unit)
{ {
if( !isDead(unit) && !isUndead(unit) return isActive(unit) && !isUndead(unit)
&& isFemale(unit) && isFemale(unit)
&& isTame(unit) && isTame(unit)
&& isOwnCiv(unit) && isOwnCiv(unit)
@ -797,11 +797,7 @@ bool isFreeEgglayer(df::unit * unit)
&& !isAssigned(unit) && !isAssigned(unit)
&& !isGrazer(unit) // exclude grazing birds because they're messy && !isGrazer(unit) // exclude grazing birds because they're messy
&& !isMerchant(unit) // don't steal merchant mounts && !isMerchant(unit) // don't steal merchant mounts
&& !isForest(unit) // don't steal birds from traders, they hate that && !isForest(unit); // don't steal birds from traders, they hate that
)
return true;
else
return false;
} }
df::unit * findFreeEgglayer() df::unit * findFreeEgglayer()
@ -2078,8 +2074,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
{ {
df::unit *unit = *unit_it; df::unit *unit = *unit_it;
// ignore dead and undead units // ignore inactive and undead units
if (isDead(unit) || isUndead(unit)) { if (!isActive(unit) || isUndead(unit)) {
continue; continue;
} }
@ -3032,7 +3028,7 @@ command_result autoButcher( color_ostream &out, bool verbose = false )
// then let autowatch add units to the watchlist which will probably start breeding (owned pets, war animals, ...) // then let autowatch add units to the watchlist which will probably start breeding (owned pets, war animals, ...)
// then process units counting those which can't be butchered (war animals, named pets, ...) // then process units counting those which can't be butchered (war animals, named pets, ...)
// so that they are treated as "own stock" as well and count towards the target quota // so that they are treated as "own stock" as well and count towards the target quota
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| isMarkedForSlaughter(unit) || isMarkedForSlaughter(unit)
|| isMerchant(unit) // ignore merchants' draught animals || isMerchant(unit) // ignore merchants' draught animals
@ -3273,7 +3269,7 @@ WatchedRace * checkRaceStocksTotal(int race)
if(unit->race != race) if(unit->race != race)
continue; continue;
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| isMerchant(unit) // ignore merchants' draught animals || isMerchant(unit) // ignore merchants' draught animals
|| isForest(unit) // ignore merchants' caged animals || isForest(unit) // ignore merchants' caged animals
@ -3302,7 +3298,7 @@ WatchedRace * checkRaceStocksProtected(int race)
if(unit->race != race) if(unit->race != race)
continue; continue;
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| isMerchant(unit) // ignore merchants' draught animals || isMerchant(unit) // ignore merchants' draught animals
|| isForest(unit) // ignore merchants' caged animals || isForest(unit) // ignore merchants' caged animals
@ -3339,7 +3335,7 @@ WatchedRace * checkRaceStocksButcherable(int race)
if(unit->race != race) if(unit->race != race)
continue; continue;
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| isMerchant(unit) // ignore merchants' draught animals || isMerchant(unit) // ignore merchants' draught animals
|| isForest(unit) // ignore merchants' caged animals || isForest(unit) // ignore merchants' caged animals
@ -3376,7 +3372,7 @@ WatchedRace * checkRaceStocksButcherFlag(int race)
if(unit->race != race) if(unit->race != race)
continue; continue;
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| isMerchant(unit) // ignore merchants' draught animals || isMerchant(unit) // ignore merchants' draught animals
|| isForest(unit) // ignore merchants' caged animals || isForest(unit) // ignore merchants' caged animals
@ -3404,7 +3400,7 @@ void butcherRace(int race)
if(unit->race != race) if(unit->race != race)
continue; continue;
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| isMerchant(unit) // ignore merchants' draught animals || isMerchant(unit) // ignore merchants' draught animals
|| isForest(unit) // ignore merchants' caged animals || isForest(unit) // ignore merchants' caged animals
@ -3439,7 +3435,7 @@ void unbutcherRace(int race)
if(unit->race != race) if(unit->race != race)
continue; continue;
if( isDead(unit) if( !isActive(unit)
|| isUndead(unit) || isUndead(unit)
|| !isMarkedForSlaughter(unit) || !isMarkedForSlaughter(unit)
) )