From cbf5eda9557e0a5395e37c466cf0027553edc9c6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 9 May 2024 02:55:55 +0300 Subject: [PATCH 47/47] AI: Cache 'worker' by unit's possible actions Previously unit's workerness was determined by Settlers flag alone. Now consider also actions that it can do. Notably units that can't do other worker actions than Build Base are not considered (auto)workers. Requested by bard See osdn #57666 Signed-off-by: Marko Lindqvist --- server/advisors/advruleset.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/server/advisors/advruleset.c b/server/advisors/advruleset.c index 8a3595b73a..98bba38335 100644 --- a/server/advisors/advruleset.c +++ b/server/advisors/advruleset.c @@ -104,7 +104,13 @@ void adv_units_ruleset_init(void) } unit_class_iterate_end; } - ptype->adv.worker = utype_has_flag(ptype, UTYF_SETTLERS); + ptype->adv.worker + = (utype_has_flag(ptype, UTYF_SETTLERS) + && (utype_can_do_action_result(ptype, ACTRES_CULTIVATE) + || utype_can_do_action_result(ptype, ACTRES_PLANT) + || utype_can_do_action_result(ptype, ACTRES_IRRIGATE) + || utype_can_do_action_result(ptype, ACTRES_MINE) + || utype_can_do_action_result(ptype, ACTRES_TRANSFORM_TERRAIN))); } unit_type_iterate_end; /* Initialize autosettlers actions */ -- 2.43.0