From 57f26f8414f6e0fa8ae323c976dd91193b297f26 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 14 Feb 2026 11:13:04 +0200
Subject: [PATCH 38/38] Pass enum req_problem_type to can_city_build_unit_now()

No functional changes - all callers still pass RPT_CERTAIN.

See RM #1941

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/default/daiair.c                  |  2 +-
 ai/default/daicity.c                 |  6 ++++--
 ai/default/daihunter.c               |  4 ++--
 ai/default/daimilitary.c             | 13 +++++++------
 ai/default/daiparadrop.c             |  2 +-
 ai/default/daitech.c                 |  6 +++---
 ai/default/daiunit.c                 |  3 ++-
 ai/tex/texaicity.c                   |  2 +-
 client/climisc.c                     |  9 +++++----
 client/gui-qt/menu.cpp               |  4 ++--
 client/gui-sdl2/wldlg.c              |  9 +++++----
 client/gui-sdl3/wldlg.c              |  9 +++++----
 client/mapctrl_common.c              |  1 +
 common/aicore/aisupport.c            |  3 ++-
 common/city.c                        | 25 ++++++++++++++++---------
 common/city.h                        |  6 ++++--
 common/improvement.c                 |  4 ++--
 common/scriptcore/api_game_methods.c |  2 +-
 common/unittype.c                    | 25 ++++++++++++++-----------
 common/unittype.h                    |  4 +++-
 server/advisors/advdata.c            |  3 ++-
 server/cityturn.c                    | 12 +++++++-----
 server/techtools.c                   |  3 ++-
 server/unittools.c                   |  3 ++-
 24 files changed, 94 insertions(+), 66 deletions(-)

diff --git a/ai/default/daiair.c b/ai/default/daiair.c
index ab009d60c9..81b9451414 100644
--- a/ai/default/daiair.c
+++ b/ai/default/daiair.c
@@ -624,7 +624,7 @@ bool dai_choose_attacker_air(struct ai_type *ait, const struct civ_map *nmap,
       continue;
     }
 
-    if (can_city_build_unit_now(nmap, pcity, punittype)) {
+    if (can_city_build_unit_now(nmap, pcity, punittype, RPT_CERTAIN)) {
       struct unit *virtual_unit =
        unit_virtual_create(
           pplayer, pcity, punittype,
diff --git a/ai/default/daicity.c b/ai/default/daicity.c
index 3988e17ae3..c061096887 100644
--- a/ai/default/daicity.c
+++ b/ai/default/daicity.c
@@ -214,7 +214,8 @@ static void dai_barbarian_choose_build(struct player *pplayer,
     struct unit_type *iunit = get_role_unit(L_BARBARIAN_BUILD, i);
 
     if (iunit->attack_strength > bestattack
-        && can_city_build_unit_now(nmap, pcity, iunit)) {
+        && can_city_build_unit_now(nmap, pcity, iunit,
+                                   RPT_CERTAIN)) {
       bestunit = iunit;
       bestattack = iunit->attack_strength;
     }
@@ -225,7 +226,8 @@ static void dai_barbarian_choose_build(struct player *pplayer,
     struct unit_type *iunit = get_role_unit(L_BARBARIAN_BUILD_TECH, i);
 
     if (iunit->attack_strength > bestattack
-        && can_city_build_unit_now(nmap, pcity, iunit)) {
+        && can_city_build_unit_now(nmap, pcity, iunit,
+                                   RPT_CERTAIN)) {
       bestunit = iunit;
       bestattack = iunit->attack_strength;
     }
diff --git a/ai/default/daihunter.c b/ai/default/daihunter.c
index 99edc51b34..9f2c74e075 100644
--- a/ai/default/daihunter.c
+++ b/ai/default/daihunter.c
@@ -96,7 +96,7 @@ static struct unit_type *dai_hunter_guess_best(struct city *pcity,
       continue;
     }
 
-    if (!can_city_build_unit_now(nmap, pcity, ut)
+    if (!can_city_build_unit_now(nmap, pcity, ut, RPT_CERTAIN)
         || ut->attack_strength < ut->transport_capacity
         || (tc == TC_OCEAN && utype_class(ut)->adv.sea_move == MOVE_NONE)
         || (tc == TC_LAND && utype_class(ut)->adv.land_move == MOVE_NONE)) {
@@ -176,7 +176,7 @@ static void dai_hunter_missile_want(struct player *pplayer,
     int desire;
 
     if (!utype_can_do_action(ut, ACTION_SUICIDE_ATTACK)
-        || !can_city_build_unit_now(nmap, pcity, ut)) {
+        || !can_city_build_unit_now(nmap, pcity, ut, RPT_CERTAIN)) {
       continue;
     }
 
diff --git a/ai/default/daimilitary.c b/ai/default/daimilitary.c
index f8df430a40..3edf6fd2cc 100644
--- a/ai/default/daimilitary.c
+++ b/ai/default/daimilitary.c
@@ -96,7 +96,7 @@ struct unit_type *dai_choose_defender_versus(struct city *pcity,
   struct civ_map *nmap = &(wld.map);
 
   simple_ai_unit_type_iterate(punittype) {
-    if (can_city_build_unit_now(nmap, pcity, punittype)) {
+    if (can_city_build_unit_now(nmap, pcity, punittype, RPT_CERTAIN)) {
       int fpatt, fpdef, defense, attack;
       double want, loss, cost = utype_build_shield_cost(pcity, NULL, punittype);
       struct unit *defender;
@@ -161,7 +161,7 @@ static struct unit_type *dai_choose_attacker(struct ai_type *ait,
     if ((tc == TC_LAND && utype_class(putype)->adv.land_move != MOVE_NONE)
         || (tc == TC_OCEAN
             && utype_class(putype)->adv.sea_move != MOVE_NONE)) {
-      if (can_city_build_unit_now(nmap, pcity, putype)
+      if (can_city_build_unit_now(nmap, pcity, putype, RPT_CERTAIN)
           && (cur > best
               || (ADV_WANTS_EQ(cur, best)
                   && utype_build_shield_cost(pcity, NULL, putype)
@@ -215,7 +215,7 @@ static struct unit_type *dai_choose_bodyguard(struct ai_type *ait,
     }
 
     /* Now find best */
-    if (can_city_build_unit_now(nmap, pcity, putype)) {
+    if (can_city_build_unit_now(nmap, pcity, putype, RPT_CERTAIN)) {
       const adv_want desire = dai_unit_defense_desirability(ait, putype);
 
       if (desire > best
@@ -1118,7 +1118,7 @@ bool dai_process_defender_want(struct ai_type *ait, const struct civ_map *nmap,
       desire /= POWER_DIVIDER / 2; /* Good enough, no rounding errors. */
       desire *= desire;
 
-      if (can_city_build_unit_now(nmap, pcity, punittype)) {
+      if (can_city_build_unit_now(nmap, pcity, punittype, RPT_CERTAIN)) {
         /* We can build the unit now... */
 
         int build_cost = utype_build_shield_cost(pcity, NULL, punittype);
@@ -1293,7 +1293,8 @@ static void process_attacker_want(struct ai_type *ait,
     if (dai_can_unit_type_follow_unit_type(punittype, orig_utype, ait)
         && is_native_near_tile(&(wld.map), utype_class(punittype), ptile)
         && (U_NOT_OBSOLETED == punittype->obsoleted_by
-            || !can_city_build_unit_direct(nmap, pcity, punittype->obsoleted_by))
+            || !can_city_build_unit_direct(nmap, pcity, punittype->obsoleted_by,
+                                           RPT_CERTAIN))
         && punittype->attack_strength > 0 /* Or we'll get SIGFPE */) {
       /* Values to be computed */
       adv_want desire;
@@ -1468,7 +1469,7 @@ static void process_attacker_want(struct ai_type *ait,
         } else if (want > best_choice->want) {
           const struct impr_type *impr_req;
 
-          if (can_city_build_unit_now(nmap, pcity, punittype)) {
+          if (can_city_build_unit_now(nmap, pcity, punittype, RPT_CERTAIN)) {
             /* This is a real unit and we really want it */
 
             CITY_LOG(LOG_DEBUG, pcity, "overriding %s(" ADV_WANT_PRINTF
diff --git a/ai/default/daiparadrop.c b/ai/default/daiparadrop.c
index 57598c3d51..22af691572 100644
--- a/ai/default/daiparadrop.c
+++ b/ai/default/daiparadrop.c
@@ -435,7 +435,7 @@ void dai_choose_paratrooper(struct ai_type *ait, const struct civ_map *nmap,
     } unit_tech_reqs_iterate_end;
 
     /* we only update choice struct if we can build it! */
-    if (!can_city_build_unit_now(nmap, pcity, u_type)) {
+    if (!can_city_build_unit_now(nmap, pcity, u_type, RPT_CERTAIN)) {
       continue;
     }
 
diff --git a/ai/default/daitech.c b/ai/default/daitech.c
index 8bc1288381..da6910c4ad 100644
--- a/ai/default/daitech.c
+++ b/ai/default/daitech.c
@@ -418,7 +418,7 @@ struct unit_type *dai_wants_defender_against(struct ai_type *ait,
 
     def_values[utype_index(deftype)] = def;
 
-    if (can_city_build_unit_now(nmap, pcity, deftype)) {
+    if (can_city_build_unit_now(nmap, pcity, deftype, RPT_CERTAIN)) {
       if (def > best_avl_def) {
         best_avl_def = def;
         best_avl = deftype;
@@ -428,7 +428,7 @@ struct unit_type *dai_wants_defender_against(struct ai_type *ait,
 
   unit_type_iterate(deftype) {
     if (def_values[utype_index(deftype)] > best_avl_def
-        && !can_city_build_unit_now(nmap, pcity, deftype)
+        && !can_city_build_unit_now(nmap, pcity, deftype, RPT_CERTAIN)
         && can_city_build_unit_later(nmap, pcity, deftype)) {
       /* It would be better than current best. Consider researching tech */
       const struct impr_type *building;
@@ -535,7 +535,7 @@ struct unit_type *dai_wants_role_unit(struct ai_type *ait, struct player *pplaye
   for (i = n - 1; i >= 0; i--) {
     struct unit_type *iunit = get_role_unit(role, i);
 
-    if (can_city_build_unit_now(nmap, pcity, iunit)) {
+    if (can_city_build_unit_now(nmap, pcity, iunit, RPT_CERTAIN)) {
       build_unit = iunit;
       break;
     } else if (can_city_build_unit_later(nmap, pcity, iunit)) {
diff --git a/ai/default/daiunit.c b/ai/default/daiunit.c
index 58ce1b4924..0b1af0e338 100644
--- a/ai/default/daiunit.c
+++ b/ai/default/daiunit.c
@@ -3480,7 +3480,8 @@ static bool role_unit_cb(struct unit_type *ptype, void *data)
   }
 
   if (cb_data->build_city == nullptr
-      || can_city_build_unit_now(nmap, cb_data->build_city, ptype)) {
+      || can_city_build_unit_now(nmap, cb_data->build_city, ptype,
+                                 RPT_CERTAIN)) {
     return TRUE;
   }
 
diff --git a/ai/tex/texaicity.c b/ai/tex/texaicity.c
index 461194e225..0c11a8bff4 100644
--- a/ai/tex/texaicity.c
+++ b/ai/tex/texaicity.c
@@ -464,7 +464,7 @@ static bool texai_city_worker_task_select(struct ai_type *ait,
   case TWTL_BUILDABLE_UNITS:
     units = unit_list_new();
     unit_type_iterate(ptype) {
-      if (can_city_build_unit_now(nmap, pcity, ptype)) {
+      if (can_city_build_unit_now(nmap, pcity, ptype, RPT_CERTAIN)) {
         unit_list_append(units, unit_virtual_create(pplayer, pcity, ptype, 0));
       }
     } unit_type_iterate_end;
diff --git a/client/climisc.c b/client/climisc.c
index 2570ae51ee..f9e2420416 100644
--- a/client/climisc.c
+++ b/client/climisc.c
@@ -803,7 +803,8 @@ int collect_buildable_targets(struct universal *targets)
   } improvement_iterate_end;
 
   unit_type_iterate(punittype) {
-    if (can_player_build_unit_now(client.conn.playing, punittype)) {
+    if (can_player_build_unit_now(client.conn.playing, punittype,
+                                  RPT_CERTAIN)) {
       targets[cids_used].kind = VUT_UTYPE;
       targets[cids_used].value.utype = punittype;
       cids_used++;
@@ -875,17 +876,17 @@ int collect_eventually_buildable_targets(struct universal *targets,
 
     if (NULL != pcity) {
       /* Can the city build? */
-      can_build = can_city_build_unit_now(nmap, pcity, punittype);
+      can_build = can_city_build_unit_now(nmap, pcity, punittype, RPT_CERTAIN);
       can_eventually_build = can_city_build_unit_later(nmap, pcity, punittype);
     } else if (NULL != pplayer) {
       /* Can our player build? */
-      can_build = can_player_build_unit_now(pplayer, punittype);
+      can_build = can_player_build_unit_now(pplayer, punittype, RPT_CERTAIN);
       can_eventually_build = can_player_build_unit_later(pplayer, punittype);
     } else {
       /* Global observer case: can any player build? */
       can_build = FALSE;
       players_iterate(aplayer) {
-        if (can_player_build_unit_now(aplayer, punittype)) {
+        if (can_player_build_unit_now(aplayer, punittype, RPT_CERTAIN)) {
           can_build = TRUE;
           break;
         }
diff --git a/client/gui-qt/menu.cpp b/client/gui-qt/menu.cpp
index 291f3a9780..97f59cedcb 100644
--- a/client/gui-qt/menu.cpp
+++ b/client/gui-qt/menu.cpp
@@ -1979,11 +1979,11 @@ void mr_menu::update_airlift_menu()
   unit_type_iterate(utype) {
     utype_id = utype_index(utype);
 
-    if (!can_player_build_unit_now(pplayer, utype)
+    if (!can_player_build_unit_now(pplayer, utype, RPT_CERTAIN)
         || !utype_can_do_action(utype, ACTION_AIRLIFT)) {
       continue;
     }
-    if (!can_player_build_unit_now(pplayer, utype)
+    if (!can_player_build_unit_now(pplayer, utype, RPT_CERTAIN)
         && !has_player_unit_type(utype_id)) {
       continue;
     }
diff --git a/client/gui-sdl2/wldlg.c b/client/gui-sdl2/wldlg.c
index 524f5cdda9..1a6e8d755b 100644
--- a/client/gui-sdl2/wldlg.c
+++ b/client/gui-sdl2/wldlg.c
@@ -1589,13 +1589,14 @@ void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
   /* ------------------------------ */
 
   unit_type_iterate(un) {
-    can_build = can_player_build_unit_now(client.conn.playing, un);
-    can_eventually_build =
-        can_player_build_unit_later(client.conn.playing, un);
+    can_build = can_player_build_unit_now(client.conn.playing, un, RPT_CERTAIN);
+    can_eventually_build
+      = can_player_build_unit_later(client.conn.playing, un);
 
     /* If there's a city, can the city build the unit? */
     if (pcity) {
-      can_build = can_build && can_city_build_unit_now(nmap, pcity, un);
+      can_build = can_build && can_city_build_unit_now(nmap, pcity, un,
+                                                       RPT_CERTAIN);
       can_eventually_build = can_eventually_build
         && can_city_build_unit_later(nmap, pcity, un);
     }
diff --git a/client/gui-sdl3/wldlg.c b/client/gui-sdl3/wldlg.c
index 7bdf5c1062..40b6f6ab03 100644
--- a/client/gui-sdl3/wldlg.c
+++ b/client/gui-sdl3/wldlg.c
@@ -1585,13 +1585,14 @@ void popup_worklist_editor(struct city *pcity, struct global_worklist *gwl)
   /* ------------------------------ */
 
   unit_type_iterate(un) {
-    can_build = can_player_build_unit_now(client.conn.playing, un);
-    can_eventually_build =
-        can_player_build_unit_later(client.conn.playing, un);
+    can_build = can_player_build_unit_now(client.conn.playing, un, RPT_CERTAIN);
+    can_eventually_build
+      = can_player_build_unit_later(client.conn.playing, un);
 
     /* If there's a city, can the city build the unit? */
     if (pcity) {
-      can_build = can_build && can_city_build_unit_now(nmap, pcity, un);
+      can_build = can_build && can_city_build_unit_now(nmap, pcity, un,
+                                                       RPT_CERTAIN);
       can_eventually_build = can_eventually_build
         && can_city_build_unit_later(nmap, pcity, un);
     }
diff --git a/client/mapctrl_common.c b/client/mapctrl_common.c
index 7214560802..c77d0e06f0 100644
--- a/client/mapctrl_common.c
+++ b/client/mapctrl_common.c
@@ -399,6 +399,7 @@ bool clipboard_copy_production(struct tile *ptile)
 
     if (!can_player_build_unit_direct(client.conn.playing,
                                       unit_type_get(punit),
+                                      RPT_CERTAIN,
                                       FALSE))  {
       create_event(ptile, E_BAD_COMMAND, ftc_client,
                    _("You don't know how to build %s!"),
diff --git a/common/aicore/aisupport.c b/common/aicore/aisupport.c
index 0cd696074f..0327a10036 100644
--- a/common/aicore/aisupport.c
+++ b/common/aicore/aisupport.c
@@ -129,7 +129,8 @@ int city_gold_worth(const struct civ_map *nmap, struct city *pcity)
     if (same_pos(unit_tile(punit), pcity->tile)) {
       const struct unit_type *punittype = unit_type_get(punit)->obsoleted_by;
 
-      if (punittype && can_city_build_unit_direct(nmap, pcity, punittype)) {
+      if (punittype
+          && can_city_build_unit_direct(nmap, pcity, punittype, RPT_CERTAIN)) {
         /* Obsolete, candidate for disbanding */
         worth += unit_shield_value(punit, unit_type_get(punit),
                                    action_by_number(ACTION_DISBAND_UNIT_RECOVER));
diff --git a/common/city.c b/common/city.c
index 33c6f5b5e2..77d6af349f 100644
--- a/common/city.c
+++ b/common/city.c
@@ -910,9 +910,11 @@ bool can_city_build_improvement_later(const struct city *pcity,
 **************************************************************************/
 bool can_city_build_unit_direct(const struct civ_map *nmap,
                                 const struct city *pcity,
-                                const struct unit_type *punittype)
+                                const struct unit_type *punittype,
+                                const enum req_problem_type prob_type)
 {
-  if (!can_player_build_unit_direct(city_owner(pcity), punittype, FALSE)) {
+  if (!can_player_build_unit_direct(city_owner(pcity), punittype,
+                                    prob_type, FALSE)) {
     return FALSE;
   }
 
@@ -954,16 +956,18 @@ bool can_city_build_unit_direct(const struct civ_map *nmap,
 **************************************************************************/
 bool can_city_build_unit_now(const struct civ_map *nmap,
                              const struct city *pcity,
-                             const struct unit_type *punittype)
+                             const struct unit_type *punittype,
+                             const enum req_problem_type prob_type)
 {
-  if (!can_city_build_unit_direct(nmap, pcity, punittype)) {
+  if (!can_city_build_unit_direct(nmap, pcity, punittype, prob_type)) {
     return FALSE;
   }
 
   while ((punittype = punittype->obsoleted_by) != U_NOT_OBSOLETED) {
     /* TODO: Decide if fulfilled impr_req is needed to make unit obsolete,
      *       i.e., should the 'consider_reg_impr_req' be TRUE or FALSE. */
-    if (can_player_build_unit_direct(city_owner(pcity), punittype, TRUE)) {
+    if (can_player_build_unit_direct(city_owner(pcity), punittype,
+                                     prob_type, TRUE)) {
       return FALSE;
     }
   }
@@ -1005,7 +1009,8 @@ bool can_city_build_direct(const struct civ_map *nmap,
 {
   switch (target->kind) {
   case VUT_UTYPE:
-    return can_city_build_unit_direct(nmap, pcity, target->value.utype);
+    return can_city_build_unit_direct(nmap, pcity, target->value.utype,
+                                      RPT_CERTAIN);
   case VUT_IMPROVEMENT:
     return can_city_build_improvement_direct(pcity, target->value.building,
                                              RPT_CERTAIN);
@@ -1025,7 +1030,8 @@ bool can_city_build_now(const struct civ_map *nmap,
 {
   switch (target->kind) {
   case VUT_UTYPE:
-    return can_city_build_unit_now(nmap, pcity, target->value.utype);
+    return can_city_build_unit_now(nmap, pcity, target->value.utype,
+                                   RPT_CERTAIN);
   case VUT_IMPROVEMENT:
     return can_city_build_improvement_now(pcity, target->value.building,
                                           RPT_CERTAIN);
@@ -1099,7 +1105,7 @@ void city_choose_build_default(const struct civ_map *nmap, struct city *pcity)
   if (city_tile(pcity) == nullptr) {
     /* When a "dummy" city is created with no tile, then choosing a build
      * target could fail. This currently might happen during map editing.
-     * FIXME: assumes the first unit is always "valid", so check for
+     * FIXME: Assumes the first unit is always "valid", so check for
      * obsolete units elsewhere. */
     pcity->production.kind = VUT_UTYPE;
     pcity->production.value.utype = utype_by_number(0);
@@ -1125,7 +1131,8 @@ void city_choose_build_default(const struct civ_map *nmap, struct city *pcity)
 
       if (!found) {
         unit_type_iterate(punittype) {
-          if (can_city_build_unit_direct(nmap, pcity, punittype)) {
+          if (can_city_build_unit_direct(nmap, pcity, punittype,
+                                         RPT_CERTAIN)) {
 #ifndef FREECIV_NDEBUG
             /* Later than this, 'found' is only needed in an fc_assert() */
             found = TRUE;
diff --git a/common/city.h b/common/city.h
index 22c6e7842f..a3ee7b2d0b 100644
--- a/common/city.h
+++ b/common/city.h
@@ -611,13 +611,15 @@ bool can_city_build_improvement_now(const struct city *pcity,
 
 bool can_city_build_unit_direct(const struct civ_map *nmap,
                                 const struct city *pcity,
-                                const struct unit_type *punittype);
+                                const struct unit_type *punittype,
+                                const enum req_problem_type prob_type);
 bool can_city_build_unit_later(const struct civ_map *nmap,
                                const struct city *pcity,
                                const struct unit_type *punittype);
 bool can_city_build_unit_now(const struct civ_map *nmap,
                              const struct city *pcity,
-                             const struct unit_type *punittype);
+                             const struct unit_type *punittype,
+                             const enum req_problem_type prob_type);
 
 bool can_city_build_direct(const struct civ_map *nmap,
                            const struct city *pcity,
diff --git a/common/improvement.c b/common/improvement.c
index 36d8707918..e4ffa9ca85 100644
--- a/common/improvement.c
+++ b/common/improvement.c
@@ -445,7 +445,7 @@ static bool impr_provides_buildable_units(const struct city *pcity,
 
   unit_type_iterate(ut) {
     if (requirement_needs_improvement(pimprove, &ut->build_reqs)
-        && can_city_build_unit_now(nmap, pcity, ut)) {
+        && can_city_build_unit_now(nmap, pcity, ut, RPT_CERTAIN)) {
       return TRUE;
     }
   } unit_type_iterate_end;
@@ -556,7 +556,7 @@ static bool impr_allows_actions(const struct city *pcity,
             return TRUE;
           }
 
-          if (can_city_build_unit_now(nmap, pcity, ut)) {
+          if (can_city_build_unit_now(nmap, pcity, ut, RPT_CERTAIN)) {
             /* This city can build a unit that uses the building */
             return TRUE;
           }
diff --git a/common/scriptcore/api_game_methods.c b/common/scriptcore/api_game_methods.c
index 644f51aa3c..59683fe6de 100644
--- a/common/scriptcore/api_game_methods.c
+++ b/common/scriptcore/api_game_methods.c
@@ -803,7 +803,7 @@ bool api_methods_player_can_build_unit_direct(lua_State *L, Player *pplayer,
   LUASCRIPT_CHECK_SELF(L, pplayer, FALSE);
   LUASCRIPT_CHECK_ARG_NIL(L, utype, 3, Unit_Type, FALSE);
 
-  return can_player_build_unit_direct(pplayer, utype, TRUE);
+  return can_player_build_unit_direct(pplayer, utype, RPT_CERTAIN, TRUE);
 }
 
 /**********************************************************************//**
diff --git a/common/unittype.c b/common/unittype.c
index b417860099..24ce834553 100644
--- a/common/unittype.c
+++ b/common/unittype.c
@@ -1740,7 +1740,8 @@ const struct unit_type *can_upgrade_unittype(const struct player *pplayer,
    * diplomatic treaties, or lua script. */
 
   while ((upgrade = upgrade->obsoleted_by) != U_NOT_OBSOLETED) {
-    if (can_player_build_unit_direct(pplayer, upgrade, TRUE)) {
+    if (can_player_build_unit_direct(pplayer, upgrade,
+                                     RPT_CERTAIN, TRUE)) {
       best_upgrade = upgrade;
     }
   }
@@ -1993,6 +1994,7 @@ bool utype_player_already_has_this(const struct player *pplayer,
 **************************************************************************/
 bool can_player_build_unit_direct(const struct player *p,
                                   const struct unit_type *punittype,
+                                  const enum req_problem_type prob_type,
                                   bool consider_reg_impr_req)
 {
   const struct req_context context = { .player = p, .unittype = punittype };
@@ -2079,14 +2081,14 @@ bool can_player_build_unit_direct(const struct player *p,
           req_copy(&copy, preq);
           copy.range = REQ_RANGE_WORLD;
 
-          if (!is_req_active(&context, nullptr, &copy, RPT_CERTAIN)) {
+          if (!is_req_active(&context, nullptr, &copy, prob_type)) {
             return FALSE;
           }
-        } else if (!is_req_active(&context, nullptr, preq, RPT_CERTAIN)) {
+        } else if (!is_req_active(&context, nullptr, preq, prob_type)) {
           return FALSE;
         }
       }
-    } else if (!is_req_active(&context, nullptr, preq, RPT_CERTAIN)) {
+    } else if (!is_req_active(&context, nullptr, preq, prob_type)) {
       return FALSE;
     }
   } requirement_vector_iterate_end;
@@ -2104,14 +2106,15 @@ bool can_player_build_unit_direct(const struct player *p,
   returns FALSE if unit is obsolete.
 **************************************************************************/
 bool can_player_build_unit_now(const struct player *p,
-                               const struct unit_type *punittype)
+                               const struct unit_type *punittype,
+                               const enum req_problem_type prob_type)
 {
-  if (!can_player_build_unit_direct(p, punittype, FALSE)) {
+  if (!can_player_build_unit_direct(p, punittype, prob_type, FALSE)) {
     return FALSE;
   }
 
   while ((punittype = punittype->obsoleted_by) != U_NOT_OBSOLETED) {
-    if (can_player_build_unit_direct(p, punittype, TRUE)) {
+    if (can_player_build_unit_direct(p, punittype, prob_type, TRUE)) {
       return FALSE;
     }
   }
@@ -2134,7 +2137,7 @@ bool can_player_build_unit_later(const struct player *p,
   }
 
   while ((punittype = punittype->obsoleted_by) != U_NOT_OBSOLETED) {
-    if (can_player_build_unit_direct(p, punittype, TRUE)) {
+    if (can_player_build_unit_direct(p, punittype, RPT_CERTAIN, TRUE)) {
       return FALSE;
     }
   }
@@ -2310,7 +2313,7 @@ struct unit_type *best_role_unit(const struct city *pcity, int role)
 
   for (j = n_with_role[role] - 1; j >= 0; j--) {
     u = with_role[role][j];
-    if (can_city_build_unit_now(nmap, pcity, u)) {
+    if (can_city_build_unit_now(nmap, pcity, u, RPT_CERTAIN)) {
       return u;
     }
   }
@@ -2337,7 +2340,7 @@ struct unit_type *best_role_unit_for_player(const struct player *pplayer,
   for (j = n_with_role[role] - 1; j >= 0; j--) {
     struct unit_type *utype = with_role[role][j];
 
-    if (can_player_build_unit_now(pplayer, utype)) {
+    if (can_player_build_unit_now(pplayer, utype, RPT_CERTAIN)) {
       return utype;
     }
   }
@@ -2362,7 +2365,7 @@ struct unit_type *first_role_unit_for_player(const struct player *pplayer,
   for (j = 0; j < n_with_role[role]; j++) {
     struct unit_type *utype = with_role[role][j];
 
-    if (can_player_build_unit_now(pplayer, utype)) {
+    if (can_player_build_unit_now(pplayer, utype, RPT_CERTAIN)) {
       return utype;
     }
   }
diff --git a/common/unittype.h b/common/unittype.h
index a988c3f1e1..409811b4a9 100644
--- a/common/unittype.h
+++ b/common/unittype.h
@@ -838,11 +838,13 @@ bool utype_player_already_has_this_unique(const struct player *pplayer,
 
 bool can_player_build_unit_direct(const struct player *p,
                                   const struct unit_type *punittype,
+                                  const enum req_problem_type prob_type,
                                   bool consider_reg_impr_req);
 bool can_player_build_unit_later(const struct player *p,
                                  const struct unit_type *punittype);
 bool can_player_build_unit_now(const struct player *p,
-                               const struct unit_type *punittype);
+                               const struct unit_type *punittype,
+                               const enum req_problem_type prob_type);
 
 #define utype_fuel(ptype) (ptype)->fuel
 
diff --git a/server/advisors/advdata.c b/server/advisors/advdata.c
index e99b8ecc11..e6e60856e8 100644
--- a/server/advisors/advdata.c
+++ b/server/advisors/advdata.c
@@ -399,7 +399,8 @@ bool adv_data_phase_init(struct player *pplayer, bool is_new_phase)
         struct unit_type *nuke
           = get_role_unit(action_id_get_role(act_id), i);
 
-        if (can_player_build_unit_direct(aplayer, nuke, FALSE)) {
+        if (can_player_build_unit_direct(aplayer, nuke,
+                                         RPT_CERTAIN, FALSE)) {
           adv->threats.nuclear = 1;
         }
       }
diff --git a/server/cityturn.c b/server/cityturn.c
index a217eeb256..508ea2cb28 100644
--- a/server/cityturn.c
+++ b/server/cityturn.c
@@ -2579,7 +2579,8 @@ void choose_build_target(struct player *pplayer, struct city *pcity)
   case VUT_UTYPE:
     /* We can build a unit again unless it's unique or we have lost the tech. */
     if (!utype_has_flag(pcity->production.value.utype, UTYF_UNIQUE)
-        && can_city_build_unit_now(nmap, pcity, pcity->production.value.utype)) {
+        && can_city_build_unit_now(nmap, pcity, pcity->production.value.utype,
+                                   RPT_CERTAIN)) {
       log_base(LOG_BUILD_TARGET, "%s repeats building %s", city_name_get(pcity),
                utype_rule_name(pcity->production.value.utype));
       return;
@@ -2664,11 +2665,11 @@ static const struct unit_type *unit_upgrades_to(struct city *pcity,
   const struct unit_type *best_upgrade = U_NOT_OBSOLETED;
   const struct civ_map *nmap = &(wld.map);
 
-  if (!can_city_build_unit_direct(nmap, pcity, punittype)) {
+  if (!can_city_build_unit_direct(nmap, pcity, punittype, RPT_CERTAIN)) {
     return U_NOT_OBSOLETED;
   }
   while ((check = check->obsoleted_by) != U_NOT_OBSOLETED) {
-    if (can_city_build_unit_direct(nmap, pcity, check)) {
+    if (can_city_build_unit_direct(nmap, pcity, check, RPT_CERTAIN)) {
       best_upgrade = check;
     }
   }
@@ -2685,7 +2686,8 @@ static void upgrade_unit_prod(struct city *pcity)
   const struct unit_type *upgrading = unit_upgrades_to(pcity, producing);
   const struct civ_map *nmap = &(wld.map);
 
-  if (upgrading && can_city_build_unit_direct(nmap, pcity, upgrading)) {
+  if (upgrading && can_city_build_unit_direct(nmap, pcity, upgrading,
+                                              RPT_CERTAIN)) {
     notify_player(city_owner(pcity), city_tile(pcity),
                   E_UNIT_UPGRADED, ftc_server,
                   _("Production of %s is upgraded to %s in %s."),
@@ -3031,7 +3033,7 @@ static bool city_build_unit(struct player *pplayer, struct city *pcity)
   /* We must make a special case for barbarians here, because they are
      so dumb. Really. They don't know the prerequisite techs for units
      they build!! - Per */
-  if (!can_city_build_unit_direct(nmap, pcity, utype)
+  if (!can_city_build_unit_direct(nmap, pcity, utype, RPT_CERTAIN)
       && !is_barbarian(pplayer)) {
     notify_player(pplayer, city_tile(pcity), E_CITY_CANTBUILD, ftc_server,
                   _("%s is building %s, which is no longer available."),
diff --git a/server/techtools.c b/server/techtools.c
index f7ae30891a..88886569e0 100644
--- a/server/techtools.c
+++ b/server/techtools.c
@@ -900,7 +900,8 @@ static void research_tech_lost(struct research *presearch, Tech_type_id tech)
       bool update = FALSE;
 
       if (pcity->production.kind == VUT_UTYPE
-          && !can_city_build_unit_now(nmap, pcity, pcity->production.value.utype)) {
+          && !can_city_build_unit_now(nmap, pcity, pcity->production.value.utype,
+                                      RPT_CERTAIN)) {
         notify_player(pplayer, city_tile(pcity),
                       E_CITY_CANTBUILD, ftc_server,
                       _("%s can't build %s. The required technology was "
diff --git a/server/unittools.c b/server/unittools.c
index 1f8e5f099d..29607de75e 100644
--- a/server/unittools.c
+++ b/server/unittools.c
@@ -188,7 +188,8 @@ struct unit_type *find_a_unit_type(enum unit_role_id role,
        * fail. */
       players_iterate(pplayer) {
         if (!is_barbarian(pplayer)
-            && can_player_build_unit_direct(pplayer, iunit, TRUE)) {
+            && can_player_build_unit_direct(pplayer, iunit,
+                                            RPT_CERTAIN, TRUE)) {
           players++;
         }
       } players_iterate_end;
-- 
2.51.0

