From fba505a2c7594e42957b7e473fb4e91b3d7890c8 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 1 Aug 2026 10:03:32 +0300
Subject: [PATCH 41/41] random_movements(): Correct attack legality check

See RM #2106

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/unittools.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/server/unittools.c b/server/unittools.c
index bb1b21b9d4..a19cebc807 100644
--- a/server/unittools.c
+++ b/server/unittools.c
@@ -5136,8 +5136,7 @@ void random_movements(struct player *pplayer)
           struct tile *dest = mapstep(&(wld.map), curtile, dirs[choice]);
 
           if (dest != nullptr) {
-            if (action_prob_possible(action_prob_vs_stack(nmap, punit, ACTION_ATTACK,
-                                                          dest))) {
+            if (is_action_enabled_unit_on_stack(nmap, ACTION_ATTACK, punit, dest)) {
               if (unit_perform_action(pplayer, id, tile_index(dest), NO_TARGET,
                                       "", ACTION_ATTACK, ACT_REQ_RULES)) {
                 moved = TRUE;
-- 
2.53.0

