From 49702c3895e065455dda9a5d5d9bafe85b1c21bb Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 15 Oct 2024 21:40:26 +0300
Subject: [PATCH 38/38] Unhardcode wld.map from can_city_build_direct()

See RM #967

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/citydlg_common.c | 2 +-
 common/city.c           | 5 ++---
 common/city.h           | 3 ++-
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/client/citydlg_common.c b/client/citydlg_common.c
index db18c73c57..3057999f02 100644
--- a/client/citydlg_common.c
+++ b/client/citydlg_common.c
@@ -1379,7 +1379,7 @@ static bool base_city_queue_insert(struct city *pcity, int position,
     struct universal old = pcity->production;
 
     /* Insert as current production. */
-    if (!can_city_build_direct(pcity, item)) {
+    if (!can_city_build_direct(&(wld.map), pcity, item)) {
       return FALSE;
     }
 
diff --git a/common/city.c b/common/city.c
index 508ecca201..30d8092a78 100644
--- a/common/city.c
+++ b/common/city.c
@@ -991,11 +991,10 @@ bool can_city_build_unit_later(const struct civ_map *nmap,
   Returns whether city can immediately build given target,
   unit or improvement. This considers obsolete targets still buildable.
 **************************************************************************/
-bool can_city_build_direct(const struct city *pcity,
+bool can_city_build_direct(const struct civ_map *nmap,
+                           const struct city *pcity,
                            const struct universal *target)
 {
-  const struct civ_map *nmap = &(wld.map);
-
   switch (target->kind) {
   case VUT_UTYPE:
     return can_city_build_unit_direct(nmap, pcity, target->value.utype);
diff --git a/common/city.h b/common/city.h
index 3369146080..3614507a35 100644
--- a/common/city.h
+++ b/common/city.h
@@ -614,7 +614,8 @@ bool can_city_build_unit_now(const struct civ_map *nmap,
                              const struct city *pcity,
                              const struct unit_type *punittype);
 
-bool can_city_build_direct(const struct city *pcity,
+bool can_city_build_direct(const struct civ_map *nmap,
+                           const struct city *pcity,
                            const struct universal *target);
 bool can_city_build_later(const struct city *pcity,
                           const struct universal *target);
-- 
2.45.2

