From 27f72be6aeee5443214499eff8b895a234f338bc Mon Sep 17 00:00:00 2001
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Date: Sat, 14 Nov 2026 13:54:58 -0800
Subject: [PATCH] dai_hunter_manage(): Skip only targets we cannot attack

unit_attack_unit_at_tile_result() returns enum unit_attack_result,
whose ATT_OK is 0. The target check negated the result, so a hunter
skipped exactly the targets it can attack and considered only those
it cannot.

In practice no hunter takes a target, and as eval_hunter_want() runs the
same code on a virtual unit, no city builds a hunter either. That covers
every Hunter-role unit, in classic Horsemen, Chariot, Knights, Dragoons,
Cavalry, Armor, Frigate, Ironclad, Destroyer and Submarine.

Compare with ATT_OK. A tile with nothing we can attack, which the check
was added for, is still skipped.

See RM #2481

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
 ai/default/aihunt.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ai/default/aihunt.c b/ai/default/aihunt.c
index 92064ae219..3bb07e1e58 100644
--- a/ai/default/aihunt.c
+++ b/ai/default/aihunt.c
@@ -501,7 +501,8 @@ int dai_hunter_manage(struct ai_type *ait, struct player *pplayer,
       }
 
       target_tile = unit_tile(target);
-      if (!unit_attack_unit_at_tile_result(punit, NULL, target, target_tile)) {
+      if (unit_attack_unit_at_tile_result(punit, NULL, target, target_tile)
+          != ATT_OK) {
         /* We can't attack the target */
         continue;
       }
-- 
2.55.0

