From 96edbd43fff25ce69cba864895d7315d73fa49de Mon Sep 17 00:00:00 2001
From: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
Date: Sat, 14 Nov 2026 13:57:44 -0800
Subject: [PATCH] POTENTIALLY_HOSTILE_PLAYER(): Be false for the player itself

A player's diplstate with itself is DS_NO_CONTACT, and NEVER_MET()
reads that, so POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, pplayer) is
TRUE. So find_something_to_kill(), when it rates a virtual attacker
for a build choice, counts the AI's own cities as targets, and one can
be the best. dai_gothere_bodyguard() likewise asks for an escort on
the way to an own city.

Test for the player itself first. Toward other players the macro is
unchanged.

See RM #2483

Signed-off-by: Sweet Tea Dorminy <sweettea-kernel@dorminy.me>
---
 ai/default/daiunit.h | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/ai/default/daiunit.h b/ai/default/daiunit.h
index 4ff27a661b..61ca544211 100644
--- a/ai/default/daiunit.h
+++ b/ai/default/daiunit.h
@@ -69,9 +69,12 @@ struct unit_type_ai
  (ptype->attack_strength * ptype->hp * ptype->firepower)
 #define IS_ATTACKER(ptype) \
   (ptype->attack_strength > ptype->transport_capacity)
+/* A player's diplstate with itself is DS_NO_CONTACT, so test for self
+ * before NEVER_MET(). */
 #define POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, aplayer)               \
-  (WAR(pplayer, aplayer) || NEVER_MET(pplayer, aplayer)                 \
-   || dai_diplomacy_get(ait, pplayer, aplayer)->countdown >= 0)
+  ((pplayer) != (aplayer)                                               \
+   && (WAR(pplayer, aplayer) || NEVER_MET(pplayer, aplayer)             \
+       || dai_diplomacy_get(ait, pplayer, aplayer)->countdown >= 0))
 #define UNITTYPE_COSTS(ut)                                              \
   (ut->pop_cost * 3 + ut->happy_cost                                    \
    + ut->upkeep[O_SHIELD] + ut->upkeep[O_FOOD] + ut->upkeep[O_GOLD])
-- 
2.55.0

