From 5cfe922bc82f85f9509971b31f218422c6958b9f Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Mon, 1 Apr 2024 01:58:30 +0300
Subject: [PATCH 19/19] Unhardcode wld.map from
 is_action_enabled_unit_on_tile()

See RM #390

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/aiparatrooper.c         |  2 +-
 ai/default/aitools.c               | 60 +++++++++++++++---------------
 common/actions.c                   |  7 ++--
 common/actions.h                   |  3 +-
 common/unit.c                      | 20 +++++-----
 server/actiontools.c               |  7 ++--
 server/advisors/advgoto.c          | 28 +++++++-------
 server/scripting/api_server_edit.c |  4 +-
 server/unithand.c                  | 24 ++++++------
 9 files changed, 78 insertions(+), 77 deletions(-)

diff --git a/ai/default/aiparatrooper.c b/ai/default/aiparatrooper.c
index 97b7da85c1..16fe3f8be9 100644
--- a/ai/default/aiparatrooper.c
+++ b/ai/default/aiparatrooper.c
@@ -248,7 +248,7 @@ void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer,
                                                tile_city(ptile_dest), NULL,
                                                ptile_dest, NULL));
         } else {
-          possible = is_action_enabled_unit_on_tile(paction->id, punit,
+          possible = is_action_enabled_unit_on_tile(nmap, paction->id, punit,
                                                     ptile_dest, NULL);
         }
 
diff --git a/ai/default/aitools.c b/ai/default/aitools.c
index 7b5d5eee9c..c1513eda37 100644
--- a/ai/default/aitools.c
+++ b/ai/default/aitools.c
@@ -856,7 +856,7 @@ 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_NUKE_UNITS);
   } else if (action_id_get_target_kind(ACTION_NUKE) == ATK_TILE
-             && is_action_enabled_unit_on_tile(ACTION_NUKE,
+             && is_action_enabled_unit_on_tile(nmap, ACTION_NUKE,
                                                punit, ptile, NULL)) {
     /* Choose "Explode Nuclear". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
@@ -869,7 +869,7 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
     unit_do_action(unit_owner(punit), punit->id, tcity->id,
                    0, "", ACTION_NUKE);
   } else if (action_id_get_target_kind(ACTION_NUKE_CITY) == ATK_TILE
-             && is_action_enabled_unit_on_tile(ACTION_NUKE_CITY,
+             && is_action_enabled_unit_on_tile(nmap, ACTION_NUKE_CITY,
                                                punit, ptile, NULL)) {
     /* Choose "Nuke City". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
@@ -936,22 +936,22 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
     /* "Transport Embark 3". */
     unit_do_action(unit_owner(punit), punit->id, ptrans->id,
                    0, "", ACTION_TRANSPORT_EMBARK3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK1,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK1,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_TRANSPORT_DISEMBARK1);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK2,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 2". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_TRANSPORT_DISEMBARK2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK3,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 3". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_TRANSPORT_DISEMBARK3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK4,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 4". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
@@ -980,52 +980,52 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
     /* Choose "Conquer Extras 4". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_CONQUER_EXTRAS4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER,
                                             punit, ptile, NULL)) {
     /* Choose "Enter Hut". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_ENTER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER2,
                                             punit, ptile, NULL)) {
     /* Choose "Enter Hut 2". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_ENTER2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER3,
                                             punit, ptile, NULL)) {
     /* Choose "Enter Hut 3". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_ENTER3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER4,
                                             punit, ptile, NULL)) {
     /* Choose "Enter Hut 4". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_ENTER4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN,
                                             punit, ptile, NULL)) {
     /* Choose "Frighten Hut". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_FRIGHTEN);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN2,
                                             punit, ptile, NULL)) {
     /* Choose "Frighten Hut 2". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_FRIGHTEN2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN3,
                                             punit, ptile, NULL)) {
     /* Choose "Frighten Hut 3". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_FRIGHTEN3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN4,
                                             punit, ptile, NULL)) {
     /* Choose "Frighten Hut 4". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_HUT_FRIGHTEN4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE,
                                             punit, ptile, NULL)) {
     /* Choose "Unit Move". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
                    0, "", ACTION_UNIT_MOVE);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE2,
                                             punit, ptile, NULL)) {
     /* Choose "Unit Move 2". */
     unit_do_action(unit_owner(punit), punit->id, tile_index(ptile),
@@ -1128,59 +1128,59 @@ bool dai_unit_move(struct ai_type *ait, struct unit *punit, struct tile *ptile)
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK1,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK1,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK1);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK2,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 2". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK3,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 3". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK4,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 4". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER,
                                             punit, ptile, NULL)) {
     /* "Enter Hut". */
     paction = action_by_number(ACTION_HUT_ENTER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER2,
                                             punit, ptile, NULL)) {
     /* "Enter Hut 2". */
     paction = action_by_number(ACTION_HUT_ENTER2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER3,
                                             punit, ptile, NULL)) {
     /* "Enter Hut 3". */
     paction = action_by_number(ACTION_HUT_ENTER3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER4,
                                             punit, ptile, NULL)) {
     /* "Enter Hut 4". */
     paction = action_by_number(ACTION_HUT_ENTER4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN2,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut 2". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN3,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut 3". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN4,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut 4". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE,
                                             punit, ptile, NULL)) {
     /* "Unit Move". */
     paction = action_by_number(ACTION_UNIT_MOVE);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE2,
                                             punit, ptile, NULL)) {
     /* "Unit Move 2". */
     paction = action_by_number(ACTION_UNIT_MOVE2);
diff --git a/common/actions.c b/common/actions.c
index 302a0d0cb4..c7c343e805 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -3272,7 +3272,7 @@ struct action *action_is_blocked_by(const struct action *act,
         /* Can't be enabled. No target. */
         continue;
       }
-      if (is_action_enabled_unit_on_tile(blocker->id,
+      if (is_action_enabled_unit_on_tile(nmap, blocker->id,
                                          actor_unit, target_tile, NULL)) {
         return blocker;
       }
@@ -4993,13 +4993,12 @@ is_action_enabled_unit_on_tile_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_tile(const action_id wanted_action,
+bool is_action_enabled_unit_on_tile(const struct civ_map *nmap,
+                                    const action_id wanted_action,
                                     const struct unit *actor_unit,
                                     const struct tile *target_tile,
                                     const struct extra_type *target_extra)
 {
-  const struct civ_map *nmap = &(wld.map);
-
   return is_action_enabled_unit_on_tile_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 7b3dda4c35..25d3af22d6 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -797,7 +797,8 @@ bool is_action_enabled_unit_on_units(const struct civ_map *nmap,
                                      const struct unit *actor_unit,
                                      const struct tile *target_tile);
 
-bool is_action_enabled_unit_on_tile(const action_id wanted_action,
+bool is_action_enabled_unit_on_tile(const struct civ_map *nmap,
+                                    const action_id wanted_action,
                                     const struct unit *actor_unit,
                                     const struct tile *target_tile,
                                     const struct extra_type *target_extra);
diff --git a/common/unit.c b/common/unit.c
index d26580609a..0c56be3436 100644
--- a/common/unit.c
+++ b/common/unit.c
@@ -945,7 +945,7 @@ bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
 {                                                                         \
     switch (action_get_target_kind(paction)) {                            \
     case ATK_TILE:                                                        \
-      return is_action_enabled_unit_on_tile(paction->id,                  \
+      return is_action_enabled_unit_on_tile(nmap, paction->id,            \
                                             punit, ptile, target);        \
     case ATK_EXTRAS:                                                      \
       return is_action_enabled_unit_on_extras(paction->id,                \
@@ -972,42 +972,42 @@ bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_CLEAN_POLLUTION,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_CLEAN_POLLUTION,
                                           punit, ptile, target);
 
   case ACTIVITY_FALLOUT:
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_CLEAN_FALLOUT,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_CLEAN_FALLOUT,
                                           punit, ptile, target);
 
   case ACTIVITY_MINE:
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_MINE, punit,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_MINE, punit,
                                           ptile, target);
 
   case ACTIVITY_PLANT:
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_PLANT,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_PLANT,
                                           punit, ptile, NULL);
 
   case ACTIVITY_IRRIGATE:
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_IRRIGATE, punit,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_IRRIGATE, punit,
                                           ptile, target);
 
   case ACTIVITY_CULTIVATE:
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_CULTIVATE,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_CULTIVATE,
                                           punit, ptile, NULL);
 
   case ACTIVITY_FORTIFYING:
@@ -1024,14 +1024,14 @@ bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_BASE,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_BASE,
                                           punit, ptile, target);
 
   case ACTIVITY_GEN_ROAD:
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_ROAD,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_ROAD,
                                           punit, ptile, target);
 
   case ACTIVITY_SENTRY:
@@ -1055,7 +1055,7 @@ bool can_unit_do_activity_targeted_at(const struct civ_map *nmap,
     /* The call below doesn't support actor tile speculation. */
     fc_assert_msg(unit_tile(punit) == ptile,
                   "Please use action_speculate_unit_on_tile()");
-    return is_action_enabled_unit_on_tile(ACTION_TRANSFORM_TERRAIN,
+    return is_action_enabled_unit_on_tile(nmap, ACTION_TRANSFORM_TERRAIN,
                                           punit, ptile, NULL);
 
   case ACTIVITY_CONVERT:
diff --git a/server/actiontools.c b/server/actiontools.c
index f5003bf572..3d63375a6c 100644
--- a/server/actiontools.c
+++ b/server/actiontools.c
@@ -1037,8 +1037,8 @@ action_auto_perf_unit_do(const enum action_auto_perf_cause cause,
         break;
       case ATK_TILE:
         if (tgt_tile
-            && is_action_enabled_unit_on_tile(act, actor, tgt_tile,
-                                              target_extra)) {
+            && is_action_enabled_unit_on_tile(nmap, act, actor,
+                                              tgt_tile, target_extra)) {
           perform_action_to(act, actor, tgt_tile->index,
                             target_extra ? extra_number(target_extra) : -1);
         }
@@ -1134,7 +1134,8 @@ action_auto_perf_unit_prob(const enum action_auto_perf_cause cause,
         break;
       case ATK_TILE:
         if (tgt_tile
-            && is_action_enabled_unit_on_tile(act, actor, tgt_tile, target_extra)) {
+            && is_action_enabled_unit_on_tile(nmap, act, actor,
+                                              tgt_tile, target_extra)) {
           current = action_prob_vs_tile(actor, act, tgt_tile, target_extra);
         }
         break;
diff --git a/server/advisors/advgoto.c b/server/advisors/advgoto.c
index 6d60be51b0..6e11905665 100644
--- a/server/advisors/advgoto.c
+++ b/server/advisors/advgoto.c
@@ -183,59 +183,59 @@ static bool adv_unit_move(struct unit *punit, struct tile *ptile)
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK1,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK1,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK1);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK2,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 2". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK3,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 3". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK4,
                                             punit, ptile, NULL)) {
     /* "Transport Disembark 4". */
     paction = action_by_number(ACTION_TRANSPORT_DISEMBARK4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER,
                                             punit, ptile, NULL)) {
     /* "Enter Hut". */
     paction = action_by_number(ACTION_HUT_ENTER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER2,
                                             punit, ptile, NULL)) {
     /* "Enter Hut 2". */
     paction = action_by_number(ACTION_HUT_ENTER2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER3,
                                             punit, ptile, NULL)) {
     /* "Enter Hut 3". */
     paction = action_by_number(ACTION_HUT_ENTER3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER4,
                                             punit, ptile, NULL)) {
     /* "Enter Hut 4". */
     paction = action_by_number(ACTION_HUT_ENTER4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN2,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut 2". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN2);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN3,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut 3". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN3);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN4,
                                             punit, ptile, NULL)) {
     /* "Frighten Hut 4". */
     paction = action_by_number(ACTION_HUT_FRIGHTEN4);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE,
                                             punit, ptile, NULL)) {
     /* "Unit Move". */
     paction = action_by_number(ACTION_UNIT_MOVE);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE2,
                                             punit, ptile, NULL)) {
     /* "Unit Move 2". */
     paction = action_by_number(ACTION_UNIT_MOVE2);
diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c
index eaf0d7fdbb..228606e6c7 100644
--- a/server/scripting/api_server_edit.c
+++ b/server/scripting/api_server_edit.c
@@ -454,7 +454,7 @@ bool api_edit_perform_action_unit_vs_tile(lua_State *L, Unit *punit,
     enabled = is_action_enabled_unit_on_units(nmap, paction->id, punit, tgt);
     break;
   case ATK_TILE:
-    enabled = is_action_enabled_unit_on_tile(paction->id, punit,
+    enabled = is_action_enabled_unit_on_tile(nmap, paction->id, punit,
                                              tgt, NULL);
     break;
   case ATK_EXTRAS:
@@ -516,7 +516,7 @@ bool api_edit_perform_action_unit_vs_tile_extra(lua_State *L, Unit *punit,
     enabled = is_action_enabled_unit_on_units(nmap, paction->id, punit, tgt);
     break;
   case ATK_TILE:
-    enabled = is_action_enabled_unit_on_tile(paction->id, punit,
+    enabled = is_action_enabled_unit_on_tile(nmap, paction->id, punit,
                                              tgt, sub_target);
     break;
   case ATK_EXTRAS:
diff --git a/server/unithand.c b/server/unithand.c
index 4574fbca91..e34a6331a6 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -3420,7 +3420,7 @@ bool unit_perform_action(struct player *pplayer,
 
 #define ACTION_PERFORM_UNIT_TILE(action, actor, target, action_performer) \
   if (target_tile                                                         \
-      && is_action_enabled_unit_on_tile(action_type,                      \
+      && is_action_enabled_unit_on_tile(nmap, action_type,                \
                                         actor_unit, target_tile,          \
                                         target_extra)) {                  \
     bool success;                                                         \
@@ -5313,17 +5313,17 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile,
 
   /*** Phase 2: OK now move the unit ***/
   /* This is a regular move, subject to the rules. */
-  if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE,
+  if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE,
                                      punit, pdesttile, NULL)) {
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_UNIT_MOVE,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE2,
                                             punit, pdesttile, NULL)) {
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_UNIT_MOVE2,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_UNIT_MOVE3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_UNIT_MOVE3,
                                             punit, pdesttile, NULL)) {
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_UNIT_MOVE3,
@@ -5352,49 +5352,49 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile,
     return unit_perform_action(pplayer, punit->id, ptrans->id,
                                NO_TARGET, "", ACTION_TRANSPORT_EMBARK3,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK1,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK1,
                                             punit, pdesttile, NULL)) {
     /* "Transport Disembark". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK1,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK2,
                                             punit, pdesttile, NULL)) {
     /* "Transport Disembark 2". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK2,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK3,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK3,
                                             punit, pdesttile, NULL)) {
     /* "Transport Disembark 3". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK3,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_TRANSPORT_DISEMBARK4,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_TRANSPORT_DISEMBARK4,
                                             punit, pdesttile, NULL)) {
     /* "Transport Disembark 4". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_TRANSPORT_DISEMBARK4,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER,
                                             punit, pdesttile, NULL)) {
     /* "Enter Hut". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_HUT_ENTER,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_ENTER2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_ENTER2,
                                             punit, pdesttile, NULL)) {
     /* "Enter Hut 2". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_HUT_ENTER2,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN,
                                             punit, pdesttile, NULL)) {
     /* "Frighten Hut". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_HUT_FRIGHTEN,
                                ACT_REQ_PLAYER);
-  } else if (is_action_enabled_unit_on_tile(ACTION_HUT_FRIGHTEN2,
+  } else if (is_action_enabled_unit_on_tile(nmap, ACTION_HUT_FRIGHTEN2,
                                             punit, pdesttile, NULL)) {
     /* "Frighten Hut 2". */
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
-- 
2.43.0

