From 91a40ba881e35e50d7384f354878113c2ab4fbe4 Mon Sep 17 00:00:00 2001 From: Myk Taylor Date: Sat, 21 Sep 2024 23:07:54 -0700 Subject: [PATCH] fix regression in Units::isGay() ref: #4810 --- docs/changelog.txt | 1 + library/modules/Units.cpp | 6 +++--- plugins/autobutcher.cpp | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/docs/changelog.txt b/docs/changelog.txt index d71c16d320..656a31a8b0 100644 --- a/docs/changelog.txt +++ b/docs/changelog.txt @@ -57,6 +57,7 @@ Template for new versions: ## Fixes - `preserve-rooms`: don't reserve a room for citizens that you expel from the fort +- `autobutcher`: fix regression in ordering of butcherable animals ## Misc Improvements diff --git a/library/modules/Units.cpp b/library/modules/Units.cpp index 44fec6ae2c..6f58a38b2f 100644 --- a/library/modules/Units.cpp +++ b/library/modules/Units.cpp @@ -312,9 +312,9 @@ bool Units::isGay(df::unit *unit) { if (!unit->status.current_soul) return false; - auto &o_flag = unit->status.current_soul->orientation_flags; - return (!isFemale(unit) || !(o_flag.bits.marry_male && o_flag.bits.romance_male)) - && (!isMale(unit) || !(o_flag.bits.marry_female && o_flag.bits.romance_female)); + df::orientation_flags orientation = unit->status.current_soul->orientation_flags; + return (!Units::isFemale(unit) || !(orientation.whole & (orientation.mask_marry_male | orientation.mask_romance_male))) + && (!Units::isMale(unit) || !(orientation.whole & (orientation.mask_marry_female | orientation.mask_romance_female))); } bool Units::isNaked(df::unit *unit, bool no_items) { diff --git a/plugins/autobutcher.cpp b/plugins/autobutcher.cpp index 42cddf42a7..aa92709ada 100644 --- a/plugins/autobutcher.cpp +++ b/plugins/autobutcher.cpp @@ -213,7 +213,7 @@ static void doMarkForSlaughter(df::unit *unit) { unit->flags2.bits.slaughter = 1; } -// returns true if a should be butchered before b +// returns true if b should be butchered before a static bool compareKids(df::unit *a, df::unit *b) { if (isHighPriority(a) != isHighPriority(b)) return isHighPriority(b); @@ -222,7 +222,7 @@ static bool compareKids(df::unit *a, df::unit *b) { return Units::getAge(a, true) > Units::getAge(b, true); } -// returns true if a should be butchered before b +// returns true if b should be butchered before a static bool compareAdults(df::unit* a, df::unit* b) { if (isHighPriority(a) != isHighPriority(b)) return isHighPriority(b);