Add "naked" (has no inventory) predicate to zone (useful for mass pitting)

develop
Kelly Martin 2012-04-20 14:22:20 -05:00
parent b7b27ebb9e
commit e0bb5bf53b
1 changed files with 20 additions and 0 deletions

@ -366,6 +366,7 @@ void cageInfo(color_ostream & out, df::building* building, bool verbose);
void chainInfo(color_ostream & out, df::building* building, bool verbose); void chainInfo(color_ostream & out, df::building* building, bool verbose);
bool isBuiltCageAtPos(df::coord pos); bool isBuiltCageAtPos(df::coord pos);
bool isInBuiltCageRoom(df::unit*); bool isInBuiltCageRoom(df::unit*);
bool isNaked(df::unit *);
int32_t getUnitAge(df::unit* unit) int32_t getUnitAge(df::unit* unit)
{ {
@ -644,6 +645,12 @@ bool hasValidMapPos(df::unit* unit)
return false; return false;
} }
bool isNaked(df::unit* unit)
{
return (unit->inventory.empty());
}
int getUnitIndexFromId(df::unit* unit_) int getUnitIndexFromId(df::unit* unit_)
{ {
for (size_t i=0; i < world->units.all.size(); i++) for (size_t i=0; i < world->units.all.size(); i++)
@ -1748,6 +1755,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
bool find_not_milkable = false; bool find_not_milkable = false;
bool find_named = false; bool find_named = false;
bool find_not_named = false; bool find_not_named = false;
bool find_naked = false;
bool find_not_naked = false;
bool find_agemin = false; bool find_agemin = false;
bool find_agemax = false; bool find_agemax = false;
@ -2126,6 +2135,15 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
find_not_egglayer = true; find_not_egglayer = true;
invert_filter=false; invert_filter=false;
} }
else if(p == "naked" && !invert_filter)
{
find_naked = true;
}
else if(p == "naked" && invert_filter)
{
find_not_naked = true;
invert_filter=false;
}
else if(p == "grazer" && !invert_filter) else if(p == "grazer" && !invert_filter)
{ {
find_grazer = true; find_grazer = true;
@ -2393,6 +2411,8 @@ command_result df_zone (color_ostream &out, vector <string> & parameters)
|| (find_not_female && isFemale(unit)) || (find_not_female && isFemale(unit))
|| (find_named && !unit->name.has_name) || (find_named && !unit->name.has_name)
|| (find_not_named && unit->name.has_name) || (find_not_named && unit->name.has_name)
|| (find_naked && !isNaked(unit))
|| (find_not_naked && isNaked(unit))
|| (find_trainable_war && (isWar(unit) || isHunter(unit) || !isTrainableWar(unit))) || (find_trainable_war && (isWar(unit) || isHunter(unit) || !isTrainableWar(unit)))
|| (find_not_trainable_war && isTrainableWar(unit)) // hm, is this check enough? || (find_not_trainable_war && isTrainableWar(unit)) // hm, is this check enough?
|| (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit))) || (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit)))