From 641385bb695dc0cab162fa5df23ee4da40417638 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 14 Dec 2023 00:04:09 +0200
Subject: [PATCH 31/31] Add 'map' parameter for is_req_active_cb

See RM #61

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/requirements.c | 232 ++++++++++++++++++++++++++----------------
 common/requirements.h |   2 +-
 common/road.c         |   6 +-
 common/road.h         |   4 +-
 4 files changed, 151 insertions(+), 93 deletions(-)

diff --git a/common/requirements.c b/common/requirements.c
index ec7063c81c..18f5eae4f4 100644
--- a/common/requirements.c
+++ b/common/requirements.c
@@ -58,7 +58,8 @@ enum fc_tristate tri_req_present(const struct req_context *context,
 
 /* Function pointer for requirement-type-specific is_req_active handlers */
 typedef enum fc_tristate
-(*is_req_active_cb)(const struct req_context *context,
+(*is_req_active_cb)(const struct civ_map *nmap,
+                    const struct req_context *context,
                     const struct player *other_player,
                     const struct requirement *req);
 
@@ -1928,7 +1929,8 @@ static inline bool players_in_same_range(const struct player *pplayer1,
   context and req must not be null, and req must be a none requirement
 **************************************************************************/
 static enum fc_tristate
-is_none_req_active(const struct req_context *context,
+is_none_req_active(const struct civ_map *nmap,
+                   const struct req_context *context,
                    const struct player *other_player,
                    const struct requirement *req)
 {
@@ -2030,7 +2032,8 @@ static int num_continent_buildings(const struct player *pplayer,
   context and req must not be null, and req must be a building requirement
 **************************************************************************/
 static enum fc_tristate
-is_building_req_active(const struct req_context *context,
+is_building_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -2191,7 +2194,8 @@ is_building_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_buildinggenus_req_active(const struct req_context *context,
+is_buildinggenus_req_active(const struct civ_map *nmap,
+                            const struct req_context *context,
                             const struct player *other_player,
                             const struct requirement *req)
 {
@@ -2235,7 +2239,8 @@ static enum fc_tristate is_buildingflag_in_city(const struct city *pcity,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_buildingflag_req_active(const struct req_context *context,
+is_buildingflag_req_active(const struct civ_map *nmap,
+                           const struct req_context *context,
                            const struct player *other_player,
                            const struct requirement *req)
 {
@@ -2281,7 +2286,8 @@ is_buildingflag_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_plr_flag_req_active(const struct req_context *context,
+is_plr_flag_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -2321,7 +2327,8 @@ is_plr_flag_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_plr_state_req_active(const struct req_context *context,
+is_plr_state_req_active(const struct civ_map *nmap,
+                        const struct req_context *context,
                         const struct player *other_player,
                         const struct requirement *req)
 {
@@ -2360,7 +2367,8 @@ is_plr_state_req_active(const struct req_context *context,
   context and req must not be null, and req must be a tech requirement
 **************************************************************************/
 static enum fc_tristate
-is_tech_req_active(const struct req_context *context,
+is_tech_req_active(const struct civ_map *nmap,
+                   const struct req_context *context,
                    const struct player *other_player,
                    const struct requirement *req)
 {
@@ -2424,7 +2432,8 @@ is_tech_req_active(const struct req_context *context,
   context and req must not be null, and req must be a techflag requirement
 **************************************************************************/
 static enum fc_tristate
-is_techflag_req_active(const struct req_context *context,
+is_techflag_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -2487,7 +2496,8 @@ is_techflag_req_active(const struct req_context *context,
   context and req must not be null, and req must be a minculture requirement
 **************************************************************************/
 static enum fc_tristate
-is_minculture_req_active(const struct req_context *context,
+is_minculture_req_active(const struct civ_map *nmap,
+                         const struct req_context *context,
                          const struct player *other_player,
                          const struct requirement *req)
 {
@@ -2560,7 +2570,8 @@ is_minculture_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_minforeignpct_req_active(const struct req_context *context,
+is_minforeignpct_req_active(const struct civ_map *nmap,
+                            const struct req_context *context,
                             const struct player *other_player,
                             const struct requirement *req)
 {
@@ -2630,7 +2641,8 @@ is_minforeignpct_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_maxunitsontile_req_active(const struct req_context *context,
+is_maxunitsontile_req_active(const struct civ_map *nmap,
+                             const struct req_context *context,
                              const struct player *other_player,
                              const struct requirement *req)
 {
@@ -2654,7 +2666,7 @@ is_maxunitsontile_req_active(const struct req_context *context,
     if (unit_list_size(context->tile->units) <= max_units) {
       return TRI_YES;
     }
-    cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+    cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
       if (unit_list_size(adjc_tile->units) <= max_units) {
         return TRI_YES;
       }
@@ -2667,7 +2679,7 @@ is_maxunitsontile_req_active(const struct req_context *context,
     if (unit_list_size(context->tile->units) <= max_units) {
       return TRI_YES;
     }
-    adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+    adjc_iterate(nmap, context->tile, adjc_tile) {
       if (unit_list_size(adjc_tile->units) <= max_units) {
         return TRI_YES;
       }
@@ -2698,13 +2710,13 @@ is_maxunitsontile_req_active(const struct req_context *context,
   context and req must not be null, and req must be an extra requirement
 **************************************************************************/
 static enum fc_tristate
-is_extra_req_active(const struct req_context *context,
+is_extra_req_active(const struct civ_map *nmap,
+                    const struct req_context *context,
                     const struct player *other_player,
                     const struct requirement *req)
 {
   const struct extra_type *pextra;
   enum fc_tristate ret;
-  const struct civ_map *nmap = &(wld.map);
 
   IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_EXTRA);
 
@@ -2796,9 +2808,10 @@ is_extra_req_active(const struct req_context *context,
   context and req must not be null, and req must be a goods requirement
 **************************************************************************/
 static enum fc_tristate
-is_good_req_active(const struct req_context *context,
-                    const struct player *other_player,
-                    const struct requirement *req)
+is_good_req_active(const struct civ_map *nmap,
+                   const struct req_context *context,
+                   const struct player *other_player,
+                   const struct requirement *req)
 {
   const struct goods_type *pgood;
 
@@ -2842,7 +2855,8 @@ is_good_req_active(const struct req_context *context,
   context and req must not be null, and req must be an action requirement
 **************************************************************************/
 static enum fc_tristate
-is_action_req_active(const struct req_context *context,
+is_action_req_active(const struct civ_map *nmap,
+                     const struct req_context *context,
                      const struct player *other_player,
                      const struct requirement *req)
 {
@@ -2862,7 +2876,8 @@ is_action_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_outputtype_req_active(const struct req_context *context,
+is_outputtype_req_active(const struct civ_map *nmap,
+                         const struct req_context *context,
                          const struct player *other_player,
                          const struct requirement *req)
 {
@@ -2881,7 +2896,8 @@ is_outputtype_req_active(const struct req_context *context,
   context and req must not be null, and req must be a specialist requirement
 **************************************************************************/
 static enum fc_tristate
-is_specialist_req_active(const struct req_context *context,
+is_specialist_req_active(const struct civ_map *nmap,
+                         const struct req_context *context,
                          const struct player *other_player,
                          const struct requirement *req)
 {
@@ -2900,7 +2916,8 @@ is_specialist_req_active(const struct req_context *context,
   context and req must not be null, and req must be a terrain requirement
 **************************************************************************/
 static enum fc_tristate
-is_terrain_req_active(const struct req_context *context,
+is_terrain_req_active(const struct civ_map *nmap,
+                      const struct req_context *context,
                       const struct player *other_player,
                       const struct requirement *req)
 {
@@ -2996,7 +3013,8 @@ is_terrain_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_terrainclass_req_active(const struct req_context *context,
+is_terrainclass_req_active(const struct civ_map *nmap,
+                           const struct req_context *context,
                            const struct player *other_player,
                            const struct requirement *req)
 {
@@ -3097,7 +3115,8 @@ is_terrainclass_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_terrainflag_req_active(const struct req_context *context,
+is_terrainflag_req_active(const struct civ_map *nmap,
+                          const struct req_context *context,
                           const struct player *other_player,
                           const struct requirement *req)
 {
@@ -3203,13 +3222,13 @@ is_terrainflag_req_active(const struct req_context *context,
   context and req must not be null, and req must be a roadflag requirement
 **************************************************************************/
 static enum fc_tristate
-is_roadflag_req_active(const struct req_context *context,
+is_roadflag_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
   enum road_flag_id roadflag;
   enum fc_tristate ret;
-  struct civ_map *nmap = &(wld.map);
 
   IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_ROADFLAG);
 
@@ -3307,13 +3326,13 @@ is_roadflag_req_active(const struct req_context *context,
   context and req must not be null, and req must be an extraflag requirement
 **************************************************************************/
 static enum fc_tristate
-is_extraflag_req_active(const struct req_context *context,
+is_extraflag_req_active(const struct civ_map *nmap,
+                        const struct req_context *context,
                         const struct player *other_player,
                         const struct requirement *req)
 {
   enum extra_flag_id extraflag;
   enum fc_tristate ret;
-  const struct civ_map *nmap = &(wld.map);
 
   IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_EXTRAFLAG);
 
@@ -3404,7 +3423,8 @@ is_extraflag_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_terrainalter_req_active(const struct req_context *context,
+is_terrainalter_req_active(const struct civ_map *nmap,
+                           const struct req_context *context,
                            const struct player *other_player,
                            const struct requirement *req)
 {
@@ -3449,7 +3469,8 @@ is_terrainalter_req_active(const struct req_context *context,
   context and req must not be null, and req must be a gov requirement
 **************************************************************************/
 static enum fc_tristate
-is_gov_req_active(const struct req_context *context,
+is_gov_req_active(const struct civ_map *nmap,
+                  const struct req_context *context,
                   const struct player *other_player,
                   const struct requirement *req)
 {
@@ -3471,7 +3492,8 @@ is_gov_req_active(const struct req_context *context,
   context and req must not be null, and req must be a style requirement
 **************************************************************************/
 static enum fc_tristate
-is_style_req_active(const struct req_context *context,
+is_style_req_active(const struct civ_map *nmap,
+                    const struct req_context *context,
                     const struct player *other_player,
                     const struct requirement *req)
 {
@@ -3493,7 +3515,8 @@ is_style_req_active(const struct req_context *context,
   context and req must not be null, and req must be a mintechs requirement
 **************************************************************************/
 static enum fc_tristate
-is_mintechs_req_active(const struct req_context *context,
+is_mintechs_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -3527,7 +3550,8 @@ is_mintechs_req_active(const struct req_context *context,
   context and req must not be null, and req must be an AI level requirement
 **************************************************************************/
 static enum fc_tristate
-is_ai_req_active(const struct req_context *context,
+is_ai_req_active(const struct civ_map *nmap,
+                 const struct req_context *context,
                  const struct player *other_player,
                  const struct requirement *req)
 {
@@ -3550,7 +3574,8 @@ is_ai_req_active(const struct req_context *context,
   context and req must not be null, and req must be a nation requirement
 **************************************************************************/
 static enum fc_tristate
-is_nation_req_active(const struct req_context *context,
+is_nation_req_active(const struct civ_map *nmap,
+                     const struct req_context *context,
                      const struct player *other_player,
                      const struct requirement *req)
 {
@@ -3611,7 +3636,8 @@ is_nation_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_nationgroup_req_active(const struct req_context *context,
+is_nationgroup_req_active(const struct civ_map *nmap,
+                          const struct req_context *context,
                           const struct player *other_player,
                           const struct requirement *req)
 {
@@ -3667,7 +3693,8 @@ is_nationgroup_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_nationality_req_active(const struct req_context *context,
+is_nationality_req_active(const struct civ_map *nmap,
+                          const struct req_context *context,
                           const struct player *other_player,
                           const struct requirement *req)
 {
@@ -3741,9 +3768,10 @@ is_nationality_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_originalowner_req_active(const struct req_context *context,
-                          const struct player *other_player,
-                          const struct requirement *req)
+is_originalowner_req_active(const struct civ_map *nmap,
+                            const struct req_context *context,
+                            const struct player *other_player,
+                            const struct requirement *req)
 {
   const struct nation_type *nation;
 
@@ -3836,7 +3864,8 @@ static enum fc_tristate is_diplrel_in_range(const struct player *target_player,
   context and req must not be null, and req must be a diplrel requirement
 **************************************************************************/
 static enum fc_tristate
-is_diplrel_req_active(const struct req_context *context,
+is_diplrel_req_active(const struct civ_map *nmap,
+                      const struct req_context *context,
                       const struct player *other_player,
                       const struct requirement *req)
 {
@@ -3855,7 +3884,8 @@ is_diplrel_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_diplrel_tile_req_active(const struct req_context *context,
+is_diplrel_tile_req_active(const struct civ_map *nmap,
+                           const struct req_context *context,
                            const struct player *other_player,
                            const struct requirement *req)
 {
@@ -3878,7 +3908,8 @@ is_diplrel_tile_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_diplrel_tile_o_req_active(const struct req_context *context,
+is_diplrel_tile_o_req_active(const struct civ_map *nmap,
+                             const struct req_context *context,
                              const struct player *other_player,
                              const struct requirement *req)
 {
@@ -3926,7 +3957,8 @@ is_diplrel_unitany_in_range(const struct tile *target_tile,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_diplrel_unitany_req_active(const struct req_context *context,
+is_diplrel_unitany_req_active(const struct civ_map *nmap,
+                              const struct req_context *context,
                               const struct player *other_player,
                               const struct requirement *req)
 {
@@ -3947,7 +3979,8 @@ is_diplrel_unitany_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_diplrel_unitany_o_req_active(const struct req_context *context,
+is_diplrel_unitany_o_req_active(const struct civ_map *nmap,
+                                const struct req_context *context,
                                 const struct player *other_player,
                                 const struct requirement *req)
 {
@@ -3966,7 +3999,8 @@ is_diplrel_unitany_o_req_active(const struct req_context *context,
   context and req must not be null, and req must be a unittype requirement
 **************************************************************************/
 static enum fc_tristate
-is_unittype_req_active(const struct req_context *context,
+is_unittype_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -3994,7 +4028,8 @@ is_unittype_req_active(const struct req_context *context,
   context and req must not be null, and req must be a unitflag requirement
 **************************************************************************/
 static enum fc_tristate
-is_unitflag_req_active(const struct req_context *context,
+is_unitflag_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -4022,7 +4057,8 @@ is_unitflag_req_active(const struct req_context *context,
   context and req must not be null, and req must be a unitclass requirement
 **************************************************************************/
 static enum fc_tristate
-is_unitclass_req_active(const struct req_context *context,
+is_unitclass_req_active(const struct civ_map *nmap,
+                        const struct req_context *context,
                         const struct player *other_player,
                         const struct requirement *req)
 {
@@ -4051,7 +4087,8 @@ is_unitclass_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_unitclassflag_req_active(const struct req_context *context,
+is_unitclassflag_req_active(const struct civ_map *nmap,
+                            const struct req_context *context,
                             const struct player *other_player,
                             const struct requirement *req)
 {
@@ -4079,7 +4116,8 @@ is_unitclassflag_req_active(const struct req_context *context,
   context and req must not be null, and req must be a unitstate requirement
 **************************************************************************/
 static enum fc_tristate
-is_unitstate_req_active(const struct req_context *context,
+is_unitstate_req_active(const struct civ_map *nmap,
+                        const struct req_context *context,
                         const struct player *other_player,
                         const struct requirement *req)
 {
@@ -4104,7 +4142,7 @@ is_unitstate_req_active(const struct req_context *context,
     return BOOL_TO_TRISTATE(context->unit->transporter != NULL);
   case USP_LIVABLE_TILE:
     return BOOL_TO_TRISTATE(
-          can_unit_exist_at_tile(&(wld.map), context->unit,
+          can_unit_exist_at_tile(nmap, context->unit,
                                  unit_tile(context->unit)));
     break;
   case USP_TRANSPORTING:
@@ -4143,7 +4181,8 @@ is_unitstate_req_active(const struct req_context *context,
   context and req must not be null, and req must be an activity requirement
 **************************************************************************/
 static enum fc_tristate
-is_activity_req_active(const struct req_context *context,
+is_activity_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -4194,7 +4233,8 @@ is_activity_req_active(const struct req_context *context,
   context and req must not be null, and req must be a minveteran requirement
 **************************************************************************/
 static enum fc_tristate
-is_minveteran_req_active(const struct req_context *context,
+is_minveteran_req_active(const struct civ_map *nmap,
+                         const struct req_context *context,
                          const struct player *other_player,
                          const struct requirement *req)
 {
@@ -4217,7 +4257,8 @@ is_minveteran_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_minmovefrags_req_active(const struct req_context *context,
+is_minmovefrags_req_active(const struct civ_map *nmap,
+                           const struct req_context *context,
                            const struct player *other_player,
                            const struct requirement *req)
 {
@@ -4240,7 +4281,8 @@ is_minmovefrags_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_minhitpoints_req_active(const struct req_context *context,
+is_minhitpoints_req_active(const struct civ_map *nmap,
+                           const struct req_context *context,
                            const struct player *other_player,
                            const struct requirement *req)
 {
@@ -4262,7 +4304,8 @@ is_minhitpoints_req_active(const struct req_context *context,
   context and req must not be null, and req must be an age requirement
 **************************************************************************/
 static enum fc_tristate
-is_age_req_active(const struct req_context *context,
+is_age_req_active(const struct civ_map *nmap,
+                  const struct req_context *context,
                   const struct player *other_player,
                   const struct requirement *req)
 {
@@ -4309,7 +4352,8 @@ is_age_req_active(const struct req_context *context,
   context and req must not be null, and req must be a form age requirement
 **************************************************************************/
 static enum fc_tristate
-is_form_age_req_active(const struct req_context *context,
+is_form_age_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -4352,7 +4396,8 @@ static bool is_city_in_tile(const struct tile *ptile,
   context and req must not be null, and req must be a citytile requirement
 **************************************************************************/
 static enum fc_tristate
-is_citytile_req_active(const struct req_context *context,
+is_citytile_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -4377,7 +4422,7 @@ is_citytile_req_active(const struct req_context *context,
       if (is_city_in_tile(context->tile, context->city)) {
         return TRI_YES;
       }
-      cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
         if (is_city_in_tile(adjc_tile, context->city)) {
           return TRI_YES;
         }
@@ -4388,7 +4433,7 @@ is_citytile_req_active(const struct req_context *context,
       if (is_city_in_tile(context->tile, context->city)) {
         return TRI_YES;
       }
-      adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      adjc_iterate(nmap, context->tile, adjc_tile) {
         if (is_city_in_tile(adjc_tile, context->city)) {
           return TRI_YES;
         }
@@ -4417,7 +4462,7 @@ is_citytile_req_active(const struct req_context *context,
       if (context->tile->owner != NULL) {
         return TRI_YES;
       }
-      cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
         if (adjc_tile->owner != NULL) {
           return TRI_YES;
         }
@@ -4428,7 +4473,7 @@ is_citytile_req_active(const struct req_context *context,
       if (context->tile->owner != NULL) {
         return TRI_YES;
       }
-      adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      adjc_iterate(nmap, context->tile, adjc_tile) {
         if (adjc_tile->owner != NULL) {
           return TRI_YES;
         }
@@ -4457,7 +4502,7 @@ is_citytile_req_active(const struct req_context *context,
       if (context->tile->extras_owner != NULL) {
         return TRI_YES;
       }
-      cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
         if (adjc_tile->extras_owner != NULL) {
           return TRI_YES;
         }
@@ -4468,7 +4513,7 @@ is_citytile_req_active(const struct req_context *context,
       if (context->tile->extras_owner != NULL) {
         return TRI_YES;
       }
-      adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      adjc_iterate(nmap, context->tile, adjc_tile) {
         if (adjc_tile->extras_owner != NULL) {
           return TRI_YES;
         }
@@ -4497,7 +4542,7 @@ is_citytile_req_active(const struct req_context *context,
       if (context->tile->worked != NULL) {
         return TRI_YES;
       }
-      cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
         if (adjc_tile->worked != NULL) {
           return TRI_YES;
         }
@@ -4508,7 +4553,7 @@ is_citytile_req_active(const struct req_context *context,
       if (context->tile->worked != NULL) {
         return TRI_YES;
       }
-      adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+      adjc_iterate(nmap, context->tile, adjc_tile) {
         if (adjc_tile->worked != NULL) {
           return TRI_YES;
         }
@@ -4551,7 +4596,7 @@ is_citytile_req_active(const struct req_context *context,
         if (tile_continent(target_tile) == cc) {
           return TRI_YES;
         }
-        cardinal_adjc_iterate(&(wld.map), target_tile, adjc_tile) {
+        cardinal_adjc_iterate(nmap, target_tile, adjc_tile) {
           if (tile_continent(adjc_tile) == cc) {
             return TRI_YES;
           }
@@ -4562,7 +4607,7 @@ is_citytile_req_active(const struct req_context *context,
         if (tile_continent(target_tile) == cc) {
           return TRI_YES;
         }
-        adjc_iterate(&(wld.map), target_tile, adjc_tile) {
+        adjc_iterate(nmap, target_tile, adjc_tile) {
           if (tile_continent(adjc_tile) == cc) {
             return TRI_YES;
           }
@@ -4605,7 +4650,7 @@ is_citytile_req_active(const struct req_context *context,
          * Maybe, the city floats? Even if the rules prohibit it... */
         return TRI_MAYBE;
       }
-      adjc_iterate(&(wld.map), cc_tile, adjc_tile) {
+      adjc_iterate(nmap, cc_tile, adjc_tile) {
         Continent_id tc = tile_continent(adjc_tile);
 
         if (0 != tc) {
@@ -4657,7 +4702,7 @@ is_citytile_req_active(const struct req_context *context,
       case REQ_RANGE_ADJACENT:
         if (ukt) {
           /* If ALL the tiles in range are on cc, we can say it's false */
-          square_iterate(&(wld.map), target_tile, 1, adjc_tile) {
+          square_iterate(nmap, target_tile, 1, adjc_tile) {
             if (tile_continent(adjc_tile) != cc) {
              return TRI_MAYBE;
             }
@@ -4665,7 +4710,7 @@ is_citytile_req_active(const struct req_context *context,
 
           return TRI_NO;
         } else {
-          square_iterate(&(wld.map), target_tile, 1, adjc_tile) {
+          square_iterate(nmap, target_tile, 1, adjc_tile) {
             Continent_id tc = tile_continent(adjc_tile);
 
             if (0 == tc) {
@@ -4683,13 +4728,13 @@ is_citytile_req_active(const struct req_context *context,
       case REQ_RANGE_CADJACENT:
         if (ukt) {
           /* If ALL the tiles in range are on cc, we can say it's false */
-          circle_iterate(&(wld.map), target_tile, 1, cadjc_tile) {
+          circle_iterate(nmap, target_tile, 1, cadjc_tile) {
             if (tile_continent(cadjc_tile) != cc) {
               return TRI_MAYBE;
             }
           } circle_iterate_end;
         } else {
-          circle_iterate(&(wld.map), target_tile, 1, cadjc_tile) {
+          circle_iterate(nmap, target_tile, 1, cadjc_tile) {
             Continent_id tc = tile_continent(cadjc_tile);
 
             if (0 == tc) {
@@ -4739,7 +4784,8 @@ is_citytile_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_citystatus_req_active(const struct req_context *context,
+is_citystatus_req_active(const struct civ_map *nmap,
+                         const struct req_context *context,
                          const struct player *other_player,
                          const struct requirement *req)
 {
@@ -4981,7 +5027,8 @@ is_citystatus_req_active(const struct req_context *context,
   context and req must not be null, and req must be a minsize requirement
 **************************************************************************/
 static enum fc_tristate
-is_minsize_req_active(const struct req_context *context,
+is_minsize_req_active(const struct civ_map *nmap,
+                      const struct req_context *context,
                       const struct player *other_player,
                       const struct requirement *req)
 {
@@ -5022,7 +5069,8 @@ is_minsize_req_active(const struct req_context *context,
   context and req must not be null, and req must be a counter requirement
 **************************************************************************/
 static enum fc_tristate
-is_counter_req_active(const struct req_context *context,
+is_counter_req_active(const struct civ_map *nmap,
+                      const struct req_context *context,
                       const struct player *other_player,
                       const struct requirement *req)
 {
@@ -5049,7 +5097,8 @@ is_counter_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_achievement_req_active(const struct req_context *context,
+is_achievement_req_active(const struct civ_map *nmap,
+                          const struct req_context *context,
                           const struct player *other_player,
                           const struct requirement *req)
 {
@@ -5094,9 +5143,10 @@ is_achievement_req_active(const struct req_context *context,
   maxlatitude requirement
 **************************************************************************/
 static enum fc_tristate
-is_latitude_req_active(const struct req_context *context,
-                      const struct player *other_player,
-                      const struct requirement *req)
+is_latitude_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
+                       const struct player *other_player,
+                       const struct requirement *req)
 {
   int min = -MAP_MAX_LATITUDE, max = MAP_MAX_LATITUDE;
 
@@ -5135,7 +5185,7 @@ is_latitude_req_active(const struct req_context *context,
       return TRI_MAYBE;
     }
 
-    cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+    cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
       int tile_lat = map_signed_latitude(adjc_tile);
 
       if (min <= tile_lat && max >= tile_lat) {
@@ -5149,7 +5199,7 @@ is_latitude_req_active(const struct req_context *context,
       return TRI_MAYBE;
     }
 
-    adjc_iterate(&(wld.map), context->tile, adjc_tile) {
+    adjc_iterate(nmap, context->tile, adjc_tile) {
       int tile_lat = map_signed_latitude(adjc_tile);
 
       if (min <= tile_lat && max >= tile_lat) {
@@ -5183,7 +5233,8 @@ is_latitude_req_active(const struct req_context *context,
   context and req must not be null, and req must be a minyear requirement
 **************************************************************************/
 static enum fc_tristate
-is_minyear_req_active(const struct req_context *context,
+is_minyear_req_active(const struct civ_map *nmap,
+                      const struct req_context *context,
                       const struct player *other_player,
                       const struct requirement *req)
 {
@@ -5200,7 +5251,8 @@ is_minyear_req_active(const struct req_context *context,
   context and req must not be null, and req must be a mincalfrag requirement
 **************************************************************************/
 static enum fc_tristate
-is_mincalfrag_req_active(const struct req_context *context,
+is_mincalfrag_req_active(const struct civ_map *nmap,
+                         const struct req_context *context,
                          const struct player *other_player,
                          const struct requirement *req)
 {
@@ -5218,7 +5270,8 @@ is_mincalfrag_req_active(const struct req_context *context,
   context and req must not be null, and req must be a topology requirement
 **************************************************************************/
 static enum fc_tristate
-is_topology_req_active(const struct req_context *context,
+is_topology_req_active(const struct civ_map *nmap,
+                       const struct req_context *context,
                        const struct player *other_player,
                        const struct requirement *req)
 {
@@ -5236,7 +5289,8 @@ is_topology_req_active(const struct req_context *context,
   context and req must not be null, and req must be a wrap requirement
 **************************************************************************/
 static enum fc_tristate
-is_wrap_req_active(const struct req_context *context,
+is_wrap_req_active(const struct civ_map *nmap,
+                   const struct req_context *context,
                    const struct player *other_player,
                    const struct requirement *req)
 {
@@ -5255,7 +5309,8 @@ is_wrap_req_active(const struct req_context *context,
   requirement
 **************************************************************************/
 static enum fc_tristate
-is_serversetting_req_active(const struct req_context *context,
+is_serversetting_req_active(const struct civ_map *nmap,
+                            const struct req_context *context,
                             const struct player *other_player,
                             const struct requirement *req)
 {
@@ -5383,7 +5438,8 @@ enum fc_tristate tri_req_present(const struct req_context *context,
 
   fc_assert_ret_val(req_definitions[req->source.kind].cb != NULL, TRI_NO);
 
-  return req_definitions[req->source.kind].cb(context, other_player, req);
+  return req_definitions[req->source.kind].cb(&(wld.map), context,
+                                              other_player, req);
 }
 
 /**********************************************************************//**
diff --git a/common/requirements.h b/common/requirements.h
index 3e44832cc3..4eccf68789 100644
--- a/common/requirements.h
+++ b/common/requirements.h
@@ -451,4 +451,4 @@ int requirement_kind_ereq(const int value,
 }
 #endif /* __cplusplus */
 
-#endif  /* FC__REQUIREMENTS_H */
+#endif /* FC__REQUIREMENTS_H */
diff --git a/common/road.c b/common/road.c
index bba5506bcf..2e071bac1b 100644
--- a/common/road.c
+++ b/common/road.c
@@ -416,7 +416,8 @@ bool road_has_flag(const struct road_type *proad, enum road_flag_id flag)
   Returns TRUE iff any cardinally adjacent tile contains a road with
   the given flag (does not check ptile itself).
 ****************************************************************************/
-bool is_road_flag_card_near(struct civ_map *nmap, const struct tile *ptile,
+bool is_road_flag_card_near(const struct civ_map *nmap,
+                            const struct tile *ptile,
                             enum road_flag_id flag)
 {
   extra_type_by_cause_iterate(EC_ROAD, pextra) {
@@ -436,7 +437,8 @@ bool is_road_flag_card_near(struct civ_map *nmap, const struct tile *ptile,
   Returns TRUE iff any adjacent tile contains a road with the given flag
   (does not check ptile itself).
 ****************************************************************************/
-bool is_road_flag_near_tile(struct civ_map *nmap, const struct tile *ptile,
+bool is_road_flag_near_tile(const struct civ_map *nmap,
+                            const struct tile *ptile,
                             enum road_flag_id flag)
 {
   extra_type_by_cause_iterate(EC_ROAD, pextra) {
diff --git a/common/road.h b/common/road.h
index b6d922d017..94b4ff7afc 100644
--- a/common/road.h
+++ b/common/road.h
@@ -121,9 +121,9 @@ int count_river_type_near_tile(struct civ_map *nmap,
 
 /* Functions to operate on a road flag. */
 bool road_has_flag(const struct road_type *proad, enum road_flag_id flag);
-bool is_road_flag_card_near(struct civ_map *nmap, const struct tile *ptile,
+bool is_road_flag_card_near(const struct civ_map *nmap, const struct tile *ptile,
                             enum road_flag_id flag);
-bool is_road_flag_near_tile(struct civ_map *nmap, const struct tile *ptile,
+bool is_road_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile,
                             enum road_flag_id flag);
 
 bool road_can_be_built(const struct road_type *proad, const struct tile *ptile);
-- 
2.42.0

