From e0bb5bf53b7466542413328c36f82cfef709d0fe Mon Sep 17 00:00:00 2001 From: Kelly Martin Date: Fri, 20 Apr 2012 14:22:20 -0500 Subject: [PATCH] Add "naked" (has no inventory) predicate to zone (useful for mass pitting) --- plugins/zone.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/plugins/zone.cpp b/plugins/zone.cpp index ee6abf327..fe8a4f759 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -366,6 +366,7 @@ void cageInfo(color_ostream & out, df::building* building, bool verbose); void chainInfo(color_ostream & out, df::building* building, bool verbose); bool isBuiltCageAtPos(df::coord pos); bool isInBuiltCageRoom(df::unit*); +bool isNaked(df::unit *); int32_t getUnitAge(df::unit* unit) { @@ -644,6 +645,12 @@ bool hasValidMapPos(df::unit* unit) return false; } +bool isNaked(df::unit* unit) +{ + return (unit->inventory.empty()); +} + + int getUnitIndexFromId(df::unit* unit_) { for (size_t i=0; i < world->units.all.size(); i++) @@ -1748,6 +1755,8 @@ command_result df_zone (color_ostream &out, vector & parameters) bool find_not_milkable = false; bool find_named = false; bool find_not_named = false; + bool find_naked = false; + bool find_not_naked = false; bool find_agemin = false; bool find_agemax = false; @@ -2126,6 +2135,15 @@ command_result df_zone (color_ostream &out, vector & parameters) find_not_egglayer = true; 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) { find_grazer = true; @@ -2393,6 +2411,8 @@ command_result df_zone (color_ostream &out, vector & parameters) || (find_not_female && isFemale(unit)) || (find_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_not_trainable_war && isTrainableWar(unit)) // hm, is this check enough? || (find_trainable_hunting && (isWar(unit) || isHunter(unit) || !isTrainableHunting(unit)))