From 22d0b0ec1c38217c3167965d56c2b3af9b16920e Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sun, 6 Oct 2024 11:40:18 -0700 Subject: [PATCH] don't run cycle on first fort tick to allow for custom config to be fully set first --- docs/changelog.txt | 1 + docs/plugins/autobutcher.rst | 12 ++++++------ plugins/autobutcher.cpp | 6 +++++- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index b883dfbc36..36797f8f49 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -58,6 +58,7 @@ Template for new versions: ## Fixes - Fix mouse clicks bleeding through DFHack windows when clicking in the space between the frame and the window content in resizable windows +- `autobutcher`: don't run a scanning and marking cycle on the first tick of a fortress to allow for all custom configuration to be set first - `logistics`: don't ignore rotten items when applying stockpile logistics operations (e.g. autodump, autoclaim, etc.) ## Misc Improvements diff --git a/docs/plugins/autobutcher.rst b/docs/plugins/autobutcher.rst index b6133fbf21..b429f57542 100644 --- a/docs/plugins/autobutcher.rst +++ b/docs/plugins/autobutcher.rst @@ -7,6 +7,9 @@ autobutcher This plugin monitors how many pets you have of each gender and age and assigns excess livestock for slaughter. See `gui/autobutcher` for an in-game interface. +Common configuration tweaks can be enabled in `gui/control-panel` in the +Automation -> Autostart tab. + Units are protected from being automatically butchered if they are: * Untamed @@ -34,10 +37,7 @@ Usage ----- ``enable autobutcher`` - Start processing livestock according to the configuration. Note that - no races are watched by default. You have to add the ones you want to - monitor with ``autobutcher watch``, ``autobutcher target`` or - ``autobutcher autowatch``. + Start processing livestock according to the per-race targets. ``autobutcher [list]`` Print status and current settings, including the watchlist. This is the default command if autobutcher is run without parameters. @@ -91,8 +91,8 @@ Though not all the races listed there are tameable/butcherable. savegame, you can export the commands required to recreate your settings. To export, open an external terminal in the DF directory, and run - ``dfhack-run autobutcher list_export > filename.txt``. To import, load your - new save and run ``script filename.txt`` in the DFHack terminal. + ``dfhack-run autobutcher list_export > autobutcher.txt``. To import, load + your new save and run ``script autobutcher.txt`` in `gui/launcher`. Examples -------- diff --git a/plugins/autobutcher.cpp b/plugins/autobutcher.cpp index aa92709ada..b8765a6372 100644 --- a/plugins/autobutcher.cpp +++ b/plugins/autobutcher.cpp @@ -17,6 +17,7 @@ #include "df/building_civzonest.h" #include "df/creature_raw.h" #include "df/general_ref.h" +#include "df/plotinfost.h" #include "df/unit.h" #include "df/world.h" @@ -31,6 +32,7 @@ using namespace DFHack; DFHACK_PLUGIN("autobutcher"); DFHACK_PLUGIN_IS_ENABLED(is_enabled); +REQUIRE_GLOBAL(plotinfo); REQUIRE_GLOBAL(world); // logging levels can be dynamically controlled with the `debugfilter` command. @@ -89,7 +91,9 @@ DFhackCExport command_result plugin_enable(color_ostream &out, bool enable) { DEBUG(control,out).print("%s from the API; persisting\n", is_enabled ? "enabled" : "disabled"); config.set_bool(CONFIG_IS_ENABLED, is_enabled); - if (enable) + // don't autorun cycle on first frame of fortress so we don't mark animals for butchering before + // all initial configuration has been applied + if (enable && plotinfo->fortress_age > 0) autobutcher_cycle(out); } else { DEBUG(control,out).print("%s from the API, but already %s; no action\n",