From 9c5da0dc05a9c37a42f8e780926417102ef89e0f Mon Sep 17 00:00:00 2001
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Date: Sat, 14 Nov 2026 13:54:54 -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/daihunter.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/ai/default/daihunter.c b/ai/default/daihunter.c
index 026582110d..8a08807023 100644
--- a/ai/default/daihunter.c
+++ b/ai/default/daihunter.c
@@ -499,7 +499,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, nullptr, target, target_tile)) {
+      if (unit_attack_unit_at_tile_result(punit, nullptr, target, target_tile)
+          != ATT_OK) {
         /* We can't attack the target */
         continue;
       }
-- 
2.55.0

