From 3c700f4f32b0b23b8e109b72a7473efc83b6a9f4 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Fri, 3 Apr 2026 20:04:00 +0300
Subject: [PATCH 30/30] traderoutes.c: Replace NULL with nullptr

See RM #1981

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/traderoutes.c | 67 ++++++++++++++++++++++----------------------
 1 file changed, 34 insertions(+), 33 deletions(-)

diff --git a/common/traderoutes.c b/common/traderoutes.c
index c81a0d743b..678e25c564 100644
--- a/common/traderoutes.c
+++ b/common/traderoutes.c
@@ -147,7 +147,7 @@ void trade_route_types_init(void)
 *************************************************************************/
 const char *trade_route_type_name(enum trade_route_type type)
 {
-  fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, NULL);
+  fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, nullptr);
 
   return trade_route_type_names[type];
 }
@@ -173,7 +173,7 @@ enum trade_route_type trade_route_type_by_name(const char *name)
 *************************************************************************/
 const char *trade_route_cancelling_type_name(enum trade_route_illegal_cancelling type)
 {
-  fc_assert_ret_val(type >= TRI_ACTIVE && type < TRI_LAST, NULL);
+  fc_assert_ret_val(type >= TRI_ACTIVE && type < TRI_LAST, nullptr);
 
   return trade_route_cancelling_type_names[type];
 }
@@ -200,7 +200,7 @@ enum trade_route_illegal_cancelling trade_route_cancelling_type_by_name(const ch
 struct trade_route_settings *
 trade_route_settings_by_type(enum trade_route_type type)
 {
-  fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, NULL);
+  fc_assert_ret_val(type >= TRT_NATIONAL && type < TRT_LAST, nullptr);
 
   return &trtss[type];
 }
@@ -268,7 +268,7 @@ int city_trade_removable(const struct city *pcity, int priority,
   /* Return values. */
   for (i = j = 0; i < num; i++) {
     j += sorted[i]->value;
-    if (NULL != would_remove) {
+    if (would_remove != nullptr) {
       trade_route_list_append(would_remove, sorted[i]);
     }
   }
@@ -307,7 +307,7 @@ bool can_establish_trade_route(const struct city *pc1, const struct city *pc2,
   if (city_num_trade_routes(pc1) >= maxpc1) {
     trade = trade_base_between_cities(pc1, pc2);
     /* Can we replace trade route? */
-    if (city_trade_removable(pc1, priority, NULL) >= trade) {
+    if (city_trade_removable(pc1, priority, nullptr) >= trade) {
       return FALSE;
     }
   }
@@ -317,7 +317,7 @@ bool can_establish_trade_route(const struct city *pc1, const struct city *pc2,
       trade = trade_base_between_cities(pc1, pc2);
     }
     /* Can we replace trade route? */
-    if (city_trade_removable(pc2, priority, NULL) >= trade) {
+    if (city_trade_removable(pc2, priority, nullptr) >= trade) {
       return FALSE;
     }
   }
@@ -326,14 +326,15 @@ bool can_establish_trade_route(const struct city *pc1, const struct city *pc2,
 }
 
 /*********************************************************************//**
-  Return the trade that exists between these cities, assuming they have a
-  trade route.
+  Return the trade that exists between these cities, assuming they have
+  a trade route.
 *************************************************************************/
 int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
 {
   int bonus = 0;
 
-  if (NULL == pc1 || NULL == pc1->tile || NULL == pc2 || NULL == pc2->tile) {
+  if (pc1 == nullptr || pc1->tile == nullptr
+      || pc2 == nullptr || pc2->tile == nullptr) {
     return 0;
   }
 
@@ -350,7 +351,7 @@ int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
   } else if (game.info.trade_revenue_style == TRS_SIMPLE) {
     /* Simple revenue style */
     bonus = (pc1->citizen_base[O_TRADE] + pc2->citizen_base[O_TRADE] + 4)
-	    * 3;
+            * 3;
   }
 
   bonus = bonus
@@ -366,7 +367,7 @@ int trade_base_between_cities(const struct city *pc1, const struct city *pc2)
   Get trade income specific to route's good.
 *************************************************************************/
 int trade_from_route(const struct city *pc1, const struct trade_route *route,
-		     int base)
+                     int base)
 {
   int val;
 
@@ -415,14 +416,14 @@ static int max_tile_trade(const struct city *pcity)
   bool is_celebrating = base_city_celebrating(pcity);
   const struct civ_map *nmap = &(wld.map);
 
-  if (pcity->tile == NULL) {
+  if (pcity->tile == nullptr) {
     return 0;
   }
 
   city_map_iterate(radius_sq, cindex, cx, cy) {
     struct tile *ptile = city_map_to_tile(nmap, pcity->tile, radius_sq, cx, cy);
 
-    if (ptile == NULL) {
+    if (ptile == nullptr) {
       continue;
     }
 
@@ -472,7 +473,7 @@ int max_trade_prod(const struct city *pcity)
   If you change this calculation remember to also update its duplication
   in dai_choose_trade_route()
 
-  pgood can be NULL for ignoring good's onetime_pct.
+  pgood can be nullptr for ignoring good's onetime_pct.
 *************************************************************************/
 int get_caravan_enter_city_trade_bonus(const struct city *pc1,
                                        const struct city *pc2,
@@ -509,12 +510,12 @@ int get_caravan_enter_city_trade_bonus(const struct city *pc1,
                  + max_trade_prod(pc1) + max_trade_prod(pc2)) * 2, 2);
   }
 
-  if (pgood != NULL) {
+  if (pgood != nullptr) {
     tb = tb * pgood->onetime_pct / 100;
   }
 
   /* Trade_revenue_bonus increases revenue by power of 2 in milimes */
-  bonus = get_target_bonus_effects(NULL,
+  bonus = get_target_bonus_effects(nullptr,
                                    &(const struct req_context) {
                                      .player = city_owner(pc1),
                                      .city = pc1,
@@ -571,7 +572,7 @@ void goods_init(void)
 
     requirement_vector_init(&(goods[i].reqs));
     goods[i].ruledit_disabled = FALSE;
-    goods[i].helptext = NULL;
+    goods[i].helptext = nullptr;
   }
 }
 
@@ -585,9 +586,9 @@ void goods_free(void)
   for (i = 0; i < MAX_GOODS_TYPES; i++) {
     requirement_vector_free(&(goods[i].reqs));
 
-    if (NULL != goods[i].helptext) {
+    if (goods[i].helptext != nullptr) {
       strvec_destroy(goods[i].helptext);
-      goods[i].helptext = NULL;
+      goods[i].helptext = nullptr;
     }
   }
 }
@@ -597,7 +598,7 @@ void goods_free(void)
 *************************************************************************/
 Goods_type_id goods_number(const struct goods_type *pgood)
 {
-  fc_assert_ret_val(NULL != pgood, -1);
+  fc_assert_ret_val(pgood != nullptr, -1);
 
   return pgood->id;
 }
@@ -610,7 +611,7 @@ Goods_type_id goods_number(const struct goods_type *pgood)
 *************************************************************************/
 Goods_type_id goods_index(const struct goods_type *pgood)
 {
-  fc_assert_ret_val(NULL != pgood, -1);
+  fc_assert_ret_val(pgood != nullptr, -1);
 
   return pgood - goods;
 }
@@ -620,7 +621,7 @@ Goods_type_id goods_index(const struct goods_type *pgood)
 *************************************************************************/
 struct goods_type *goods_by_number(Goods_type_id id)
 {
-  fc_assert_ret_val(id >= 0 && id < game.control.num_goods_types, NULL);
+  fc_assert_ret_val(id >= 0 && id < game.control.num_goods_types, nullptr);
 
   return &goods[id];
 }
@@ -642,15 +643,15 @@ const char *goods_rule_name(struct goods_type *pgood)
 }
 
 /*********************************************************************//**
-  Returns goods type matching rule name or NULL if there is no goods type
-  with such name.
+  Returns goods type matching rule name or nullptr if there is no
+  goods type with such name.
 *************************************************************************/
 struct goods_type *goods_by_rule_name(const char *name)
 {
   const char *qs;
 
-  if (name == NULL) {
-    return NULL;
+  if (name == nullptr) {
+    return nullptr;
   }
 
   qs = Qn_(name);
@@ -661,12 +662,12 @@ struct goods_type *goods_by_rule_name(const char *name)
     }
   } goods_type_iterate_end;
 
-  return NULL;
+  return nullptr;
 }
 
 /*********************************************************************//**
-  Returns goods type matching the translated name, or NULL if there is no
-  goods type with that name.
+  Returns goods type matching the translated name, or nullptr if there is
+  no goods type with that name.
 *************************************************************************/
 struct goods_type *goods_by_translated_name(const char *name)
 {
@@ -676,7 +677,7 @@ struct goods_type *goods_by_translated_name(const char *name)
     }
   } goods_type_iterate_end;
 
-  return NULL;
+  return nullptr;
 }
 
 /*********************************************************************//**
@@ -699,9 +700,9 @@ bool goods_can_be_provided(const struct city *pcity,
                            .city = pcity,
                            .tile = city_tile(pcity),
                            .unit = punit,
-                           .unittype = punit ? unit_type_get(punit) : NULL,
+                           .unittype = punit ? unit_type_get(punit) : nullptr,
                          },
-                         NULL,
+                         nullptr,
                          &pgood->reqs, RPT_CERTAIN);
 }
 
@@ -763,7 +764,7 @@ struct goods_type *goods_from_city_to_unit(const struct city *src,
   } goods_type_iterate_end;
 
   if (i == 0) {
-    return NULL;
+    return nullptr;
   }
 
   return potential[fc_rand(i)];
-- 
2.53.0

