Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[autobutcher] don't run cycle on first fort tick #4987

Merged
merged 1 commit into from
Oct 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions docs/changelog.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 6 additions & 6 deletions docs/plugins/autobutcher.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
--------
Expand Down
6 changes: 5 additions & 1 deletion plugins/autobutcher.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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.
Expand Down Expand Up @@ -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",
Expand Down