From f5460c5c990f82d2005c880edd7598b89c6f6fdc Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 9 Nov 2026 22:30:51 +0200
Subject: [PATCH 39/39] rulecache: Fix detection of IgWall units

See RM #2470

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/advisors/advruleset.c | 16 ++++++++++++----
 1 file changed, 12 insertions(+), 4 deletions(-)

diff --git a/server/advisors/advruleset.c b/server/advisors/advruleset.c
index 4ad985f91e..e4586d64d0 100644
--- a/server/advisors/advruleset.c
+++ b/server/advisors/advruleset.c
@@ -84,18 +84,26 @@ void adv_units_ruleset_init(void)
 
     effect_list_iterate(get_effects(EFT_DEFEND_BONUS), peffect) {
       if (peffect->value > 0) {
+        bool effect_active = TRUE;
+
         requirement_vector_iterate(&peffect->reqs, preq) {
           if (!is_req_active(&context, NULL, preq, RPT_POSSIBLE)) {
-            ptype->adv.igwall = FALSE;
+            effect_active = FALSE;
             break;
           }
         } requirement_vector_iterate_end;
-      }
-      if (!ptype->adv.igwall) {
-        break;
+
+        if (effect_active) {
+          ptype->adv.igwall = FALSE;
+          break;
+        }
       }
     } effect_list_iterate_end;
 
+    if (ptype->adv.igwall) {
+      log_debug("Rulecache: %s IgWall", utype_rule_name(ptype));
+    }
+
     if (utype_has_role(ptype, L_FERRYBOAT)) {
       unit_class_iterate(aclass) {
         if (BV_ISSET(ptype->cargo, uclass_index(aclass))) {
-- 
2.53.0

