From 5c7aea0775a6de9a436813f1c25af2bfd5540816 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 15 Jul 2023 20:20:51 -0700 Subject: [PATCH] fix logic for autotrain and autotrade --- docs/changelog.txt | 2 ++ plugins/logistics.cpp | 9 ++++++--- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index 6e669c893..dc5c2ce46 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -38,6 +38,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences: ## Fixes - Fix extra keys appearing in DFHack text boxes when shift (or any other modifier) is released before the other key you were pressing +- `logistics`: don't autotrain domestic animals brought by invaders (they'll get attacked by friendly creatures as soon as you let them out of their cage) +- `logistics`: don't bring trade goods to depot if the only caravans present are tribute caravans ## Misc Improvements - `stockpiles`: include exotic pets in the "tameable" filter diff --git a/plugins/logistics.cpp b/plugins/logistics.cpp index 20b2c343f..a7da0e553 100644 --- a/plugins/logistics.cpp +++ b/plugins/logistics.cpp @@ -330,11 +330,13 @@ private: df::building_tradedepotst * const depot; static df::building_tradedepotst * get_active_trade_depot() { - // at least one caravan must be approaching or ready to trade + // at least one non-tribute caravan must be approaching or ready to trade if (!plotinfo->caravans.size()) return NULL; bool found = false; for (auto caravan : plotinfo->caravans) { + if (caravan->flags.bits.tribute) + continue; auto trade_state = caravan->trade_state; auto time_remaining = caravan->time_remaining; if ((trade_state == df::caravan_state::T_trade_state::Approaching || @@ -392,8 +394,9 @@ public: bool can_designate(color_ostream& out, df::item* item) override { auto unit = get_caged_unit(item); - return unit && Units::isTamable(unit) && !Units::isTame(unit) - && !has_training_assignment(unit); + return unit && !Units::isInvader(unit) && + Units::isTamable(unit) && !Units::isTame(unit) && + !has_training_assignment(unit); } bool designate(color_ostream& out, df::item* item) override {