From e3d17d5a830ec1d024021ab968ec2ab7d9552463 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 22 Mar 2024 23:36:47 +0200
Subject: [PATCH 21/21] Unhardcode wld.map from
 is_action_enabled_unit_on_unit()

See RM #340

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/aidiplomat.c            |  5 +++--
 ai/default/aihunt.c                |  4 ++--
 ai/default/aitools.c               | 12 ++++++------
 common/actions.c                   |  7 +++----
 common/actions.h                   |  3 ++-
 common/unit.c                      |  6 ++++--
 server/actiontools.c               |  4 ++--
 server/advisors/advgoto.c          | 17 +++++++++--------
 server/barbarian.c                 | 18 ++++++++++--------
 server/scripting/api_server_edit.c |  4 +++-
 server/unithand.c                  | 29 +++++++++++++++--------------
 11 files changed, 59 insertions(+), 50 deletions(-)

diff --git a/ai/default/aidiplomat.c b/ai/default/aidiplomat.c
index 559595a710..3e3ae98e69 100644
--- a/ai/default/aidiplomat.c
+++ b/ai/default/aidiplomat.c
@@ -587,6 +587,7 @@ static bool dai_diplomat_bribe_nearby(struct ai_type *ait,
                                       struct unit *punit, struct pf_map *pfm)
 {
   int gold_avail, expenses;
+  const struct civ_map *nmap = &(wld.map);
 
   dai_calc_data(pplayer, NULL, &expenses, NULL);
   gold_avail = pplayer->economic.gold - expenses;
@@ -608,7 +609,7 @@ static bool dai_diplomat_bribe_nearby(struct ai_type *ait,
         || !POTENTIALLY_HOSTILE_PLAYER(ait, pplayer, unit_owner(pvictim))
         || unit_list_size(ptile->units) > 1
         || tile_city(ptile)
-        || !is_action_enabled_unit_on_unit(ACTION_SPY_BRIBE_UNIT,
+        || !is_action_enabled_unit_on_unit(nmap, ACTION_SPY_BRIBE_UNIT,
                                            punit, pvictim)) {
       continue;
     }
@@ -659,7 +660,7 @@ static bool dai_diplomat_bribe_nearby(struct ai_type *ait,
       struct tile *bribee_tile;
       struct pf_path *path;
 
-      bribee_tile = mapstep(&(wld.map), pos.tile, DIR_REVERSE(pos.dir_to_here));
+      bribee_tile = mapstep(nmap, pos.tile, DIR_REVERSE(pos.dir_to_here));
       path = pf_map_path(pfm, bribee_tile);
       if (!path || !adv_unit_execute_path(punit, path) 
           || punit->moves_left <= 0) {
diff --git a/ai/default/aihunt.c b/ai/default/aihunt.c
index 41c01a2bb4..6036499589 100644
--- a/ai/default/aihunt.c
+++ b/ai/default/aihunt.c
@@ -361,7 +361,7 @@ static void dai_hunter_try_launch(struct ai_type *ait,
           }
         } unit_list_iterate_end;
         if (sucker) {
-          break; /* found something - kill it! */
+          break; /* Found something - kill it! */
         }
       } pf_map_move_costs_iterate_end;
       pf_map_destroy(pfm);
@@ -370,7 +370,7 @@ static void dai_hunter_try_launch(struct ai_type *ait,
         if (unit_transported(missile)) {
           struct unit *ptrans = unit_transport_get(missile);
 
-          if (is_action_enabled_unit_on_unit(ACTION_TRANSPORT_ALIGHT,
+          if (is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_ALIGHT,
                                              missile, ptrans)) {
             unit_do_action(unit_owner(punit), punit->id, ptrans->id,
                            0, "", ACTION_TRANSPORT_ALIGHT);
diff --git a/ai/default/aitools.c b/ai/default/aitools.c
index 9bb286c2ab..e2d10dd1bf 100644
--- a/ai/default/aitools.c
+++ b/ai/default/aitools.c
@@ -917,21 +917,21 @@ bool dai_unit_attack(struct ai_type *ait, struct unit *punit, struct tile *ptile
                    0, "", ACTION_CONQUER_CITY4);
   } 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,
+             && is_action_enabled_unit_on_unit(nmap, 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(nmap, punit, ptile)
              && ((ptrans = transporter_for_unit_at(punit, ptile)))
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2,
+             && is_action_enabled_unit_on_unit(nmap, 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(nmap, punit, ptile)
              && ((ptrans = transporter_for_unit_at(punit, ptile)))
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK3,
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     unit_do_action(unit_owner(punit), punit->id, ptrans->id,
@@ -1112,19 +1112,19 @@ bool dai_unit_move(struct ai_type *ait, struct unit *punit, struct tile *ptile)
   /* Select move kind. */
   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,
+      && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK,
                                         punit, ptrans)) {
     /* "Transport Embark". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK);
   } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ptrans != NULL
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK2,
                                                punit, ptrans)) {
     /* "Transport Embark 2". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK2);
   } else if (!can_unit_survive_at_tile(nmap, punit, ptile)
              && ptrans != NULL
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK3,
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK3);
diff --git a/common/actions.c b/common/actions.c
index d42644e5e5..a597734fae 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -3252,7 +3252,7 @@ struct action *action_is_blocked_by(const struct action *act,
         /* Can't be enabled. No target. */
         continue;
       }
-      if (is_action_enabled_unit_on_unit(blocker->id,
+      if (is_action_enabled_unit_on_unit(nmap, blocker->id,
                                          actor_unit, target_unit)) {
         return blocker;
       }
@@ -4829,12 +4829,11 @@ is_action_enabled_unit_on_unit_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_unit(const action_id wanted_action,
+bool is_action_enabled_unit_on_unit(const struct civ_map *nmap,
+                                    const action_id wanted_action,
                                     const struct unit *actor_unit,
                                     const struct unit *target_unit)
 {
-  const struct civ_map *nmap = &(wld.map);
-
   return is_action_enabled_unit_on_unit_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 8e7b7f177c..375ab1d11d 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -787,7 +787,8 @@ bool is_action_enabled_unit_on_city(const struct civ_map *nmap,
                                     const struct unit *actor_unit,
                                     const struct city *target_city);
 
-bool is_action_enabled_unit_on_unit(const action_id wanted_action,
+bool is_action_enabled_unit_on_unit(const struct civ_map *nmap,
+                                    const action_id wanted_action,
                                     const struct unit *actor_unit,
                                     const struct unit *target_unit);
 
diff --git a/common/unit.c b/common/unit.c
index 3573db09b5..299658bbd4 100644
--- a/common/unit.c
+++ b/common/unit.c
@@ -792,6 +792,8 @@ bool can_unit_unload(const struct unit *pcargo, const struct unit *ptrans)
 bool can_unit_alight_or_be_unloaded(const struct unit *pcargo,
                                     const struct unit *ptrans)
 {
+  const struct civ_map *nmap = &(wld.map);
+
   if (!pcargo || !ptrans) {
     return FALSE;
   }
@@ -799,9 +801,9 @@ bool can_unit_alight_or_be_unloaded(const struct unit *pcargo,
   fc_assert_ret_val(unit_transport_get(pcargo) == ptrans, FALSE);
 
   if (is_server()) {
-    return (is_action_enabled_unit_on_unit(ACTION_TRANSPORT_ALIGHT,
+    return (is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_ALIGHT,
                                            pcargo, ptrans)
-            || is_action_enabled_unit_on_unit(ACTION_TRANSPORT_UNLOAD,
+            || is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_UNLOAD,
                                               ptrans, pcargo));
   } else {
     return (action_prob_possible(
diff --git a/server/actiontools.c b/server/actiontools.c
index 4422762b9a..cd02eab9bd 100644
--- a/server/actiontools.c
+++ b/server/actiontools.c
@@ -1059,7 +1059,7 @@ action_auto_perf_unit_do(const enum action_auto_perf_cause cause,
         break;
       case ATK_UNIT:
         if (tgt_unit
-            && is_action_enabled_unit_on_unit(act, actor, tgt_unit)) {
+            && is_action_enabled_unit_on_unit(nmap, act, actor, tgt_unit)) {
           perform_action_to(act, actor, tgt_unit->id, EXTRA_NONE);
         }
         break;
@@ -1154,7 +1154,7 @@ action_auto_perf_unit_prob(const enum action_auto_perf_cause cause,
         break;
       case ATK_UNIT:
         if (tgt_unit
-            && is_action_enabled_unit_on_unit(act, actor, tgt_unit)) {
+            && is_action_enabled_unit_on_unit(nmap, act, actor, tgt_unit)) {
           current = action_prob_vs_unit(actor, act, tgt_unit);
         }
         break;
diff --git a/server/advisors/advgoto.c b/server/advisors/advgoto.c
index face4b1a56..6d60be51b0 100644
--- a/server/advisors/advgoto.c
+++ b/server/advisors/advgoto.c
@@ -154,8 +154,9 @@ static bool adv_unit_move(struct unit *punit, struct tile *ptile)
   struct action *paction;
   struct player *pplayer = unit_owner(punit);
   struct unit *ptrans = NULL;
+  const struct civ_map *nmap = &(wld.map);
 
-  /* if enemy, stop and give a chance for the human player to
+  /* If enemy, stop and give a chance for the human player to
      handle this case */
   if (is_enemy_unit_tile(ptile, pplayer)
       || is_enemy_city_tile(ptile, pplayer)) {
@@ -164,21 +165,21 @@ static bool adv_unit_move(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,
+      && is_action_enabled_unit_on_unit(nmap, 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,
+             && is_action_enabled_unit_on_unit(nmap, 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,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK3,
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     paction = action_by_number(ACTION_TRANSPORT_EMBARK3);
@@ -247,7 +248,7 @@ static bool adv_unit_move(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/server/barbarian.c b/server/barbarian.c
index 822a83451a..8ef7110e14 100644
--- a/server/barbarian.c
+++ b/server/barbarian.c
@@ -282,6 +282,7 @@ bool unleash_barbarians(struct tile *ptile)
   int checked_count;
   int dir;
   bool barbarian_stays = FALSE;
+  const struct civ_map *nmap = &(wld.map);
 
   /* FIXME: When there is no L_BARBARIAN unit,
    *        but L_BARBARIAN_TECH is already available,
@@ -325,7 +326,7 @@ bool unleash_barbarians(struct tile *ptile)
   /* Get information about surrounding terrains in terrain class level.
    * Only needed if we consider moving units away to random directions. */
   for (dir = 0; dir < 8; dir++) {
-    dir_tiles[dir] = mapstep(&(wld.map), ptile, dir);
+    dir_tiles[dir] = mapstep(nmap, ptile, dir);
     if (dir_tiles[dir] == NULL) {
       terrainc[dir] = terrain_class_invalid();
     } else if (!is_non_allied_unit_tile(dir_tiles[dir], barbarians)) {
@@ -355,7 +356,7 @@ bool unleash_barbarians(struct tile *ptile)
              checked_count++) {
           int rdir = random_unchecked_direction(land_tiles - checked_count, checked);
 
-          if (unit_can_move_to_tile(&(wld.map), punit2, dir_tiles[rdir],
+          if (unit_can_move_to_tile(nmap, punit2, dir_tiles[rdir],
                                     TRUE, FALSE, FALSE)) {
             /* Move */
             (void) unit_move_pay(punit2, dir_tiles[rdir]);
@@ -401,17 +402,17 @@ bool unleash_barbarians(struct tile *ptile)
         /* We do have a boat. Try to get everybody in */
         unit_list_iterate_safe((ptile)->units, punit2) {
           if (unit_owner(punit2) == barbarians) {
-            if (is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK,
+            if (is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK,
                                                punit2, boat)) {
               /* Load */
               unit_do_action(unit_owner(punit2), punit2->id, boat->id,
                              0, "", ACTION_TRANSPORT_EMBARK);
-            } else if (is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2,
+            } else if (is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK2,
                                                       punit2, boat)) {
               /* Load */
               unit_do_action(unit_owner(punit2), punit2->id, boat->id,
                              0, "", ACTION_TRANSPORT_EMBARK2);
-            } else if (is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3,
+            } else if (is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK3,
                                                       punit2, boat)) {
               /* Load */
               unit_do_action(unit_owner(punit2), punit2->id, boat->id,
@@ -436,7 +437,7 @@ bool unleash_barbarians(struct tile *ptile)
 
             rdir = random_unchecked_direction(land_tiles - checked_count, checked);
 
-            if (unit_can_move_to_tile(&(wld.map), punit2, dir_tiles[rdir],
+            if (unit_can_move_to_tile(nmap, punit2, dir_tiles[rdir],
                                       TRUE, FALSE, FALSE)) {
               /* Move */
               (void) unit_move_pay(punit2, dir_tiles[rdir]);
@@ -535,13 +536,14 @@ static void try_summon_barbarians(void)
   bool hut_present = FALSE;
   int city_count;
   int city_max;
+  const struct civ_map *nmap = &(wld.map);
 
   /* We attempt the summons on a particular, random position.  If this is
    * an invalid position then the summons simply fails this time.  This means
    * that a particular tile's chance of being summoned on is independent of
    * all the other tiles on the map - which is essential for balanced
    * gameplay. */
-  ptile = rand_map_pos(&(wld.map));
+  ptile = rand_map_pos(nmap);
 
   if (terrain_has_flag(tile_terrain(ptile), TER_NO_BARBS)) {
     return;
@@ -659,7 +661,7 @@ static void try_summon_barbarians(void)
 
     if (is_native_tile(boat, utile)
         && !utype_player_already_has_this_unique(barbarians, boat)
-        && (is_safe_ocean(&(wld.map), utile)
+        && (is_safe_ocean(nmap, utile)
             || (!utype_has_flag(boat, UTYF_COAST_STRICT)
                 && !utype_has_flag(boat, UTYF_COAST)))) {
       int cap;
diff --git a/server/scripting/api_server_edit.c b/server/scripting/api_server_edit.c
index 3956e47cbe..c97743a69b 100644
--- a/server/scripting/api_server_edit.c
+++ b/server/scripting/api_server_edit.c
@@ -414,6 +414,8 @@ bool api_edit_perform_action_unit_vs_city_tech(lua_State *L, Unit *punit,
 bool api_edit_perform_action_unit_vs_unit(lua_State *L, Unit *punit,
                                           Action *paction, Unit *tgt)
 {
+  const struct civ_map *nmap = &(wld.map);
+
   LUASCRIPT_CHECK_STATE(L, FALSE);
   LUASCRIPT_CHECK_ARG_NIL(L, punit, 2, Unit, FALSE);
   LUASCRIPT_CHECK_ARG_NIL(L, paction, 3, Action, FALSE);
@@ -422,7 +424,7 @@ bool api_edit_perform_action_unit_vs_unit(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_UNIT, FALSE);
   fc_assert_ret_val(!action_has_result(paction, ACTRES_FOUND_CITY), FALSE);
-  if (is_action_enabled_unit_on_unit(paction->id, punit, tgt)) {
+  if (is_action_enabled_unit_on_unit(nmap, paction->id, punit, tgt)) {
     return unit_perform_action(unit_owner(punit), punit->id,
                                tgt->id, IDENTITY_NUMBER_ZERO, "",
                                paction->id, ACT_REQ_RULES);
diff --git a/server/unithand.c b/server/unithand.c
index dc41db501e..d0bb39eb8a 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -218,7 +218,7 @@ void handle_unit_type_upgrade(struct player *pplayer, Unit_type_id uti)
           && unit_perform_action(pplayer, punit->id, pcity->id, 0, "",
                                  paction->id, ACT_REQ_SS_AGENT)) {
         number_of_upgraded_units++;
-      } else if (UU_NO_MONEY == unit_upgrade_test(&(wld.map), punit, FALSE)) {
+      } else if (UU_NO_MONEY == unit_upgrade_test(nmap, punit, FALSE)) {
         break;
       }
     }
@@ -3049,7 +3049,7 @@ void handle_unit_action_query(struct connection *pc,
   switch (paction->result) {
   case ACTRES_SPY_BRIBE_UNIT:
     if (punit
-        && is_action_enabled_unit_on_unit(action_type,
+        && is_action_enabled_unit_on_unit(nmap, action_type,
                                           pactor, punit)) {
       dsend_packet_unit_action_answer(pc,
                                       actor_id32, actor_id16, target_id,
@@ -3229,7 +3229,7 @@ bool unit_perform_action(struct player *pplayer,
   case ATK_UNITS:
   case ATK_TILE:
   case ATK_EXTRAS:
-    target_tile = index_to_tile(&(wld.map), target_id);
+    target_tile = index_to_tile(nmap, target_id);
     if (target_tile == NULL) {
       log_verbose("unit_perform_action() invalid target tile %d",
                   target_id);
@@ -3363,7 +3363,7 @@ bool unit_perform_action(struct player *pplayer,
 
 #define ACTION_PERFORM_UNIT_UNIT(action, actor, target, action_performer) \
   if (punit                                                               \
-      && is_action_enabled_unit_on_unit(action_type, actor_unit, punit)) {\
+      && is_action_enabled_unit_on_unit(nmap, action_type, actor_unit, punit)) { \
     bool success;                                                         \
     script_server_signal_emit("action_started_unit_unit",                 \
                               action_by_number(action), actor, target);   \
@@ -4640,7 +4640,7 @@ static bool do_attack(struct unit *punit, struct tile *def_tile,
   moves_used = unit_move_rate(punit) - punit->moves_left;
   def_moves_used = unit_move_rate(pdefender) - pdefender->moves_left;
 
-  adj = base_get_direction_for_step(&(wld.map),
+  adj = base_get_direction_for_step(nmap,
                                     punit->tile, pdefender->tile, &facing);
 
   fc_assert(adj);
@@ -5236,6 +5236,7 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile,
 {
   struct player *pplayer = unit_owner(punit);
   struct unit *ptrans;
+  const struct civ_map *nmap = &(wld.map);
 
   /*** Phase 1: Attempted action interpretation checks ***/
 
@@ -5270,7 +5271,7 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile,
    * An attempted move to a tile a unit can't move to is always interpreted
    * as trying to perform an action (unless move_do_not_act is TRUE) */
   if (!move_do_not_act) {
-    const bool can_not_move = !unit_can_move_to_tile(&(wld.map),
+    const bool can_not_move = !unit_can_move_to_tile(nmap,
                                                      punit, pdesttile,
                                                      FALSE, FALSE, FALSE);
     bool one_action_may_be_legal
@@ -5324,25 +5325,25 @@ bool unit_move_handling(struct unit *punit, struct tile *pdesttile,
     return unit_perform_action(pplayer, punit->id, tile_index(pdesttile),
                                NO_TARGET, "", ACTION_UNIT_MOVE3,
                                ACT_REQ_PLAYER);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, pdesttile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, pdesttile)
              && ((ptrans = transporter_for_unit_at(punit, pdesttile)))
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK,
                                                punit, ptrans)) {
     /* "Transport Embark". */
     return unit_perform_action(pplayer, punit->id, ptrans->id,
                                NO_TARGET, "", ACTION_TRANSPORT_EMBARK,
                                ACT_REQ_PLAYER);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, pdesttile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, pdesttile)
              && ((ptrans = transporter_for_unit_at(punit, pdesttile)))
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK2,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK2,
                                                punit, ptrans)) {
     /* "Transport Embark 2". */
     return unit_perform_action(pplayer, punit->id, ptrans->id,
                                NO_TARGET, "", ACTION_TRANSPORT_EMBARK2,
                                ACT_REQ_PLAYER);
-  } else if (!can_unit_survive_at_tile(&(wld.map), punit, pdesttile)
+  } else if (!can_unit_survive_at_tile(nmap, punit, pdesttile)
              && ((ptrans = transporter_for_unit_at(punit, pdesttile)))
-             && is_action_enabled_unit_on_unit(ACTION_TRANSPORT_EMBARK3,
+             && is_action_enabled_unit_on_unit(nmap, ACTION_TRANSPORT_EMBARK3,
                                                punit, ptrans)) {
     /* "Transport Embark 3". */
     return unit_perform_action(pplayer, punit->id, ptrans->id,
@@ -5932,7 +5933,7 @@ void handle_unit_sscs_set(struct player *pplayer,
      * perform against the target tile. Action decision state can be set by
      * the server it self too. */
 
-    if (index_to_tile(&(wld.map), value) == NULL) {
+    if (index_to_tile(nmap, value) == NULL) {
       /* Asked to be reminded to ask what actions the unit can do to a non
        * existing target tile. */
       log_verbose("unit_sscs_set() invalid target tile %d for unit %d",
@@ -5941,7 +5942,7 @@ void handle_unit_sscs_set(struct player *pplayer,
     }
 
     punit->action_decision_want = ACT_DEC_ACTIVE;
-    punit->action_decision_tile = index_to_tile(&(wld.map), value);
+    punit->action_decision_tile = index_to_tile(nmap, value);
 
     /* Let the client know that this unit needs the player to decide
      * what to do. */
-- 
2.43.0

