diff options
| author | Robert Heinrich | 2012-04-15 21:45:15 +0200 |
|---|---|---|
| committer | Robert Heinrich | 2012-04-15 21:45:15 +0200 |
| commit | 7aefae17d1b0173df99e4c788e58b5f347ebfd39 (patch) | |
| tree | 8af04aa86bd7d0258fb50b14c59733437744b71d /plugins/zone.cpp | |
| parent | 6197c4e7397d8cd67f8486ce2470280251f9edd7 (diff) | |
| download | dfhack-7aefae17d1b0173df99e4c788e58b5f347ebfd39.tar.gz dfhack-7aefae17d1b0173df99e4c788e58b5f347ebfd39.tar.bz2 dfhack-7aefae17d1b0173df99e4c788e58b5f347ebfd39.tar.xz | |
autonestbox: don't assign to nestboxes which are already claimed or contain eggs.
bprobe: look a bit closer at nestboxes
Diffstat (limited to 'plugins/zone.cpp')
| -rw-r--r-- | plugins/zone.cpp | 25 |
1 files changed, 24 insertions, 1 deletions
diff --git a/plugins/zone.cpp b/plugins/zone.cpp index c3f065e4..f17f2946 100644 --- a/plugins/zone.cpp +++ b/plugins/zone.cpp @@ -56,6 +56,7 @@ using namespace std; #include "df/building_civzonest.h" #include "df/building_cagest.h" #include "df/building_chainst.h" +#include "df/building_nest_boxst.h" #include "df/general_ref_building_civzone_assignedst.h" #include <df/creature_raw.h> #include <df/caste_raw.h> @@ -1063,6 +1064,28 @@ bool isNestboxAtPos(int32_t x, int32_t y, int32_t z) return found; } +bool isFreeNestboxAtPos(int32_t x, int32_t y, int32_t z) +{ + bool found = false; + for (size_t b=0; b < world->buildings.all.size(); b++) + { + df::building* building = world->buildings.all[b]; + if( building->getType() == building_type::NestBox + && building->x1 == x + && building->y1 == y + && building->z == z ) + { + df::building_nest_boxst* nestbox = (df::building_nest_boxst*) building; + if(nestbox->claimed_by == -1 && nestbox->contained_items.size() == 1) + { + found = true; + break; + } + } + } + return found; +} + bool isEmptyPasture(df::building* building) { if(!isPenPasture(building)) @@ -1083,7 +1106,7 @@ df::building* findFreeNestboxZone() df::building* building = world->buildings.all[b]; if( isEmptyPasture(building) && isActive(building) && - isNestboxAtPos(building->x1, building->y1, building->z)) + isFreeNestboxAtPos(building->x1, building->y1, building->z)) { free_building = building; break; |
