From 51f4ee5daca48e85ef6de1e09dc3da8596ea9763 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 17 Mar 2024 23:01:20 +0200
Subject: [PATCH 38/38] Unhardcode wld.map from
 is_action_enabled_unit_on_city()

See RM #320

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/daicity.c               |  5 +++--
 ai/default/daitools.c              | 32 ++++++++++++++++--------------
 ai/default/daiunit.c               | 14 +++++++------
 common/actions.c                   |  8 ++++----
 common/actions.h                   |  3 ++-
 common/unit.c                      |  4 +++-
 server/actiontools.c               |  6 ++++--
 server/scripting/api_server_edit.c |  6 +++---
 server/unithand.c                  | 15 ++++++++------
 9 files changed, 53 insertions(+), 40 deletions(-)

diff --git a/ai/default/daicity.c b/ai/default/daicity.c
index ae97dc9cb9..4f5d99b150 100644
--- a/ai/default/daicity.c
+++ b/ai/default/daicity.c
@@ -452,6 +452,7 @@ static void unit_do_disband_trad(struct player *owner, struct unit *punit,
                                  const enum action_requester requester)
 {
   const int punit_id_stored = punit->id;
+  const struct civ_map *nmap = &(wld.map);
 
   fc_assert_ret(owner == unit_owner(punit));
 
@@ -464,7 +465,7 @@ static void unit_do_disband_trad(struct player *owner, struct unit *punit,
     tgt_city = tile_city(unit_tile(punit));
 
     if (tgt_city
-        && is_action_enabled_unit_on_city(ACTION_HELP_WONDER,
+        && is_action_enabled_unit_on_city(nmap, ACTION_HELP_WONDER,
                                           punit, tgt_city)) {
       if (unit_perform_action(owner, punit->id, tgt_city->id,
                               0, NULL, ACTION_HELP_WONDER, requester)) {
@@ -488,7 +489,7 @@ static void unit_do_disband_trad(struct player *owner, struct unit *punit,
     tgt_city = tile_city(unit_tile(punit));
 
     if (tgt_city
-        && is_action_enabled_unit_on_city(ACTION_DISBAND_UNIT_RECOVER,
+        && is_action_enabled_unit_on_city(nmap, ACTION_DISBAND_UNIT_RECOVER,
                                           punit, tgt_city)) {
       if (unit_perform_action(owner, punit->id, tgt_city->id,
                               0, NULL, ACTION_DISBAND_UNIT_RECOVER, requester)) {
diff --git a/ai/default/daitools.c b/ai/default/daitools.c
index 16a1227139..2b75b63eee 100644
--- a/ai/default/daitools.c
+++ b/ai/default/daitools.c
@@ -819,6 +819,7 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
   int sanity = punit->id;
   bool alive;
   struct city *tcity;
+  const struct civ_map *nmap = &(wld.map);
 
   CHECK_UNIT(punit);
   fc_assert_ret_val(is_ai(unit_owner(punit)), TRUE);
@@ -866,7 +867,7 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
                    0, "", ACTION_NUKE);
   } else if (action_id_get_target_kind(ACTION_NUKE) == ATK_CITY
              && (tcity = tile_city(ptile))
-             && is_action_enabled_unit_on_city(ACTION_NUKE,
+             && is_action_enabled_unit_on_city(nmap, ACTION_NUKE,
                                                punit, tcity)) {
     /* Choose "Explode Nuclear". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
@@ -879,7 +880,7 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
                    0, "", ACTION_NUKE_CITY);
   } else if (action_id_get_target_kind(ACTION_NUKE_CITY) == ATK_CITY
              && (tcity = tile_city(ptile))
-             && is_action_enabled_unit_on_city(ACTION_NUKE_CITY,
+             && is_action_enabled_unit_on_city(nmap, ACTION_NUKE_CITY,
                                                punit, tcity)) {
     /* Choose "Nuke City". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
@@ -895,51 +896,51 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_SUICIDE_ATTACK);
   } else if ((tcity = tile_city(ptile))
-             && is_action_enabled_unit_on_city(ACTION_CONQUER_CITY,
+             && is_action_enabled_unit_on_city(nmap, ACTION_CONQUER_CITY,
                                                punit, tcity)) {
     /* Choose "Conquer City". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
                    0, "", ACTION_CONQUER_CITY);
   } else if ((tcity = tile_city(ptile))
-             && is_action_enabled_unit_on_city(ACTION_CONQUER_CITY2,
+             && is_action_enabled_unit_on_city(nmap, ACTION_CONQUER_CITY2,
                                                punit, tcity)) {
     /* Choose "Conquer City 2". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
                    0, "", ACTION_CONQUER_CITY2);
   } else if ((tcity = tile_city(ptile))
-             && is_action_enabled_unit_on_city(ACTION_CONQUER_CITY3,
+             && is_action_enabled_unit_on_city(nmap, ACTION_CONQUER_CITY3,
                                                punit, tcity)) {
     /* Choose "Conquer City 3". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
                    0, "", ACTION_CONQUER_CITY3);
   } else if ((tcity = tile_city(ptile))
-             && is_action_enabled_unit_on_city(ACTION_CONQUER_CITY4,
+             && is_action_enabled_unit_on_city(nmap, ACTION_CONQUER_CITY4,
                                                punit, tcity)) {
     /* Choose "Conquer City 4". */
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
                    0, "", ACTION_CONQUER_CITY4);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ((ptrans = transporter_for_unit_at(punit, ptile)))
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK,
                                                punit, ptrans)) {
     /* "Transport Embark". */
     unit_do_action(unit_owner(punit), punit->id, ptrans->id,
                    0, "", ACTION_TRANSPORT_EMBARK);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ((ptrans = transporter_for_unit_at(punit, ptile)))
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2,
                                                punit, ptrans)) {
     /* "Transport Embark 2". */
     unit_do_action(unit_owner(punit), punit->id, ptrans->id,
                    0, "", ACTION_TRANSPORT_EMBARK2);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ((ptrans = transporter_for_unit_at(punit, ptile)))
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3,
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     unit_do_action(unit_owner(punit), punit->id, ptrans->id,
                    0, "", ACTION_TRANSPORT_EMBARK3);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ((ptrans = transporter_for_unit_at(punit, ptile)))
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK4,
                                                punit, ptrans)) {
@@ -1086,6 +1087,7 @@ bool dai_unit_move(struct ai_type *ait, struct unit *punit, struct tile *ptile)
   int sanity = punit->id;
   struct player *pplayer = unit_owner(punit);
   const bool is_plr_ai = is_ai(pplayer);
+  const struct civ_map *nmap = &(wld.map);
 
   CHECK_UNIT(punit);
   fc_assert_ret_val_msg(is_tiles_adjacent(unit_tile(punit), ptile), FALSE,
@@ -1119,25 +1121,25 @@ bool dai_unit_move(struct ai_type *ait, struct unit *punit, struct tile *ptile)
   }
 
   /* Select move kind. */
-  if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  if (!can_unit_survive_at_tile(nmap, punit, ptile)
       && ((ptrans = transporter_for_unit_at(punit, ptile)))
       && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK,
                                         punit, ptrans)) {
     /* "Transport Embark". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ptrans != NULL
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2,
                                                punit, ptrans)) {
     /* "Transport Embark 2". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK2);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ptrans != NULL
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3,
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK3);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, ptile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ptrans != NULL
              && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK4,
                                                punit, ptrans)) {
@@ -1208,7 +1210,7 @@ bool dai_unit_move(struct ai_type *ait, struct unit *punit, struct tile *ptile)
   if (action_has_result(paction, ACTRES_UNIT_MOVE)
       || action_has_result(paction, ACTRES_TRANSPORT_DISEMBARK)) {
     /* The unit will have to move it self rather than being moved. */
-    int mcost = map_move_cost_unit(&(wld.map), punit, ptile);
+    int mcost = map_move_cost_unit(nmap, punit, ptile);
 
     if (paction) {
       struct tile *from_tile;
diff --git a/ai/default/daiunit.c b/ai/default/daiunit.c
index 3e021238ef..0879e44ae1 100644
--- a/ai/default/daiunit.c
+++ b/ai/default/daiunit.c
@@ -1992,6 +1992,7 @@ static void dai_caravan_goto(struct ai_type *ait, struct player *pplayer,
 {
   bool alive = TRUE;
   struct unit_ai *unit_data = def_ai_unit_data(punit, ait);
+  const struct civ_map *nmap = &(wld.map);
 
   fc_assert_ret(NULL != dest_city);
 
@@ -2035,7 +2036,7 @@ static void dai_caravan_goto(struct ai_type *ait, struct player *pplayer,
     if (unit_transported(punit)) {
       aiferry_clear_boat(ait, punit);
     }
-    if (help_wonder && is_action_enabled_unit_on_city(ACTION_HELP_WONDER,
+    if (help_wonder && is_action_enabled_unit_on_city(nmap, ACTION_HELP_WONDER,
                                                       punit, dest_city)) {
         /*
          * We really don't want to just drop all caravans in immediately.
@@ -2050,7 +2051,7 @@ static void dai_caravan_goto(struct ai_type *ait, struct player *pplayer,
                city_name_get(dest_city));
       unit_do_action(pplayer, punit->id, dest_city->id,
                      0, "", ACTION_HELP_WONDER);
-    } else if (is_action_enabled_unit_on_city(ACTION_TRADE_ROUTE,
+    } else if (is_action_enabled_unit_on_city(nmap, ACTION_TRADE_ROUTE,
                                               punit, dest_city)) {
       log_base(LOG_CARAVAN, "%s %s[%d](%d,%d) creates trade route in %s",
                nation_rule_name(nation_of_unit(punit)),
@@ -2060,7 +2061,7 @@ static void dai_caravan_goto(struct ai_type *ait, struct player *pplayer,
                city_name_get(dest_city));
       unit_do_action(pplayer, punit->id, dest_city->id,
                      0, "", ACTION_TRADE_ROUTE);
-    } else if (is_action_enabled_unit_on_city(ACTION_MARKETPLACE,
+    } else if (is_action_enabled_unit_on_city(nmap, ACTION_MARKETPLACE,
                                               punit, dest_city)) {
       /* Get the one time bonus. */
       log_base(LOG_CARAVAN, "%s %s[%d](%d,%d) enters marketplace of %s",
@@ -2270,6 +2271,7 @@ static void dai_manage_caravan(struct ai_type *ait, struct player *pplayer,
   bool required_boat = FALSE;
   bool request_boat = FALSE;
   bool tired_of_waiting_boat = FALSE;
+  const struct civ_map *nmap = &(wld.map);
 
   CHECK_UNIT(punit);
 
@@ -2318,13 +2320,13 @@ static void dai_manage_caravan(struct ai_type *ait, struct player *pplayer,
             && !city_production_gets_caravan_shields(&city_dest->production))
         || (unit_data->task == AIUNIT_TRADE
             && real_map_distance(city_dest->tile, unit_tile(punit)) <= 1
-            && !(is_action_enabled_unit_on_city(ACTION_TRADE_ROUTE,
+            && !(is_action_enabled_unit_on_city(nmap, ACTION_TRADE_ROUTE,
                                                 punit, city_dest)
-                 || is_action_enabled_unit_on_city(ACTION_MARKETPLACE,
+                 || is_action_enabled_unit_on_city(nmap, ACTION_MARKETPLACE,
                                                    punit, city_dest)))
         || (unit_data->task == AIUNIT_WONDER
             && real_map_distance(city_dest->tile, unit_tile(punit)) <= 1
-            && !is_action_enabled_unit_on_city(ACTION_HELP_WONDER,
+            && !is_action_enabled_unit_on_city(nmap, ACTION_HELP_WONDER,
                                                punit, city_dest))) {
       /* destination invalid! */
       dai_unit_new_task(ait, punit, AIUNIT_NONE, NULL);
diff --git a/common/actions.c b/common/actions.c
index c2496a673b..fd1e74f216 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -2244,6 +2244,7 @@ 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);
@@ -2262,7 +2263,7 @@ struct action *action_is_blocked_by(const struct action *act,
         /* Can't be enabled. No target. */
         continue;
       }
-      if (is_action_enabled_unit_on_city(blocker->id,
+      if (is_action_enabled_unit_on_city(nmap, blocker->id,
                                          actor_unit, target_city)) {
         return blocker;
       }
@@ -3036,12 +3037,11 @@ is_action_enabled_unit_on_city_full(const struct civ_map *nmap,
 
   See note in is_action_enabled() for why the action may still be disabled.
 **************************************************************************/
-bool is_action_enabled_unit_on_city(const action_id wanted_action,
+bool is_action_enabled_unit_on_city(const struct civ_map *nmap,
+                                    const action_id wanted_action,
                                     const struct unit *actor_unit,
                                     const struct city *target_city)
 {
-  const struct civ_map *nmap = &(wld.map);
-
   return is_action_enabled_unit_on_city_full(nmap, wanted_action, actor_unit,
                                              unit_home(actor_unit),
                                              unit_tile(actor_unit),
diff --git a/common/actions.h b/common/actions.h
index 45de38f3b3..ae546da8d5 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -520,7 +520,8 @@ struct action *action_is_blocked_by(const struct action *act,
                                     const struct city *target_city,
                                     const struct unit *target_unit);
 
-bool is_action_enabled_unit_on_city(const action_id wanted_action,
+bool is_action_enabled_unit_on_city(const struct civ_map *nmap,
+                                    const action_id wanted_action,
                                     const struct unit *actor_unit,
                                     const struct city *target_city);
 
diff --git a/common/unit.c b/common/unit.c
index 46d048def5..8f3baf0c3d 100644
--- a/common/unit.c
+++ b/common/unit.c
@@ -186,10 +186,12 @@ enum unit_airlift_result
 bool unit_can_airlift_to(const struct unit *punit,
                          const struct city *pdest_city)
 {
+  const struct civ_map *nmap = &(wld.map);
+
   fc_assert_ret_val(pdest_city, FALSE);
 
   if (is_server()) {
-    return is_action_enabled_unit_on_city(ACTION_AIRLIFT,
+    return is_action_enabled_unit_on_city(nmap, ACTION_AIRLIFT,
                                           punit, pdest_city);
   } else {
     return action_prob_possible(action_prob_vs_city(punit, ACTION_AIRLIFT,
diff --git a/server/actiontools.c b/server/actiontools.c
index 66599b4fec..b76b2d68ff 100644
--- a/server/actiontools.c
+++ b/server/actiontools.c
@@ -1003,6 +1003,7 @@ action_auto_perf_unit_do(const enum action_auto_perf_cause cause,
   const struct city *tgt_city;
   const struct tile *tgt_tile;
   const struct unit *tgt_unit;
+  const struct civ_map *nmap = &(wld.map);
 
   const struct action_auto_perf *autoperf
     = action_auto_perf_unit_sel(cause, actor, other_player,
@@ -1054,7 +1055,7 @@ action_auto_perf_unit_do(const enum action_auto_perf_cause cause,
         break;
       case ATK_CITY:
         if (tgt_city
-            && is_action_enabled_unit_on_city(act, actor, tgt_city)) {
+            && is_action_enabled_unit_on_city(nmap, act, actor, tgt_city)) {
           perform_action_to(act, actor, tgt_city->id, EXTRA_NONE)
         }
         break;
@@ -1104,6 +1105,7 @@ action_auto_perf_unit_prob(const enum action_auto_perf_cause cause,
   const struct city *tgt_city;
   const struct tile *tgt_tile;
   const struct unit *tgt_unit;
+  const struct civ_map *nmap = &(wld.map);
 
   const struct action_auto_perf *autoperf
     = action_auto_perf_unit_sel(cause, actor, other_player,
@@ -1148,7 +1150,7 @@ action_auto_perf_unit_prob(const enum action_auto_perf_cause cause,
         break;
       case ATK_CITY:
         if (tgt_city
-            && is_action_enabled_unit_on_city(act, actor, tgt_city)) {
+            && is_action_enabled_unit_on_city(nmap, act, actor, tgt_city)) {
           current = action_prob_vs_city(actor, act, tgt_city);
         }
         break;
diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c
index f36658a6e2..103358602d 100644
--- a/server/scripting/api_server_edit.c
+++ b/server/scripting/api_server_edit.c
@@ -271,7 +271,7 @@ bool api_edit_perform_action_unit_vs_city(lua_State *L, Unit *punit,
   fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
   fc_assert_ret_val(action_get_target_kind(paction) == ATK_CITY, FALSE);
   fc_assert_ret_val(!action_has_result(paction, ACTRES_FOUND_CITY), FALSE);
-  if (is_action_enabled_unit_on_city(paction->id, punit, tgt)) {
+  if (is_action_enabled_unit_on_city(&(wld.map), paction->id, punit, tgt)) {
     return unit_perform_action(unit_owner(punit), punit->id,
                                tgt->id, IDENTITY_NUMBER_ZERO, "",
                                paction->id, ACT_REQ_RULES);
@@ -297,7 +297,7 @@ bool api_edit_perform_action_unit_vs_city_impr(lua_State *L, Unit *punit,
   fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
   fc_assert_ret_val(action_get_target_kind(paction) == ATK_CITY, FALSE);
   fc_assert_ret_val(!action_has_result(paction, ACTRES_FOUND_CITY), FALSE);
-  if (is_action_enabled_unit_on_city(paction->id, punit, tgt)) {
+  if (is_action_enabled_unit_on_city(&(wld.map), paction->id, punit, tgt)) {
     return unit_perform_action(unit_owner(punit), punit->id,
                                tgt->id, sub_tgt->item_number, "",
                                paction->id, ACT_REQ_RULES);
@@ -323,7 +323,7 @@ bool api_edit_perform_action_unit_vs_city_tech(lua_State *L, Unit *punit,
   fc_assert_ret_val(action_get_actor_kind(paction) == AAK_UNIT, FALSE);
   fc_assert_ret_val(action_get_target_kind(paction) == ATK_CITY, FALSE);
   fc_assert_ret_val(!action_has_result(paction, ACTRES_FOUND_CITY), FALSE);
-  if (is_action_enabled_unit_on_city(paction->id, punit, tgt)) {
+  if (is_action_enabled_unit_on_city(&(wld.map), paction->id, punit, tgt)) {
     return unit_perform_action(unit_owner(punit), punit->id,
                                tgt->id, sub_tgt->item_number, "",
                                paction->id, ACT_REQ_RULES);
diff --git a/server/unithand.c b/server/unithand.c
index e3c9a144cf..553bf87621 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -190,6 +190,7 @@ void handle_unit_type_upgrade(struct player *pplayer, Unit_type_id uti)
   struct unit_type *from_unittype = utype_by_number(uti);
   int number_of_upgraded_units = 0;
   struct action *paction = action_by_number(ACTION_UPGRADE_UNIT);
+  const struct civ_map *nmap = &(wld.map);
 
   if (NULL == from_unittype) {
     /* Probably died or bribed. */
@@ -214,7 +215,7 @@ void handle_unit_type_upgrade(struct player *pplayer, Unit_type_id uti)
     if (unit_type_get(punit) == from_unittype) {
       struct city *pcity = tile_city(unit_tile(punit));
 
-      if (is_action_enabled_unit_on_city(paction->id, punit, pcity)
+      if (is_action_enabled_unit_on_city(nmap, paction->id, punit, pcity)
           && unit_perform_action(pplayer, punit->id, pcity->id, 0, "",
                                  paction->id, ACT_REQ_SS_AGENT)) {
         number_of_upgraded_units++;
@@ -3183,6 +3184,7 @@ void handle_unit_action_query(struct connection *pc,
   struct action *paction = action_by_number(action_type);
   struct unit *punit = game_unit_by_number(target_id);
   struct city *pcity = game_city_by_number(target_id);
+  const struct civ_map *nmap = &(wld.map);
 
   if (NULL == paction) {
     /* Non existing action */
@@ -3220,7 +3222,7 @@ void handle_unit_action_query(struct connection *pc,
     break;
   case ACTRES_SPY_INCITE_CITY:
     if (pcity
-        && is_action_enabled_unit_on_city(action_type,
+        && is_action_enabled_unit_on_city(nmap, action_type,
                                           pactor, pcity)) {
       dsend_packet_unit_action_answer(pc,
                                       actor_id, target_id,
@@ -3236,7 +3238,7 @@ void handle_unit_action_query(struct connection *pc,
     break;
   case ACTRES_UPGRADE_UNIT:
     if (pcity
-        && is_action_enabled_unit_on_city(action_type,
+        && is_action_enabled_unit_on_city(nmap, action_type,
                                           pactor, pcity)) {
       const struct unit_type *tgt_utype;
       int upgr_cost;
@@ -3262,7 +3264,7 @@ void handle_unit_action_query(struct connection *pc,
   case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
   case ACTRES_STRIKE_BUILDING:
     if (pcity
-        && is_action_enabled_unit_on_city(action_type,
+        && is_action_enabled_unit_on_city(nmap, action_type,
                                           pactor, pcity)) {
       spy_send_sabotage_list(pc, pactor, pcity,
                              action_by_number(action_type), request_kind);
@@ -3337,6 +3339,7 @@ bool unit_perform_action(struct player *pplayer,
   struct impr_type *sub_tgt_impr;
   struct unit *punit = NULL;
   struct city *pcity = NULL;
+  const struct civ_map *nmap = &(wld.map);
 
   if (!action_id_exists(action_type)) {
     /* Non existing action */
@@ -3460,8 +3463,8 @@ bool unit_perform_action(struct player *pplayer,
 
 #define ACTION_PERFORM_UNIT_CITY(action, actor, target, action_performer) \
   if (pcity                                                               \
-      && is_action_enabled_unit_on_city(action_type,                      \
-                                       actor_unit, pcity)) {              \
+      && is_action_enabled_unit_on_city(nmap, action_type,                \
+                                        actor_unit, pcity)) {             \
     bool success;                                                         \
     script_server_signal_emit("action_started_unit_city",                 \
                               action_by_number(action), actor, target);   \
-- 
2.43.0

