From bebecec1e55db794d2607af90e41de35a665208e Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 1 Jan 2023 16:32:56 -0800 Subject: [PATCH 1/2] update autobutcher to work with new zoo structures --- plugins/CMakeLists.txt | 2 +- plugins/autobutcher.cpp | 17 ++++++++++++----- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/plugins/CMakeLists.txt b/plugins/CMakeLists.txt index dd5000ab5..6c2071376 100644 --- a/plugins/CMakeLists.txt +++ b/plugins/CMakeLists.txt @@ -80,7 +80,7 @@ set_source_files_properties( Brushes.h PROPERTIES HEADER_FILE_ONLY TRUE ) #dfhack_plugin(3dveins 3dveins.cpp) #dfhack_plugin(add-spatter add-spatter.cpp) -#dfhack_plugin(autobutcher autobutcher.cpp LINK_LIBRARIES lua) +dfhack_plugin(autobutcher autobutcher.cpp LINK_LIBRARIES lua) #dfhack_plugin(autochop autochop.cpp) #dfhack_plugin(autoclothing autoclothing.cpp) #dfhack_plugin(autodump autodump.cpp) diff --git a/plugins/autobutcher.cpp b/plugins/autobutcher.cpp index 81ec0c5df..d75108f3f 100644 --- a/plugins/autobutcher.cpp +++ b/plugins/autobutcher.cpp @@ -712,13 +712,20 @@ static bool hasValidMapPos(df::unit *unit) { && unit->pos.z < world->map.z_count; } -// built cage defined as room (supposed to detect zoo cages) +// built cage in a zone (supposed to detect zoo cages) static bool isInBuiltCageRoom(df::unit *unit) { for (auto building : world->buildings.all) { - // !!! building->isRoom() returns true if the building can be made a room but currently isn't - // !!! except for coffins/tombs which always return false - // !!! using the bool is_room however gives the correct state/value - if (!building->is_room || building->getType() != df::building_type::Cage) + if (building->getType() != df::building_type::Cage) + continue; + + bool in_zone = false; + for (auto relation : building->relations) { + if (relation->getType() == df::building_type::Civzone) { + in_zone = true; + break; + } + } + if (!in_zone) continue; df::building_cagest* cage = (df::building_cagest*)building; From ab5c7708d815425ef393a74c2ff2924e39692349 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 1 Jan 2023 16:35:39 -0800 Subject: [PATCH 2/2] update docs --- docs/plugins/autobutcher.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/plugins/autobutcher.rst b/docs/plugins/autobutcher.rst index f288f9073..1a4aa4f91 100644 --- a/docs/plugins/autobutcher.rst +++ b/docs/plugins/autobutcher.rst @@ -12,7 +12,7 @@ watch list. Units will be ignored if they are: * Untamed * Nicknamed (for custom protection; you can use the `rename` ``unit`` tool individually, or `zone` ``nick`` for groups) -* Caged, if and only if the cage is defined as a room (to protect zoos) +* Caged, if and only if the cage is in a zone (to protect zoos) * Trained for war or hunting Creatures who will not reproduce (because they're not interested in the