From eced2547f267cbee654f73b6ba2d689af479dc5c Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 29 Mar 2024 17:26:04 +0200
Subject: [PATCH 30/30] Unhardcode wld.map from city_map_to_tile()

See RM #374

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/daicity.c           |  6 ++++--
 ai/default/daisettler.c        |  3 ++-
 ai/tex/texaicity.c             |  3 ++-
 client/agents/cma_core.c       |  6 +++---
 client/citydlg_common.c        |  2 +-
 client/gui-gtk-3.22/citydlg.c  |  3 ++-
 client/gui-gtk-4.0/citydlg.c   |  3 ++-
 client/gui-qt/citydlg.cpp      |  2 +-
 client/mapview_common.c        |  4 ++--
 client/packhand.c              |  4 ++--
 common/aicore/citymap.c        | 20 +++++++++++-------
 common/aicore/cm.c             | 37 +++++++++++++++++++---------------
 common/city.c                  | 21 ++++++++++++-------
 common/city.h                  | 35 ++++++++++++++++----------------
 common/game.c                  |  5 +++--
 common/improvement.c           |  3 ++-
 common/metaknowledge.c         |  4 +++-
 common/player.c                |  6 ++++--
 common/requirements.c          | 36 ++++++++++++++++-----------------
 common/traderoutes.c           |  3 ++-
 server/advisors/autosettlers.c |  2 +-
 server/advisors/infracache.c   |  6 ++++--
 server/citytools.c             | 26 +++++++++++++-----------
 server/cityturn.c              | 30 +++++++++++++++++----------
 server/generator/startpos.c    | 13 ++++++------
 server/maphand.c               |  3 ++-
 server/sanitycheck.c           |  5 +++--
 server/savegame/savegame2.c    |  9 +++++----
 server/savegame/savegame3.c    |  3 ++-
 server/score.c                 |  5 +++--
 30 files changed, 179 insertions(+), 129 deletions(-)

diff --git a/ai/default/daicity.c b/ai/default/daicity.c
index c2ab0df239..99e38a4a64 100644
--- a/ai/default/daicity.c
+++ b/ai/default/daicity.c
@@ -1029,6 +1029,7 @@ static void resolve_city_emergency(struct ai_type *ait, struct player *pplayer,
                                    struct city *pcity)
 {
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   log_base(LOG_EMERGENCY,
            "Emergency in %s (%s, angry%d, unhap%d food%d, prod%d)",
@@ -1039,7 +1040,7 @@ static void resolve_city_emergency(struct ai_type *ait, struct player *pplayer,
            pcity->surplus[O_FOOD],
            pcity->surplus[O_SHIELD]);
 
-  city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, atile) {
+  city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, atile) {
     struct city *acity = tile_worked(atile);
 
     if (acity && acity != pcity && city_owner(acity) == city_owner(pcity))  {
@@ -1425,6 +1426,7 @@ adv_want dai_city_want(struct player *pplayer, struct city *acity,
 {
   adv_want want = 0;
   int prod[O_LAST], bonus[O_LAST], waste[O_LAST];
+  const struct civ_map *nmap = &(wld.map);
 
   memset(prod, 0, O_LAST * sizeof(*prod));
   if (NULL != pimprove
@@ -1435,7 +1437,7 @@ adv_want dai_city_want(struct player *pplayer, struct city *acity,
     /* The below calculation mostly duplicates get_worked_tile_output().
      * We do this only for buildings that we know may change tile
      * outputs. */
-    city_tile_iterate(city_map_radius_sq_get(acity), acenter, ptile) {
+    city_tile_iterate(nmap, city_map_radius_sq_get(acity), acenter, ptile) {
       if (tile_worked(ptile) == acity) {
         output_type_iterate(o) {
           prod[o] += city_tile_output(acity, ptile, celebrating, o);
diff --git a/ai/default/daisettler.c b/ai/default/daisettler.c
index 0dd8ce2d48..1835d4e3ee 100644
--- a/ai/default/daisettler.c
+++ b/ai/default/daisettler.c
@@ -284,6 +284,7 @@ static struct cityresult *cityresult_fill(struct ai_type *ait,
   bool handicap = has_handicap(pplayer, H_MAP);
   struct adv_data *adv = adv_data_get(pplayer, NULL);
   struct cityresult *result;
+  const struct civ_map *nmap = &(wld.map);
 
   fc_assert_ret_val(adv != NULL, NULL);
   fc_assert_ret_val(center != NULL, NULL);
@@ -304,7 +305,7 @@ static struct cityresult *cityresult_fill(struct ai_type *ait,
 
   result->city_radius_sq = city_map_radius_sq_get(pcity);
 
-  city_tile_iterate_index(result->city_radius_sq, result->tile, ptile,
+  city_tile_iterate_index(nmap, result->city_radius_sq, result->tile, ptile,
                           cindex) {
     int tindex = tile_index(ptile);
     int reserved = citymap_read(ptile);
diff --git a/ai/tex/texaicity.c b/ai/tex/texaicity.c
index 9cd7741560..c2b1c78bbc 100644
--- a/ai/tex/texaicity.c
+++ b/ai/tex/texaicity.c
@@ -451,6 +451,7 @@ static bool texai_city_worker_task_select(struct ai_type *ait,
   struct texai_tile_state state = { .uw_max = 0, .uw_max_base = 0, .worst_worked = FC_INFINITY,
                                     .orig_worst_worked = 0, .old_worst_worked = FC_INFINITY };
   struct unit_list *units = NULL;
+  const struct civ_map *nmap = &(wld.map);
 
   switch (limit) {
   case TWTL_CURRENT_UNITS:
@@ -468,7 +469,7 @@ static bool texai_city_worker_task_select(struct ai_type *ait,
     break;
   }
 
-  city_tile_iterate_index(city_map_radius_sq_get(pcity), city_tile(pcity),
+  city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), city_tile(pcity),
                           ptile, cindex) {
     texai_tile_worker_task_select(pplayer, pcity, ptile, cindex, units,
                                   &worked, &unworked, &state, limit);
diff --git a/client/agents/cma_core.c b/client/agents/cma_core.c
index 0894ce05c9..c4de584d50 100644
--- a/client/agents/cma_core.c
+++ b/client/agents/cma_core.c
@@ -202,8 +202,8 @@ static bool apply_result_on_server(struct city *pcity,
   connection_do_buffer(&client.conn);
 
   /* Remove all surplus workers */
-  city_tile_iterate_skip_free_worked(city_radius_sq, pcenter, ptile, idx,
-                                     x, y) {
+  city_tile_iterate_skip_free_worked(&(wld.map), city_radius_sq, pcenter,
+                                     ptile, idx, x, y) {
     if (tile_worked(ptile) == pcity
         && !result->worker_positions[idx]) {
       log_apply_result("Removing worker at {%d,%d}.", x, y);
@@ -241,7 +241,7 @@ static bool apply_result_on_server(struct city *pcity,
   /* Set workers */
   /* FIXME: This code assumes that any toggled worker will turn into a
    * DEFAULT_SPECIALIST! */
-  city_tile_iterate_skip_free_worked(city_radius_sq, pcenter, ptile, idx,
+  city_tile_iterate_skip_free_worked(&(wld.map), city_radius_sq, pcenter, ptile, idx,
                                      x, y) {
     if (NULL == tile_worked(ptile)
         && result->worker_positions[idx]) {
diff --git a/client/citydlg_common.c b/client/citydlg_common.c
index 6860a97934..fad76e600a 100644
--- a/client/citydlg_common.c
+++ b/client/citydlg_common.c
@@ -1576,7 +1576,7 @@ int city_toggle_worker(struct city *pcity, int city_x, int city_y)
 
   city_radius_sq = city_map_radius_sq_get(pcity);
   fc_assert(is_valid_city_coords(city_radius_sq, city_x, city_y));
-  ptile = city_map_to_tile(city_tile(pcity), city_radius_sq,
+  ptile = city_map_to_tile(&(wld.map), city_tile(pcity), city_radius_sq,
                            city_x, city_y);
   if (NULL == ptile) {
     return 0;
diff --git a/client/gui-gtk-3.22/citydlg.c b/client/gui-gtk-3.22/citydlg.c
index 70eca5b5b4..76a2f9bddf 100644
--- a/client/gui-gtk-3.22/citydlg.c
+++ b/client/gui-gtk-3.22/citydlg.c
@@ -3044,7 +3044,8 @@ static gboolean button_down_citymap(GtkWidget *w, GdkEventButton *ev,
       struct city *pcity = pdialog->pcity;
 
       popup_workertask_dlg(pdialog->pcity,
-                           city_map_to_tile(pcity->tile, city_map_radius_sq_get(pcity),
+                           city_map_to_tile(&(wld.map), pcity->tile,
+                                            city_map_radius_sq_get(pcity),
                                             city_x, city_y));
     }
   }
diff --git a/client/gui-gtk-4.0/citydlg.c b/client/gui-gtk-4.0/citydlg.c
index 0a8d47940d..5fe004c666 100644
--- a/client/gui-gtk-4.0/citydlg.c
+++ b/client/gui-gtk-4.0/citydlg.c
@@ -3159,7 +3159,8 @@ static gboolean right_button_down_citymap(GtkGestureClick *gesture, int n_press,
     struct city *pcity = pdialog->pcity;
 
     popup_workertask_dlg(pdialog->pcity,
-                         city_map_to_tile(pcity->tile, city_map_radius_sq_get(pcity),
+                         city_map_to_tile(&(wld.map), pcity->tile,
+                                          city_map_radius_sq_get(pcity),
                                           city_x, city_y));
   }
 
diff --git a/client/gui-qt/citydlg.cpp b/client/gui-qt/citydlg.cpp
index bf07ac31d9..1bb1437364 100644
--- a/client/gui-qt/citydlg.cpp
+++ b/client/gui-qt/citydlg.cpp
@@ -1383,7 +1383,7 @@ void city_map::context_menu(QPoint point)
     return;
   }
 
-  ptile = city_map_to_tile(mcity->tile, city_map_radius_sq_get(mcity),
+  ptile = city_map_to_tile(&(wld.map), mcity->tile, city_map_radius_sq_get(mcity),
                            city_x, city_y);
   pterr = tile_terrain(ptile);
   for_terr.kind = VUT_TERRAIN;
diff --git a/client/mapview_common.c b/client/mapview_common.c
index bdd197ce61..c01a0b31e3 100644
--- a/client/mapview_common.c
+++ b/client/mapview_common.c
@@ -2845,7 +2845,7 @@ struct city *find_city_or_settler_near_tile(const struct tile *ptile,
   closest_city = NULL;
 
   /* Check within maximum (squared) city radius */
-  city_tile_iterate(max_rad, ptile, tile1) {
+  city_tile_iterate(&(wld.map), max_rad, ptile, tile1) {
     pcity = tile_city(tile1);
     if (pcity
         && (NULL == client.conn.playing
@@ -2874,7 +2874,7 @@ struct city *find_city_or_settler_near_tile(const struct tile *ptile,
 
   if (!game.scenario.prevent_new_cities) {
     /* Check within maximum (squared) city radius */
-    city_tile_iterate(max_rad, ptile, tile1) {
+    city_tile_iterate(&(wld.map), max_rad, ptile, tile1) {
       unit_list_iterate(tile1->units, psettler) {
         if ((NULL == client.conn.playing
              || unit_owner(psettler) == client.conn.playing)
diff --git a/client/packhand.c b/client/packhand.c
index 3d269c5007..aaef1bf17b 100644
--- a/client/packhand.c
+++ b/client/packhand.c
@@ -702,7 +702,7 @@ void handle_city_info(const struct packet_city_info *packet)
     } else if (city_owner(pcity) != powner) {
       /* Remember what were the worked tiles. The server won't
        * send them to us again. */
-      city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity),
+      city_tile_iterate_skip_free_worked(&(wld.map), city_map_radius_sq_get(pcity),
                                          ptile, pworked, _index, _x, _y) {
         if (pcity == tile_worked(pworked)) {
           if (NULL == worked_tiles) {
@@ -1191,7 +1191,7 @@ void handle_city_short_info(const struct packet_city_short_info *packet)
     } else if (city_owner(pcity) != powner) {
       /* Remember what were the worked tiles. The server won't
        * send to us again. */
-      city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), ptile,
+      city_tile_iterate_skip_free_worked(&(wld.map), city_map_radius_sq_get(pcity), ptile,
                                          pworked, _index, _x, _y) {
         if (pcity == tile_worked(pworked)) {
           if (NULL == worked_tiles) {
diff --git a/common/aicore/citymap.c b/common/aicore/citymap.c
index a45c8439d0..8dd11df81c 100644
--- a/common/aicore/citymap.c
+++ b/common/aicore/citymap.c
@@ -60,7 +60,9 @@ static int *citymap = NULL;
 **************************************************************************/
 void citymap_turn_init(struct player *pplayer)
 {
-  /* The citymap is reinitialized at the start of ever turn.  This includes
+  const struct civ_map *nmap = &(wld.map);
+
+  /* The citymap is reinitialized at the start of ever turn. This includes
    * a call to realloc, which only really matters if this is the first turn
    * of the game (but it's easier than a separate function to do this). */
   citymap = fc_realloc(citymap, MAP_INDEX_SIZE * sizeof(*citymap));
@@ -70,8 +72,8 @@ void citymap_turn_init(struct player *pplayer)
     city_list_iterate(pother->cities, pcity) {
       struct tile *pcenter = city_tile(pcity);
 
-      /* reserve at least the default (squared) city radius */
-      city_tile_iterate(MAX(city_map_radius_sq_get(pcity),
+      /* Reserve at least the default (squared) city radius */
+      city_tile_iterate(nmap, MAX(city_map_radius_sq_get(pcity),
                             CITY_MAP_DEFAULT_RADIUS_SQ),
                         pcenter, ptile) {
         struct city *pwork = tile_worked(ptile);
@@ -89,8 +91,8 @@ void citymap_turn_init(struct player *pplayer)
     if (unit_is_cityfounder(punit)
         && punit->server.adv->task == AUT_BUILD_CITY) {
 
-      /* use default (squared) city radius */
-      city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, punit->goto_tile,
+      /* Use default (squared) city radius */
+      city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, punit->goto_tile,
                         ptile) {
         if (citymap[tile_index(ptile)] >= 0) {
           citymap[tile_index(ptile)]++;
@@ -119,6 +121,8 @@ void citymap_free(void)
 **************************************************************************/
 void citymap_reserve_city_spot(struct tile *ptile, int id)
 {
+  const struct civ_map *nmap = &(wld.map);
+
 #ifdef FREECIV_DEBUG
   log_citymap("id %d reserving (%d, %d), was %d", 
               id, TILE_XY(ptile), citymap[tile_index(ptile)]);
@@ -128,7 +132,7 @@ void citymap_reserve_city_spot(struct tile *ptile, int id)
   /* Tiles will now be "reserved" by actual workers, so free excess
    * reservations. Also mark tiles for city overlapping, or 'crowding'.
    * Uses the default city map size / squared city radius. */
-  city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
+  city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
     if (citymap[tile_index(ptile1)] == -id) {
       citymap[tile_index(ptile1)] = 0;
     }
@@ -145,7 +149,9 @@ void citymap_reserve_city_spot(struct tile *ptile, int id)
 **************************************************************************/
 void citymap_free_city_spot(struct tile *ptile, int id)
 {
-  city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
+  const struct civ_map *nmap = &(wld.map);
+
+  city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, ptile, ptile1) {
     if (citymap[tile_index(ptile1)] == -(id)) {
       citymap[tile_index(ptile1)] = 0;
     } else if (citymap[tile_index(ptile1)] > 0) {
diff --git a/common/aicore/cm.c b/common/aicore/cm.c
index c053d2f455..2475a314a3 100644
--- a/common/aicore/cm.c
+++ b/common/aicore/cm.c
@@ -1239,17 +1239,18 @@ static void init_tile_lattice(struct city *pcity,
 {
   struct cm_tile_type type;
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
-  /* add all the fields into the lattice */
-  tile_type_init(&type); /* init just once */
+  /* Add all the fields into the lattice */
+  tile_type_init(&type); /* Init just once */
 
-  city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
+  city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
                           ctindex) {
     if (is_free_worked(pcity, ptile)) {
       continue;
     } else if (city_can_work_tile(pcity, ptile)) {
-      compute_tile_production(pcity, ptile, &type); /* clobbers type */
-      tile_type_lattice_add(lattice, &type, ctindex); /* copy type if needed */
+      compute_tile_production(pcity, ptile, &type); /* Clobbers type */
+      tile_type_lattice_add(lattice, &type, ctindex); /* Copy type if needed */
     }
   } city_tile_iterate_index_end;
 
@@ -1586,14 +1587,15 @@ static void compute_max_stats_heuristic(const struct cm_state *state,
                                         int production[],
                                         int check_choice, bool negative_ok)
 {
-  struct partial_solution solnplus; /* will be soln, plus some tiles */
+  struct partial_solution solnplus; /* Will be soln, plus some tiles */
+  const struct civ_map *nmap = &(wld.map);
 
   /* Production is whatever the solution produces, plus the
      most possible of each kind of production the idle workers could
      produce */
 
   if (soln->idle == 1) {
-    /* Then the total solution is soln + this new worker.  So we know the
+    /* Then the total solution is soln + this new worker. So we know the
        production exactly, and can shortcut the later code. */
     const struct cm_tile_type *ptype = tile_type_get(state, check_choice);
 
@@ -1634,7 +1636,7 @@ static void compute_max_stats_heuristic(const struct cm_state *state,
   output_type_iterate(stat_index) {
     int base = production[stat_index];
 
-    city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
+    city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
       if (is_free_worked(pcity, ptile)) {
         base += city_tile_output(pcity, ptile, is_celebrating, stat_index);
       }
@@ -1935,9 +1937,10 @@ static int min_food_surplus_for_fastest_growth(struct cm_state *state)
   citizens workers = city_size;
   int food_needed = city_granary_size(city_size) - pcity->food_stock;
   int min_turns;
+  const struct civ_map *nmap = &(wld.map);
 
   city_map_iterate(city_radius_sq, cindex, x, y) {
-    struct tile *ptile = city_map_to_tile(pcity->tile, city_radius_sq, x, y);
+    struct tile *ptile = city_map_to_tile(nmap, pcity->tile, city_radius_sq, x, y);
     if (!ptile) {
       continue;
     }
@@ -2267,15 +2270,16 @@ static void cm_result_copy(struct cm_result *result,
                            const struct city *pcity, bool *workers_map)
 {
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
-  /* clear worker positions */
+  /* Clear worker positions */
   memset(result->worker_positions, 0,
          sizeof(*result->worker_positions)
          * city_map_tiles(result->city_radius_sq));
 
-  city_tile_iterate_index(result->city_radius_sq, pcenter, ptile, ctindex) {
+  city_tile_iterate_index(nmap, result->city_radius_sq, pcenter, ptile, ctindex) {
     if (workers_map == NULL) {
-      /* use the main map */
+      /* Use the main map */
       struct city *pwork = tile_worked(ptile);
 
       result->worker_positions[ctindex] = (NULL != pwork && pwork == pcity);
@@ -2284,16 +2288,16 @@ static void cm_result_copy(struct cm_result *result,
     }
   } city_tile_iterate_index_end;
 
-  /* copy the specialist counts */
+  /* Copy the specialist counts */
   specialist_type_iterate(spec) {
     result->specialists[spec] = pcity->specialists[spec];
   } specialist_type_iterate_end;
 
-  /* find the surplus production numbers */
+  /* Find the surplus production numbers */
   get_city_surplus(pcity, result->surplus,
       &result->disorder, &result->happy);
 
-  /* this is a valid result, in a sense */
+  /* This is a valid result, in a sense */
   result->found_a_valid = TRUE;
 }
 
@@ -2424,13 +2428,14 @@ static void print_performance(struct one_perf *counts)
 void cm_print_city(const struct city *pcity)
 {
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   log_test("cm_print_city(city %d=\"%s\")", pcity->id, city_name_get(pcity));
   log_test("  size=%d, specialists=%s",
            city_size_get(pcity), specialists_string(pcity->specialists));
 
   log_test("  workers at:");
-  city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
+  city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
                           cindex) {
     struct city *pwork = tile_worked(ptile);
 
diff --git a/common/city.c b/common/city.c
index 61ab9ac939..2e30a631e2 100644
--- a/common/city.c
+++ b/common/city.c
@@ -301,7 +301,8 @@ bool city_map_includes_tile(const struct city *const pcity,
   Finds the map position for a given city map coordinate of a certain
   city. Returns true if the map position found is real.
 **************************************************************************/
-struct tile *city_map_to_tile(const struct tile *city_center,
+struct tile *city_map_to_tile(const struct civ_map *nmap,
+                              const struct tile *city_center,
                               int city_radius_sq, int city_map_x,
                               int city_map_y)
 {
@@ -314,7 +315,7 @@ struct tile *city_map_to_tile(const struct tile *city_center,
   tile_x += CITY_ABS2REL(city_map_x);
   tile_y += CITY_ABS2REL(city_map_y);
 
-  return map_pos_to_tile(&(wld.map), tile_x, tile_y);
+  return map_pos_to_tile(nmap, tile_x, tile_y);
 }
 
 /**********************************************************************//**
@@ -444,6 +445,7 @@ void citylog_map_data(enum log_level level, int radius_sq, int *map_data)
 void citylog_map_workers(enum log_level level, struct city *pcity)
 {
   int *city_map_data = NULL;
+  const struct civ_map *nmap = &(wld.map);
 
   fc_assert_ret(pcity != NULL);
 
@@ -455,7 +457,8 @@ void citylog_map_workers(enum log_level level, struct city *pcity)
                             sizeof(*city_map_data));
 
   city_map_iterate(city_map_radius_sq_get(pcity), cindex, x, y) {
-    struct tile *ptile = city_map_to_tile(city_tile(pcity),
+    struct tile *ptile = city_map_to_tile(nmap,
+                                          city_tile(pcity),
                                           city_map_radius_sq_get(pcity),
                                           x, y);
     city_map_data[cindex] = (ptile && tile_worked(ptile) == pcity)
@@ -2099,7 +2102,9 @@ bool is_friendly_city_near(const struct player *owner,
 bool city_exists_within_max_city_map(const struct tile *ptile,
                                      bool may_be_on_center)
 {
-  city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
+  const struct civ_map *nmap = &(wld.map);
+
+  city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
     if (may_be_on_center || !same_pos(ptile, ptile1)) {
       if (tile_city(ptile1)) {
         return TRUE;
@@ -2315,10 +2320,11 @@ static inline void get_worked_tile_output(const struct city *pcity,
   bool is_celebrating = base_city_celebrating(pcity);
 #endif
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   memset(output, 0, O_LAST * sizeof(*output));
 
-  city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
+  city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
                           city_tile_index) {
     if (workers_map == NULL) {
       struct city *pwork = tile_worked(ptile);
@@ -2395,8 +2401,9 @@ static inline void city_tile_cache_update(struct city *pcity)
 {
   bool is_celebrating = base_city_celebrating(pcity);
   int radius_sq = city_map_radius_sq_get(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
-  /* initialize tile_cache if needed */
+  /* Initialize tile_cache if needed */
   if (pcity->tile_cache == NULL || pcity->tile_cache_radius_sq == -1
       || pcity->tile_cache_radius_sq != radius_sq) {
     pcity->tile_cache = fc_realloc(pcity->tile_cache,
@@ -2407,7 +2414,7 @@ static inline void city_tile_cache_update(struct city *pcity)
 
   /* Any unreal tiles are skipped - these values should have been memset
    * to 0 when the city was created. */
-  city_tile_iterate_index(radius_sq, pcity->tile, ptile, city_tile_index) {
+  city_tile_iterate_index(nmap, radius_sq, pcity->tile, ptile, city_tile_index) {
     output_type_iterate(o) {
       (pcity->tile_cache[city_tile_index]).output[o]
         = city_tile_output(pcity, ptile, is_celebrating, o);
diff --git a/common/city.h b/common/city.h
index 808740289f..6b147249db 100644
--- a/common/city.h
+++ b/common/city.h
@@ -198,11 +198,11 @@ void citylog_map_workers(enum log_level level, struct city *pcity);
  * _city_tile is the center of the (possible) city.
  * (_index) will be the city tile index in the interval
  * [0, city_map_tiles(_radius_sq)] */
-#define city_tile_iterate_index(_radius_sq, _city_tile, _tile,		\
+#define city_tile_iterate_index(_nmap, _radius_sq, _city_tile, _tile,   \
                                 _index) {				\
   city_map_iterate_outwards_radius_sq_index(CITY_MAP_CENTER_RADIUS_SQ,	\
                                             _radius_sq, _index, _x, _y)	\
-  struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq,         \
+  struct tile *_tile = city_map_to_tile(_nmap, _city_tile, _radius_sq,  \
                                         _x, _y);			\
   if (NULL != _tile) {
 
@@ -211,12 +211,12 @@ void citylog_map_workers(enum log_level level, struct city *pcity);
   } city_map_iterate_outwards_radius_sq_index_end;
 
 /* simple extension to skip is_free_worked() tiles. */
-#define city_tile_iterate_skip_free_worked(_radius_sq, _city_tile,	\
-                                           _tile, _index, _x, _y) {	\
-  city_map_iterate(_radius_sq, _index, _x, _y) {			\
-    if (!is_free_worked_index(_index)) {				\
-      struct tile *_tile = city_map_to_tile(_city_tile, _radius_sq,	\
-                                            _x, _y);			\
+#define city_tile_iterate_skip_free_worked(_nmap, _radius_sq, _city_tile,  \
+                                           _tile, _index, _x, _y) {	   \
+  city_map_iterate(_radius_sq, _index, _x, _y) {			   \
+    if (!is_free_worked_index(_index)) {				   \
+      struct tile *_tile = city_map_to_tile(_nmap, _city_tile, _radius_sq, \
+                                            _x, _y);			   \
       if (NULL != _tile) {
 
 #define city_tile_iterate_skip_free_worked_end				\
@@ -227,12 +227,12 @@ void citylog_map_workers(enum log_level level, struct city *pcity);
 
 /* Does the same thing as city_tile_iterate_index(), but keeps the city
  * coordinates hidden. */
-#define city_tile_iterate(_radius_sq, _city_tile, _tile) {              \
-  const struct tile *_center##_tile = _city_tile;                       \
-  city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ,        \
-                                      _radius_sq, _x, _y)               \
-  struct tile *_tile = city_map_to_tile(_center##_tile, _radius_sq,     \
-                                        _x, _y);                        \
+#define city_tile_iterate(_nmap, _radius_sq, _city_tile, _tile) {          \
+  const struct tile *_center##_tile = _city_tile;                          \
+  city_map_iterate_outwards_radius_sq(CITY_MAP_CENTER_RADIUS_SQ,           \
+                                      _radius_sq, _x, _y)                  \
+  struct tile *_tile = city_map_to_tile(_nmap, _center##_tile, _radius_sq, \
+                                        _x, _y);                           \
   if (NULL != _tile) {
 
 #define city_tile_iterate_end                                           \
@@ -547,7 +547,7 @@ extern struct output_type output_types[];
   }                                                                    \
 }
 
-/* output type functions */
+/* Output type functions */
 
 const char *get_output_identifier(Output_type_id output);
 const char *get_output_name(Output_type_id output);
@@ -556,7 +556,7 @@ Output_type_id output_type_by_identifier(const char *id);
 void add_specialist_output(const struct city *pcity, int *output);
 void set_city_production(struct city *pcity);
 
-/* properties */
+/* Properties */
 
 const char *city_name_get(const struct city *pcity);
 void city_name_set(struct city *pcity, const char *new_name);
@@ -673,7 +673,8 @@ bool city_tile_to_city_map(int *city_map_x, int *city_map_y,
                            const struct tile *city_center,
                            const struct tile *map_tile);
 
-struct tile *city_map_to_tile(const struct tile *city_center,
+struct tile *city_map_to_tile(const struct civ_map *nmap,
+                              const struct tile *city_center,
                               int city_radius_sq, int city_map_x,
                               int city_map_y);
 
diff --git a/common/game.c b/common/game.c
index d610c64a64..e7314cb4fa 100644
--- a/common/game.c
+++ b/common/game.c
@@ -179,9 +179,10 @@ void game_remove_city(struct world *gworld, struct city *pcity)
 {
   struct tile *pcenter = city_tile(pcity);
   struct player *powner = city_owner(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   if (NULL != powner) {
-    /* always unlink before clearing data */
+    /* Always unlink before clearing data */
     city_list_remove(powner->cities, pcity);
   }
 
@@ -196,7 +197,7 @@ void game_remove_city(struct world *gworld, struct city *pcity)
               nation_rule_name(nation_of_player(powner)),
               city_name_get(pcity));
 
-    city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
+    city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
       if (tile_worked(ptile) == pcity) {
         tile_set_worked(ptile, NULL);
       }
diff --git a/common/improvement.c b/common/improvement.c
index 986e4872e7..12004daafc 100644
--- a/common/improvement.c
+++ b/common/improvement.c
@@ -455,6 +455,7 @@ static bool impr_provides_buildable_units(const struct city *pcity,
 static bool impr_provides_buildable_extras(const struct city *pcity,
                                            const struct impr_type *pimprove)
 {
+  const struct civ_map *nmap = &(wld.map);
 
   /* Fast check */
   if (!pimprove->allows_extras) {
@@ -463,7 +464,7 @@ static bool impr_provides_buildable_extras(const struct city *pcity,
 
   extra_type_iterate(pextra) {
     if (requirement_needs_improvement(pimprove, &pextra->reqs)) {
-      city_tile_iterate(city_map_radius_sq_get(pcity),
+      city_tile_iterate(nmap, city_map_radius_sq_get(pcity),
                         city_tile(pcity), ptile) {
         if (player_can_build_extra(pextra, city_owner(pcity), ptile)) {
           return TRUE;
diff --git a/common/metaknowledge.c b/common/metaknowledge.c
index 7032f0448d..3cfcff8c03 100644
--- a/common/metaknowledge.c
+++ b/common/metaknowledge.c
@@ -75,13 +75,15 @@ static bool is_tile_seen_adj(const struct player *pow_player,
 static bool is_tile_seen_city(const struct player *pow_player,
                               const struct city *target_city)
 {
+  const struct civ_map *nmap = &(wld.map);
+
   /* Don't know the city radius. */
   if (!can_player_see_city_internals(pow_player, target_city)) {
     return FALSE;
   }
 
   /* A tile of the city is unseen */
-  city_tile_iterate(city_map_radius_sq_get(target_city),
+  city_tile_iterate(nmap, city_map_radius_sq_get(target_city),
                     city_tile(target_city), ptile) {
     if (!tile_is_seen(ptile, pow_player)) {
       return FALSE;
diff --git a/common/player.c b/common/player.c
index 6f89047698..e87493c0ca 100644
--- a/common/player.c
+++ b/common/player.c
@@ -1231,12 +1231,14 @@ struct unit *player_unit_by_number(const struct player *pplayer, int unit_id)
 }
 
 /*******************************************************************//**
-  Return true iff x,y is inside any of the player's city map.
+  Return true iff tile is inside any of the player's city map.
 ***********************************************************************/
 bool player_in_city_map(const struct player *pplayer,
                         const struct tile *ptile)
 {
-  city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
+  const struct civ_map *nmap = &(wld.map);
+
+  city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, ptile, ptile1) {
     struct city *pcity = tile_city(ptile1);
 
     if (pcity
diff --git a/common/requirements.c b/common/requirements.c
index 5eb192ac8d..311fbc676e 100644
--- a/common/requirements.c
+++ b/common/requirements.c
@@ -2767,7 +2767,7 @@ is_extra_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       if (tile_has_extra(ptile, pextra)) {
         return TRI_YES;
@@ -2780,7 +2780,7 @@ is_extra_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       if (tile_has_extra(ptile, pextra)) {
         return TRI_YES;
@@ -2792,7 +2792,7 @@ is_extra_req_active(const struct civ_map *nmap,
       if (trade_partner == NULL) {
         ret = TRI_MAYBE;
       } else {
-        city_tile_iterate(city_map_radius_sq_get(trade_partner),
+        city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
                           city_tile(trade_partner), ptile) {
           if (tile_has_extra(ptile, pextra)) {
             return TRI_YES;
@@ -2966,7 +2966,7 @@ is_terrain_req_active(const struct civ_map *nmap,
       return TRI_MAYBE;
     }
     if (pterrain != NULL) {
-      city_tile_iterate(city_map_radius_sq_get(context->city),
+      city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                         city_tile(context->city), ptile) {
         if (tile_terrain(ptile) == pterrain) {
           return TRI_YES;
@@ -2981,7 +2981,7 @@ is_terrain_req_active(const struct civ_map *nmap,
     if (pterrain != NULL) {
       enum fc_tristate ret;
 
-      city_tile_iterate(city_map_radius_sq_get(context->city),
+      city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                         city_tile(context->city), ptile) {
         if (tile_terrain(ptile) == pterrain) {
           return TRI_YES;
@@ -2993,7 +2993,7 @@ is_terrain_req_active(const struct civ_map *nmap,
         if (trade_partner == NULL) {
           ret = TRI_MAYBE;
         } else {
-          city_tile_iterate(city_map_radius_sq_get(trade_partner),
+          city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
                             city_tile(trade_partner), ptile) {
             if (tile_terrain(ptile) == pterrain) {
               return TRI_YES;
@@ -3065,7 +3065,7 @@ is_terrainclass_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       const struct terrain *pterrain = tile_terrain(ptile);
 
@@ -3080,7 +3080,7 @@ is_terrainclass_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       const struct terrain *pterrain = tile_terrain(ptile);
 
@@ -3095,7 +3095,7 @@ is_terrainclass_req_active(const struct civ_map *nmap,
       if (trade_partner == NULL) {
         ret = TRI_MAYBE;
       } else {
-        city_tile_iterate(city_map_radius_sq_get(trade_partner),
+        city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
                           city_tile(trade_partner), ptile) {
           const struct terrain *pterrain = tile_terrain(ptile);
 
@@ -3173,7 +3173,7 @@ is_terrainflag_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       const struct terrain *pterrain = tile_terrain(ptile);
 
@@ -3188,7 +3188,7 @@ is_terrainflag_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       const struct terrain *pterrain = tile_terrain(ptile);
 
@@ -3203,7 +3203,7 @@ is_terrainflag_req_active(const struct civ_map *nmap,
       if (trade_partner == NULL) {
         ret = TRI_MAYBE;
       } else {
-        city_tile_iterate(city_map_radius_sq_get(trade_partner),
+        city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
                           city_tile(trade_partner), ptile) {
           const struct terrain *pterrain = tile_terrain(ptile);
 
@@ -3287,7 +3287,7 @@ is_roadflag_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       if (tile_has_road_flag(ptile, roadflag)) {
         return TRI_YES;
@@ -3299,7 +3299,7 @@ is_roadflag_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       if (tile_has_road_flag(ptile, roadflag)) {
         return TRI_YES;
@@ -3311,7 +3311,7 @@ is_roadflag_req_active(const struct civ_map *nmap,
       if (trade_partner == NULL) {
         ret = TRI_MAYBE;
       } else {
-        city_tile_iterate(city_map_radius_sq_get(trade_partner),
+        city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
                           city_tile(trade_partner), ptile) {
           if (tile_has_road_flag(ptile, roadflag)) {
             return TRI_YES;
@@ -3383,7 +3383,7 @@ is_extraflag_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       if (tile_has_extra_flag(ptile, extraflag)) {
         return TRI_YES;
@@ -3395,7 +3395,7 @@ is_extraflag_req_active(const struct civ_map *nmap,
     if (!context->city) {
       return TRI_MAYBE;
     }
-    city_tile_iterate(city_map_radius_sq_get(context->city),
+    city_tile_iterate(nmap, city_map_radius_sq_get(context->city),
                       city_tile(context->city), ptile) {
       if (tile_has_extra_flag(ptile, extraflag)) {
         return TRI_YES;
@@ -3407,7 +3407,7 @@ is_extraflag_req_active(const struct civ_map *nmap,
       if (trade_partner == NULL) {
         ret = TRI_MAYBE;
       } else {
-        city_tile_iterate(city_map_radius_sq_get(trade_partner),
+        city_tile_iterate(nmap, city_map_radius_sq_get(trade_partner),
                           city_tile(trade_partner), ptile) {
           if (tile_has_extra_flag(ptile, extraflag)) {
             return TRI_YES;
diff --git a/common/traderoutes.c b/common/traderoutes.c
index c711d84ef3..a4617beadf 100644
--- a/common/traderoutes.c
+++ b/common/traderoutes.c
@@ -403,13 +403,14 @@ static int max_tile_trade(const struct city *pcity)
   int tile_trade[city_map_tiles(radius_sq)];
   size_t size = 0;
   bool is_celebrating = base_city_celebrating(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   if (pcity->tile == NULL) {
     return 0;
   }
 
   city_map_iterate(radius_sq, cindex, cx, cy) {
-    struct tile *ptile = city_map_to_tile(pcity->tile, radius_sq, cx, cy);
+    struct tile *ptile = city_map_to_tile(nmap, pcity->tile, radius_sq, cx, cy);
 
     if (ptile == NULL) {
       continue;
diff --git a/server/advisors/autosettlers.c b/server/advisors/autosettlers.c
index 004210df63..a27daf3646 100644
--- a/server/advisors/autosettlers.c
+++ b/server/advisors/autosettlers.c
@@ -471,7 +471,7 @@ adv_want settler_evaluate_improvements(const struct civ_map *nmap,
     struct tile *pcenter = city_tile(pcity);
 
     /* Try to work near the city */
-    city_tile_iterate_index(city_map_radius_sq_get(pcity), pcenter, ptile,
+    city_tile_iterate_index(nmap, city_map_radius_sq_get(pcity), pcenter, ptile,
                             cindex) {
       bool consider = TRUE;
       bool in_use = (tile_worked(ptile) == pcity);
diff --git a/server/advisors/infracache.c b/server/advisors/infracache.c
index 87278ccb2d..026f8c3b24 100644
--- a/server/advisors/infracache.c
+++ b/server/advisors/infracache.c
@@ -244,11 +244,13 @@ static adv_want adv_calc_rmextra(const struct city *pcity,
   Do all tile improvement calculations and cache them for later.
 
   These values are used in settler_evaluate_improvements() so this function
-  must be called before doing that.  Currently this is only done when handling
+  must be called before doing that. Currently this is only done when handling
   auto-settlers or when the AI contemplates building worker units.
 **************************************************************************/
 void initialize_infrastructure_cache(struct player *pplayer)
 {
+  const struct civ_map *nmap = &(wld.map);
+
   city_list_iterate(pplayer->cities, pcity) {
     struct tile *pcenter = city_tile(pcity);
     int radius_sq = city_map_radius_sq_get(pcity);
@@ -260,7 +262,7 @@ void initialize_infrastructure_cache(struct player *pplayer)
       } as_transform_action_iterate_end;
     } city_map_iterate_end;
 
-    city_tile_iterate_index(radius_sq, pcenter, ptile, cindex) {
+    city_tile_iterate_index(nmap, radius_sq, pcenter, ptile, cindex) {
       adv_city_worker_act_set(pcity, cindex, ACTIVITY_MINE,
                               adv_calc_plant(pcity, ptile));
       adv_city_worker_act_set(pcity, cindex, ACTIVITY_IRRIGATE,
diff --git a/server/citytools.c b/server/citytools.c
index c0a59b006d..bdb270f247 100644
--- a/server/citytools.c
+++ b/server/citytools.c
@@ -3332,8 +3332,9 @@ void sync_cities(void)
 void city_map_update_all(struct city *pcity)
 {
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
-  city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
+  city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
                                      ptile, _index, _x, _y) {
     /* bypass city_map_update_tile_now() for efficiency */
     city_map_update_tile_direct(ptile, FALSE);
@@ -3436,29 +3437,29 @@ void refresh_player_cities_vision(struct player *pplayer)
 ****************************************************************************/
 bool city_map_update_radius_sq(struct city *pcity)
 {
-
   fc_assert_ret_val(pcity != NULL, FALSE);
 
   int city_tiles_old, city_tiles_new;
   int city_radius_sq_old = city_map_radius_sq_get(pcity);
   int city_radius_sq_new = game.info.init_city_radius_sq
                            + get_city_bonus(pcity, EFT_CITY_RADIUS_SQ);
+  const struct civ_map *nmap = &(wld.map);
 
-  /* check minimum / maximum allowed city radii */
+  /* Check minimum / maximum allowed city radii */
   city_radius_sq_new = CLIP(CITY_MAP_MIN_RADIUS_SQ, city_radius_sq_new,
                             CITY_MAP_MAX_RADIUS_SQ);
 
   if (city_radius_sq_new == city_radius_sq_old) {
-    /* no change */
+    /* No change */
     return FALSE;
   }
 
-  /* get number of city tiles for each radii */
+  /* Get number of city tiles for each radii */
   city_tiles_old = city_map_tiles(city_radius_sq_old);
   city_tiles_new = city_map_tiles(city_radius_sq_new);
 
   if (city_tiles_old == city_tiles_new) {
-    /* a change of the squared city radius but no change of the number of
+    /* A change of the squared city radius but no change of the number of
      * city tiles */
     return FALSE;;
   }
@@ -3466,7 +3467,7 @@ bool city_map_update_radius_sq(struct city *pcity)
   log_debug("[%s (%d)] city_map_radius_sq: %d => %d", city_name_get(pcity),
             pcity->id, city_radius_sq_old, city_radius_sq_new);
 
-  /* workers map before */
+  /* Workers map before */
   log_debug("[%s (%d)] city size: %d; specialists: %d (before change)",
             city_name_get(pcity), pcity->id, city_size_get(pcity),
             city_specialists(pcity));
@@ -3475,16 +3476,16 @@ bool city_map_update_radius_sq(struct city *pcity)
   city_map_radius_sq_set(pcity, city_radius_sq_new);
 
   if (city_tiles_old < city_tiles_new) {
-    /* increased number of city tiles */
+    /* Increased number of city tiles */
     city_refresh_vision(pcity);
   } else {
-    /* reduced number of city tiles */
+    /* Reduced number of city tiles */
     int workers = 0;
 
-    /* remove workers from the tiles removed rom the city map */
+    /* Remove workers from the tiles removed rom the city map */
     city_map_iterate_radius_sq(city_radius_sq_new, city_radius_sq_old,
                                city_x, city_y) {
-      struct tile *ptile = city_map_to_tile(city_tile(pcity),
+      struct tile *ptile = city_map_to_tile(nmap, city_tile(pcity),
                                             city_radius_sq_old, city_x,
                                             city_y);
 
@@ -3497,8 +3498,9 @@ bool city_map_update_radius_sq(struct city *pcity)
     /* add workers to free city tiles */
     if (workers > 0) {
       int radius_sq = city_map_radius_sq_get(pcity);
+
       city_map_iterate_without_index(radius_sq, city_x, city_y) {
-        struct tile *ptile = city_map_to_tile(city_tile(pcity), radius_sq,
+        struct tile *ptile = city_map_to_tile(nmap, city_tile(pcity), radius_sq,
                                               city_x, city_y);
 
         if (ptile && !is_free_worked(pcity, ptile)
diff --git a/server/cityturn.c b/server/cityturn.c
index ed4693b5e1..ee4dd6b512 100644
--- a/server/cityturn.c
+++ b/server/cityturn.c
@@ -275,16 +275,17 @@ void remove_obsolete_buildings(struct player *pplayer)
 }
 
 /**********************************************************************//**
-  Rearrange workers according to a cm_result struct.  The caller must make
+  Rearrange workers according to a cm_result struct. The caller must make
   sure that the result is valid.
 **************************************************************************/
 void apply_cmresult_to_city(struct city *pcity,
                             const struct cm_result *cmr)
 {
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   /* Now apply results */
-  city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
+  city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
                                      ptile, idx, x, y) {
     struct city *pwork = tile_worked(ptile);
 
@@ -738,10 +739,11 @@ static citizens city_reduce_workers(struct city *pcity, citizens change)
 {
   struct tile *pcenter = city_tile(pcity);
   int want = change;
+  const struct civ_map *nmap = &(wld.map);
 
   fc_assert_ret_val(0 < change, 0);
 
-  city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
+  city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
                                      ptile, _index, _x, _y) {
     if (0 < want && tile_worked(ptile) == pcity) {
       city_map_update_empty(pcity, ptile);
@@ -924,6 +926,7 @@ static bool city_increase_size(struct city *pcity)
   struct tile *pcenter = city_tile(pcity);
   struct player *powner = city_owner(pcity);
   const struct impr_type *pimprove = pcity->production.value.building;
+  const struct civ_map *nmap = &(wld.map);
 
   if (!city_can_grow_to(pcity, city_size_get(pcity) + 1)) {
     /* Need improvement */
@@ -962,9 +965,9 @@ static bool city_increase_size(struct city *pcity)
    * make new citizens into scientists or taxmen -- Massimo */
 
   /* Ignore food if no square can be worked */
-  city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
+  city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
                                      ptile, _index, _x, _y) {
-    if (tile_worked(ptile) != pcity /* quick test */
+    if (tile_worked(ptile) != pcity /* Quick test */
      && city_can_work_tile(pcity, ptile)) {
       have_square = TRUE;
     }
@@ -3368,9 +3371,10 @@ static bool place_pollution(struct city *pcity, enum extra_cause cause)
   struct tile *pcenter = city_tile(pcity);
   int city_radius_sq = city_map_radius_sq_get(pcity);
   int k = 100;
+  const struct civ_map *nmap = &(wld.map);
 
   while (k > 0) {
-    /* place pollution on a random city tile */
+    /* Place pollution on a random city tile */
     int cx, cy;
     int tile_id = fc_rand(city_map_tiles(city_radius_sq));
     struct extra_type *pextra;
@@ -3378,7 +3382,7 @@ static bool place_pollution(struct city *pcity, enum extra_cause cause)
     city_tile_index_to_xy(&cx, &cy, tile_id, city_radius_sq);
 
     /* Check for a real map position */
-    if (!(ptile = city_map_to_tile(pcenter, city_radius_sq, cx, cy))) {
+    if (!(ptile = city_map_to_tile(nmap, pcenter, city_radius_sq, cx, cy))) {
       continue;
     }
 
@@ -3966,6 +3970,7 @@ static bool do_city_migration(struct city *pcity_from,
   const char *nation_from, *nation_to;
   struct city *rcity = NULL;
   int to_id = pcity_to->id;
+  const struct civ_map *nmap = &(wld.map);
 
   if (!pcity_from || !pcity_to) {
     return FALSE;
@@ -3982,17 +3987,18 @@ static bool do_city_migration(struct city *pcity_from,
   ptile_from = city_tile(pcity_from);
   ptile_to = city_tile(pcity_to);
 
-  /* check food supply in the receiver city */
+  /* Check food supply in the receiver city */
   if (game.server.mgr_foodneeded) {
     bool migration = FALSE;
 
     if (pcity_to->surplus[O_FOOD] >= game.info.food_cost) {
       migration = TRUE;
     } else {
-      /* check if there is a free tile for the new citizen which, when worked,
+      /* Check if there is a free tile for the new citizen which, when worked,
        * leads to zero or positive food surplus for the enlarged city */
       int max_food_tile = -1;  /* no free tile */
-      city_tile_iterate(city_map_radius_sq_get(pcity_to),
+
+      city_tile_iterate(nmap, city_map_radius_sq_get(pcity_to),
                         city_tile(pcity_to), ptile) {
         if (city_can_work_tile(pcity_to, ptile)
             && tile_worked(ptile) != pcity_to) {
@@ -4589,10 +4595,12 @@ void city_counters_refresh(struct city *pcity)
 **************************************************************************/
 void city_tc_effect_refresh(struct player *pplayer)
 {
+  const struct civ_map *nmap = &(wld.map);
+
   city_list_iterate(pplayer->cities, pcity) {
     bool changed = FALSE;
 
-    city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity),
+    city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity),
                                        city_tile(pcity), ptile, idx, x, y) {
       if (ptile->worked == pcity
           && get_city_tile_output_bonus(pcity, ptile, NULL, EFT_TILE_WORKABLE) <= 0) {
diff --git a/server/generator/startpos.c b/server/generator/startpos.c
index 8588323bd4..84ec90bad2 100644
--- a/server/generator/startpos.c
+++ b/server/generator/startpos.c
@@ -307,10 +307,11 @@ bool create_start_positions(enum map_startpos mode,
   int *tile_value = NULL;
   int min_goodies_per_player = 1500;
   int total_goodies = 0;
-  /* this is factor is used to maximize land used in extreme little maps */
+  /* This is factor is used to maximize land used in extreme little maps */
   float efactor =  player_count() / map_size_checked() / 4; 
   bool failure = FALSE;
   bool is_tmap = temperature_is_initialized();
+  const struct civ_map *nmap = &(wld.map);
 
   if (wld.map.num_continents < 1) {
     /* Currently we can only place starters on land terrain, so fail
@@ -337,18 +338,18 @@ bool create_start_positions(enum map_startpos mode,
   tile_value_aux = fc_calloc(MAP_INDEX_SIZE, sizeof(*tile_value_aux));
   tile_value = fc_calloc(MAP_INDEX_SIZE, sizeof(*tile_value));
 
-  /* get the tile value */
+  /* Get the tile value */
   whole_map_iterate(&(wld.map), value_tile) {
     tile_value_aux[tile_index(value_tile)] = get_tile_value(value_tile);
   } whole_map_iterate_end;
 
-  /* select the best tiles */
+  /* Select the best tiles */
   whole_map_iterate(&(wld.map), value_tile) {
     int this_tile_value = tile_value_aux[tile_index(value_tile)];
     int lcount = 0, bcount = 0;
 
-    /* check all tiles within the default city radius */
-    city_tile_iterate(CITY_MAP_DEFAULT_RADIUS_SQ, value_tile, ptile1) {
+    /* Check all tiles within the default city radius */
+    city_tile_iterate(nmap, CITY_MAP_DEFAULT_RADIUS_SQ, value_tile, ptile1) {
       if (this_tile_value > tile_value_aux[tile_index(ptile1)]) {
         lcount++;
       } else if (this_tile_value < tile_value_aux[tile_index(ptile1)]) {
@@ -361,7 +362,7 @@ bool create_start_positions(enum map_startpos mode,
     }
     tile_value[tile_index(value_tile)] = 100 * this_tile_value;
   } whole_map_iterate_end;
-  /* get an average value */
+  /* Get an average value */
   smooth_int_map(tile_value, TRUE);
 
   initialize_isle_data();
diff --git a/server/maphand.c b/server/maphand.c
index 240fab4515..a3702e6e44 100644
--- a/server/maphand.c
+++ b/server/maphand.c
@@ -419,10 +419,11 @@ void give_citymap_from_player_to_player(struct city *pcity,
 					struct player *pfrom, struct player *pdest)
 {
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   buffer_shared_vision(pdest);
 
-  city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, ptile) {
+  city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, ptile) {
     give_tile_info_from_player_to_player(pfrom, pdest, ptile);
   } city_tile_iterate_end;
 
diff --git a/server/sanitycheck.c b/server/sanitycheck.c
index e8ad0d5ff4..58113bc9fd 100644
--- a/server/sanitycheck.c
+++ b/server/sanitycheck.c
@@ -328,11 +328,12 @@ static void check_city_size(struct city *pcity, const char *file,
   int delta;
   int citizen_count = 0;
   struct tile *pcenter = city_tile(pcity);
+  const struct civ_map *nmap = &(wld.map);
 
   SANITY_CITY(pcity, city_size_get(pcity) >= 1);
 
-  city_tile_iterate_skip_free_worked(city_map_radius_sq_get(pcity), pcenter,
-                                  ptile, _index, _x, _y) {
+  city_tile_iterate_skip_free_worked(nmap, city_map_radius_sq_get(pcity), pcenter,
+                                     ptile, _index, _x, _y) {
     if (tile_worked(ptile) == pcity) {
       citizen_count++;
     }
diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c
index 7caaa13746..db9d6592d2 100644
--- a/server/savegame/savegame2.c
+++ b/server/savegame/savegame2.c
@@ -3754,6 +3754,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
   int nat_x, nat_y;
   citizens size;
   const char *stylename;
+  const struct civ_map *nmap = &(wld.map);
 
   sg_warn_ret_val(secfile_lookup_int(loading->file, &nat_x, "%s.x", citystr),
                   FALSE, "%s", secfile_error());
@@ -3908,7 +3909,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
     pcity->style = city_style(pcity);
   }
 
-  pcity->server.synced = FALSE; /* must re-sync with clients */
+  pcity->server.synced = FALSE; /* Must re-sync with clients */
 
   /* Initialise list of city improvements. */
   for (i = 0; i < ARRAY_SIZE(pcity->built); i++) {
@@ -3942,7 +3943,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
 
   city_freeze_workers(pcity);
 
-  /* load new savegame with variable (squared) city radius and worked
+  /* Load new savegame with variable (squared) city radius and worked
    * tiles map */
 
   int radius_sq
@@ -3950,7 +3951,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
                                  citystr);
   city_map_radius_sq_set(pcity, radius_sq);
 
-  city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
+  city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
     if (loading->worked_tiles[ptile->index] == pcity->id) {
       if (sq_map_distance(ptile, pcity->tile) > radius_sq) {
         log_sg("[%s] '%s' (%d, %d) has worker outside current radius "
@@ -3964,7 +3965,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
       }
 
 #ifdef FREECIV_DEBUG
-      /* set this tile to unused; a check for not resetted tiles is
+      /* Set this tile to unused; a check for not resetted tiles is
        * included in game_load_internal() */
       loading->worked_tiles[ptile->index] = -1;
 #endif /* FREECIV_DEBUG */
diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c
index 06a8cbb134..7265d55c32 100644
--- a/server/savegame/savegame3.c
+++ b/server/savegame/savegame3.c
@@ -5077,6 +5077,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
   int partner;
   int want;
   int tmp_int;
+  const struct civ_map *nmap = &(wld.map);
 
   sg_warn_ret_val(secfile_lookup_int(loading->file, &nat_x, "%s.x", citystr),
                   FALSE, "%s", secfile_error());
@@ -5292,7 +5293,7 @@ static bool sg_load_player_city(struct loaddata *loading, struct player *plr,
                                  citystr);
   city_map_radius_sq_set(pcity, radius_sq);
 
-  city_tile_iterate(CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
+  city_tile_iterate(nmap, CITY_MAP_MAX_RADIUS_SQ, city_tile(pcity), ptile) {
     if (loading->worked_tiles[ptile->index] == pcity->id) {
       if (sq_map_distance(ptile, pcity->tile) > radius_sq) {
         log_sg("[%s] '%s' (%d, %d) has worker outside current radius "
diff --git a/server/score.c b/server/score.c
index b083ea9a7b..3458c8ccb5 100644
--- a/server/score.c
+++ b/server/score.c
@@ -161,6 +161,7 @@ static void print_landarea_map(struct claim_map *pcmap, int turn)
 static void build_landarea_map(struct claim_map *pcmap)
 {
   bv_player *claims = fc_calloc(MAP_INDEX_SIZE, sizeof(*claims));
+  const struct civ_map *nmap = &(wld.map);
 
   memset(pcmap, 0, sizeof(*pcmap));
 
@@ -169,13 +170,13 @@ static void build_landarea_map(struct claim_map *pcmap)
     city_list_iterate(pplayer->cities, pcity) {
       struct tile *pcenter = city_tile(pcity);
 
-      city_tile_iterate(city_map_radius_sq_get(pcity), pcenter, tile1) {
+      city_tile_iterate(nmap, city_map_radius_sq_get(pcity), pcenter, tile1) {
 	BV_SET(claims[tile_index(tile1)], player_index(city_owner(pcity)));
       } city_tile_iterate_end;
     } city_list_iterate_end;
   } players_iterate_end;
 
-  whole_map_iterate(&(wld.map), ptile) {
+  whole_map_iterate(nmap, ptile) {
     struct player *owner = NULL;
     bv_player *pclaim = &claims[tile_index(ptile)];
 
-- 
2.43.0

