fix logic for autotrain and autotrade

develop
Myk Taylor 2023-07-15 20:20:51 -07:00
parent e1ad92295c
commit 5c7aea0775
No known key found for this signature in database
GPG Key ID: 8A39CA0FA0C16E78
2 changed files with 8 additions and 3 deletions

@ -38,6 +38,8 @@ changelog.txt uses a syntax similar to RST, with a few special sequences:
## Fixes ## Fixes
- Fix extra keys appearing in DFHack text boxes when shift (or any other modifier) is released before the other key you were pressing - 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 ## Misc Improvements
- `stockpiles`: include exotic pets in the "tameable" filter - `stockpiles`: include exotic pets in the "tameable" filter

@ -330,11 +330,13 @@ private:
df::building_tradedepotst * const depot; df::building_tradedepotst * const depot;
static df::building_tradedepotst * get_active_trade_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()) if (!plotinfo->caravans.size())
return NULL; return NULL;
bool found = false; bool found = false;
for (auto caravan : plotinfo->caravans) { for (auto caravan : plotinfo->caravans) {
if (caravan->flags.bits.tribute)
continue;
auto trade_state = caravan->trade_state; auto trade_state = caravan->trade_state;
auto time_remaining = caravan->time_remaining; auto time_remaining = caravan->time_remaining;
if ((trade_state == df::caravan_state::T_trade_state::Approaching || 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 { bool can_designate(color_ostream& out, df::item* item) override {
auto unit = get_caged_unit(item); auto unit = get_caged_unit(item);
return unit && Units::isTamable(unit) && !Units::isTame(unit) return unit && !Units::isInvader(unit) &&
&& !has_training_assignment(unit); Units::isTamable(unit) && !Units::isTame(unit) &&
!has_training_assignment(unit);
} }
bool designate(color_ostream& out, df::item* item) override { bool designate(color_ostream& out, df::item* item) override {