From 51d46d8965c16fa21261dc636d0d34951448d5eb Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Thu, 9 May 2024 02:50:16 +0300 Subject: [PATCH 63/63] AI: Cache 'worker' by unit's possible actions Previously unit's workerness was determined by Workers 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 1a544f1791..4ad985f91e 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_WORKERS); + ptype->adv.worker + = (utype_has_flag(ptype, UTYF_WORKERS) + && (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 autoworkers actions */ -- 2.43.0