From 8e20fb4f43d16adeda71f5cc1dbdbecce6fd3b22 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 1 Sep 2024 01:03:18 +0300
Subject: [PATCH 7/7] Unhardcode wld.map from action_prob_unit_vs_tgt()

See RM #819

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/aiparatrooper.c | 2 +-
 client/control.c           | 2 +-
 common/actions.c           | 4 ++--
 common/actions.h           | 3 ++-
 server/unithand.c          | 2 ++
 5 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/ai/default/aiparatrooper.c b/ai/default/aiparatrooper.c
index 42501513ae..7ed2d354a7 100644
--- a/ai/default/aiparatrooper.c
+++ b/ai/default/aiparatrooper.c
@@ -244,7 +244,7 @@ void dai_manage_paratrooper(struct ai_type *ait, struct player *pplayer,
 
         if (has_handicap(pplayer, H_FOG)) {
           possible = action_prob_possible(
-                       action_prob_unit_vs_tgt(paction, punit,
+                       action_prob_unit_vs_tgt(nmap, paction, punit,
                                                tile_city(ptile_dest), NULL,
                                                ptile_dest, NULL));
         } else {
diff --git a/client/control.c b/client/control.c
index ef6ce47ffb..ccdcea0dce 100644
--- a/client/control.c
+++ b/client/control.c
@@ -3030,7 +3030,7 @@ void do_unit_paradrop_to(struct unit *punit, struct tile *ptile)
     }
 
     if (action_prob_possible(
-          action_prob_unit_vs_tgt(paction, punit,
+          action_prob_unit_vs_tgt(&(wld.map), paction, punit,
                                   tile_city(ptile), NULL,
                                   ptile, NULL))) {
       if (paradrop_action == NULL) {
diff --git a/common/actions.c b/common/actions.c
index 6ad2f5d643..b5790fbc65 100644
--- a/common/actions.c
+++ b/common/actions.c
@@ -6395,7 +6395,8 @@ struct act_prob action_prob_self(const struct civ_map *nmap,
   @param extra_tgt the target for extra sub targeted actions
   @return the action probability of performing the action
 **************************************************************************/
-struct act_prob action_prob_unit_vs_tgt(const struct action *paction,
+struct act_prob action_prob_unit_vs_tgt(const struct civ_map *nmap,
+                                        const struct action *paction,
                                         const struct unit *act_unit,
                                         const struct city *tgt_city,
                                         const struct unit *tgt_unit,
@@ -6404,7 +6405,6 @@ struct act_prob action_prob_unit_vs_tgt(const struct action *paction,
 {
   /* Assume impossible until told otherwise. */
   struct act_prob prob = ACTPROB_IMPOSSIBLE;
-  const struct civ_map *nmap = &(wld.map);
 
   fc_assert_ret_val(paction, ACTPROB_IMPOSSIBLE);
   fc_assert_ret_val(act_unit, ACTPROB_IMPOSSIBLE);
diff --git a/common/actions.h b/common/actions.h
index 3e9a0b9f5b..875c72eb7e 100644
--- a/common/actions.h
+++ b/common/actions.h
@@ -845,7 +845,8 @@ struct act_prob action_prob_self(const struct civ_map *nmap,
                                  const struct unit *actor,
                                  const action_id act_id);
 
-struct act_prob action_prob_unit_vs_tgt(const struct action *paction,
+struct act_prob action_prob_unit_vs_tgt(const struct civ_map *nmap,
+                                        const struct action *paction,
                                         const struct unit *act_unit,
                                         const struct city *tgt_city,
                                         const struct unit *tgt_unit,
diff --git a/server/unithand.c b/server/unithand.c
index d3c3a5f837..d759333d8e 100644
--- a/server/unithand.c
+++ b/server/unithand.c
@@ -2945,6 +2945,7 @@ static void illegal_action(struct player *pplayer,
 {
   bool information_revealed;
   bool was_punished;
+  const struct civ_map *nmap = &(wld.map);
 
   struct action *stopped_action = action_by_number(stopped_action_id);
 
@@ -2955,6 +2956,7 @@ static void illegal_action(struct player *pplayer,
 
 
   information_revealed = action_prob_possible(action_prob_unit_vs_tgt(
+                                                 nmap,
                                                  stopped_action,
                                                  actor,
                                                  target_city, target_unit,
-- 
2.45.2

