From f334296dbe804b1a61e56499036df03040d70704 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Wed, 10 Jul 2024 06:51:45 +0300
Subject: [PATCH 28/28] Unhardcode wld.map from action_is_blocked_by()

See RM #758

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/actions.c  | 10 +++++-----
 common/actions.h  |  3 ++-
 server/unithand.c |  2 +-
 3 files changed, 8 insertions(+), 7 deletions(-)

diff --git a/common/actions.c b/common/actions.c
index 77d4ce9aea..8403f38d53 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -2246,7 +2246,8 @@ blocked_find_target_city(const struct action *act,
 
   An action that can block another blocks when it is forced and possible.
 **************************************************************************/
-struct action *action_is_blocked_by(const struct action *act,
+struct action *action_is_blocked_by(const struct civ_map *nmap,
+                                    const struct action *act,
                                     const struct unit *actor_unit,
                                     const struct tile *target_tile_arg,
                                     const struct city *target_city_arg,
@@ -2258,7 +2259,6 @@ struct action *action_is_blocked_by(const struct action *act,
   const struct city *target_city
       = blocked_find_target_city(act, actor_unit, target_tile,
                                  target_city_arg, target_unit);
-  const struct civ_map *nmap = &(wld.map);
 
   action_iterate(blocker_id) {
     struct action *blocker = action_by_number(blocker_id);
@@ -2845,7 +2845,7 @@ is_action_possible(const struct civ_map *nmap,
     break;
   }
 
-  if (action_is_blocked_by(paction, actor->unit,
+  if (action_is_blocked_by(nmap, paction, actor->unit,
                            target->tile, target->city, target->unit)) {
     /* Allows an action to block an other action. If a blocking action is
      * legal the actions it blocks becomes illegal. */
@@ -4163,7 +4163,7 @@ action_prob_vs_city_full(const struct civ_map *nmap,
 
   /* Doesn't leak information since it must be 100% certain from the
    * player's perspective that the blocking action is legal. */
-  if (action_is_blocked_by(act, actor_unit,
+  if (action_is_blocked_by(nmap, act, actor_unit,
                            city_tile(target_city), target_city, NULL)) {
     /* Don't offer to perform an action known to be blocked. */
     return ACTPROB_IMPOSSIBLE;
@@ -4363,7 +4363,7 @@ action_prob_vs_stack_full(const struct civ_map *nmap,
   /* Doesn't leak information since it must be 100% certain from the
    * player's perspective that the blocking action is legal. */
   unit_list_iterate(target_tile->units, target_unit) {
-    if (action_is_blocked_by(act, actor_unit,
+    if (action_is_blocked_by(nmap, act, actor_unit,
                              target_tile, tile_city(target_tile),
                              target_unit)) {
       /* Don't offer to perform an action known to be blocked. */
diff --git a/common/actions.h b/common/actions.h
index d47f57e1bc..65b1ad000a 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -514,7 +514,8 @@ bool action_enabler_utype_possible_actor(const struct action_enabler *ae,
                                          const struct unit_type *act_utype);
 bool action_enabler_possible_actor(const struct action_enabler *ae);
 
-struct action *action_is_blocked_by(const struct action *act,
+struct action *action_is_blocked_by(const struct civ_map *nmap,
+                                    const struct action *act,
                                     const struct unit *actor_unit,
                                     const struct tile *target_tile,
                                     const struct city *target_city,
diff --git a/server/unithand.c b/server/unithand.c
index b5501c7a04..74860b7759 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -1917,7 +1917,7 @@ static struct ane_expl *expl_act_not_enabl(struct unit *punit,
                                               can_upgrade_unittype(
                                                   act_player, act_utype));
   } else if (paction
-             && (blocker = action_is_blocked_by(paction, punit,
+             && (blocker = action_is_blocked_by(nmap, paction, punit,
                                                 target_tile, target_city,
                                                 target_unit))) {
     explnat->kind = ANEK_ACTION_BLOCKS;
-- 
2.43.0

