From f77117de8e677d93b94a82674c12d0c8253a36e4 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Tue, 22 Sep 2026 02:47:47 +0300
Subject: [PATCH 69/69] tex/: Replace NULL with nullptr

See RM #2271

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 ai/tex/texai.c      |  2 +-
 ai/tex/texaicity.c  | 54 ++++++++++++++++++++++++---------------------
 ai/tex/texaimsg.c   |  4 ++--
 ai/tex/texaiworld.c | 30 ++++++++++++-------------
 4 files changed, 47 insertions(+), 43 deletions(-)

diff --git a/ai/tex/texai.c b/ai/tex/texai.c
index 197f2789c2..378c8b5c09 100644
--- a/ai/tex/texai.c
+++ b/ai/tex/texai.c
@@ -44,7 +44,7 @@ bool fc_ai_tex_setup(struct ai_type *ai);
 
 static void texai_init_self(struct ai_type *ai);
 
-static struct ai_type *self = NULL;
+static struct ai_type *self = nullptr;
 
 /**********************************************************************//**
   Set pointer to ai type of the tex ai.
diff --git a/ai/tex/texaicity.c b/ai/tex/texaicity.c
index 0c11a8bff4..37aff0e7e9 100644
--- a/ai/tex/texaicity.c
+++ b/ai/tex/texaicity.c
@@ -97,10 +97,10 @@ void texai_city_worker_wants(struct ai_type *ait,
   struct texai_city *cdata = texai_city_data(ait, pcity);
   int *wants = cdata->unit_wants;
   int maxwant = 0;
-  struct unit_type *type = NULL;
+  struct unit_type *type = nullptr;
   Continent_id place = tile_continent(city_tile(pcity));
-  struct ai_plr *dai = dai_plr_data_get(ait, pplayer, NULL);
-  struct adv_data *adv = adv_data_get(pplayer, NULL);
+  struct ai_plr *dai = dai_plr_data_get(ait, pplayer, nullptr);
+  struct adv_data *adv = adv_data_get(pplayer, nullptr);
 
   unit_type_iterate(ptype) {
     wants[utype_index(ptype)] = 0;
@@ -180,7 +180,7 @@ static void texai_tile_worker_task_select(struct player *pplayer,
     bool possible = FALSE;
     enum extra_cause cause;
     enum extra_rmcause rmcause;
-    struct extra_type *tgt = NULL;
+    struct extra_type *tgt = nullptr;
 
     /* Do not request activities that already are under way. */
     unit_list_iterate(ptile->units, punit) {
@@ -225,7 +225,7 @@ static void texai_tile_worker_task_select(struct player *pplayer,
           worked->want       = TWMP * (value - orig_value);
           worked->ptile      = ptile;
           worked->act        = action_id_get_activity(act);
-          worked->tgt        = NULL;
+          worked->tgt        = nullptr;
           if (limit == TWTL_BUILDABLE_UNITS) {
             unit_list_iterate(units, punit) {
               if (action_prob_possible(
@@ -252,7 +252,7 @@ static void texai_tile_worker_task_select(struct player *pplayer,
           unworked->want       = TWMP * (value - orig_value);
           unworked->ptile      = ptile;
           unworked->act        = action_id_get_activity(act);
-          unworked->tgt        = NULL;
+          unworked->tgt        = nullptr;
           if (limit == TWTL_BUILDABLE_UNITS) {
             unit_list_iterate(units, punit) {
               if (action_prob_possible(
@@ -271,7 +271,7 @@ static void texai_tile_worker_task_select(struct player *pplayer,
   } aw_transform_action_iterate_end;
 
   extra_type_iterate(tgt) {
-    struct action *paction = NULL;
+    struct action *paction = nullptr;
     bool removing = tile_has_extra(ptile, tgt);
 
     unit_list_iterate(units, punit) {
@@ -308,7 +308,7 @@ static void texai_tile_worker_task_select(struct player *pplayer,
       }
     } unit_list_iterate_end;
 
-    if (paction != NULL) {
+    if (paction != nullptr) {
       adv_want base_value;
       int value;
       adv_want extra;
@@ -337,7 +337,7 @@ static void texai_tile_worker_task_select(struct player *pplayer,
         base_value = adv_city_worker_extra_get(pcity, cindex, tgt);
       }
 
-      if (proad != NULL && road_provides_move_bonus(proad)) {
+      if (proad != nullptr && road_provides_move_bonus(proad)) {
         int old_move_cost;
         int mc_multiplier = 1;
         int mc_divisor = 1;
@@ -449,17 +449,20 @@ static bool texai_city_worker_task_select(struct ai_type *ait,
                                           enum texai_worker_task_limitation limit)
 {
   struct worker_task *selected;
-  struct worker_task worked = { .ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL };
-  struct worker_task unworked = { .ptile = NULL, .want = 0, .act = ACTIVITY_IDLE, .tgt = NULL };
-  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;
+  struct worker_task worked
+    = { .ptile = nullptr, .want = 0, .act = ACTIVITY_IDLE, .tgt = nullptr };
+  struct worker_task unworked
+    = { .ptile = nullptr, .want = 0, .act = ACTIVITY_IDLE, .tgt = nullptr };
+  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 = nullptr;
   const struct civ_map *nmap = &(wld.map);
 
   switch (limit) {
   case TWTL_CURRENT_UNITS:
     units = texai_player_units(pplayer);
-    state.wants = NULL;
+    state.wants = nullptr;
     break;
   case TWTL_BUILDABLE_UNITS:
     units = unit_list_new();
@@ -478,7 +481,7 @@ static bool texai_city_worker_task_select(struct ai_type *ait,
                                   &worked, &unworked, &state, limit);
   } city_tile_iterate_end;
 
-  if (worked.ptile == NULL
+  if (worked.ptile == nullptr
       || (state.old_worst_worked < state.uw_max
           && (state.uw_max - state.orig_worst_worked) * TWMP > worked.want)
       || (state.uw_max - state.uw_max_base * TWMP > worked.want)) {
@@ -497,19 +500,20 @@ static bool texai_city_worker_task_select(struct ai_type *ait,
     unit_list_destroy(units);
   }
 
-  if (selected->ptile != NULL) {
-    struct extra_type *target = NULL;
+  if (selected->ptile != nullptr) {
+    struct extra_type *target = nullptr;
 
-    if (selected->tgt == NULL) {
+    if (selected->tgt == nullptr) {
       enum extra_cause cause = activity_to_extra_cause(selected->act);
 
       if (cause != EC_NONE) {
-        target = next_extra_for_tile(selected->ptile, cause, pplayer, NULL);
+        target = next_extra_for_tile(selected->ptile, cause, pplayer, nullptr);
       } else {
         enum extra_rmcause rmcause = activity_to_extra_rmcause(selected->act);
 
         if (rmcause != ERM_NONE) {
-          target = prev_extra_in_tile(selected->ptile, rmcause, pplayer, NULL);
+          target = prev_extra_in_tile(selected->ptile, rmcause,
+                                      pplayer, nullptr);
         }
       }
     } else {
@@ -537,11 +541,11 @@ void texai_req_worker_task_rcv(struct texai_req *req)
 
   pcity = game_city_by_number(data->city_id);
 
-  if (pcity != NULL && city_owner(pcity) == req->plr) {
+  if (pcity != nullptr && city_owner(pcity) == req->plr) {
     /* City has not been lost meanwhile */
     struct worker_task *ptask = worker_task_list_get(pcity->task_reqs, 0);
 
-    if (ptask == NULL) {
+    if (ptask == nullptr) {
       ptask = fc_malloc(sizeof(struct worker_task));
       worker_task_init(ptask);
       worker_task_list_append(pcity->task_reqs, ptask);
@@ -581,9 +585,9 @@ void texai_city_free(struct ai_type *ait, struct city *pcity)
 {
   struct texai_city *city_data = texai_city_data(ait, pcity);
 
-  if (city_data != NULL) {
+  if (city_data != nullptr) {
     adv_deinit_choice(&(city_data->defai.choice));
-    city_set_ai_data(pcity, ait, NULL);
+    city_set_ai_data(pcity, ait, nullptr);
     FC_FREE(city_data);
   }
 }
diff --git a/ai/tex/texaimsg.c b/ai/tex/texaimsg.c
index 055d593e84..20974f38b5 100644
--- a/ai/tex/texaimsg.c
+++ b/ai/tex/texaimsg.c
@@ -62,7 +62,7 @@ void texai_send_req(enum texaireqtype type, struct player *pplayer,
 **************************************************************************/
 void texai_first_activities(struct ai_type *ait, struct player *pplayer)
 {
-  texai_send_msg(TEXAI_MSG_FIRST_ACTIVITIES, pplayer, NULL);
+  texai_send_msg(TEXAI_MSG_FIRST_ACTIVITIES, pplayer, nullptr);
 }
 
 /**********************************************************************//**
@@ -70,5 +70,5 @@ void texai_first_activities(struct ai_type *ait, struct player *pplayer)
 **************************************************************************/
 void texai_phase_finished(struct ai_type *ait, struct player *pplayer)
 {
-  texai_send_msg(TEXAI_MSG_PHASE_FINISHED, pplayer, NULL);
+  texai_send_msg(TEXAI_MSG_PHASE_FINISHED, pplayer, nullptr);
 }
diff --git a/ai/tex/texaiworld.c b/ai/tex/texaiworld.c
index 97d6c55e1f..61c71c569b 100644
--- a/ai/tex/texaiworld.c
+++ b/ai/tex/texaiworld.c
@@ -117,7 +117,7 @@ void texai_tile_info(struct tile *ptile)
     info->terrain = ptile->terrain;
     info->extras = ptile->extras;
 
-    texai_send_msg(TEXAI_MSG_TILE_INFO, NULL, info);
+    texai_send_msg(TEXAI_MSG_TILE_INFO, nullptr, info);
   }
 }
 
@@ -128,7 +128,7 @@ void texai_tile_info_recv(void *data)
 {
   struct texai_tile_info_msg *info = (struct texai_tile_info_msg *)data;
 
-  if (texai_world.map.tiles != NULL) {
+  if (texai_world.map.tiles != nullptr) {
     struct tile *ptile;
 
     ptile = index_to_tile(&(texai_world.map), info->index);
@@ -152,7 +152,7 @@ static void texai_city_update(struct city *pcity, enum texaimsgtype msgtype)
     info->owner = player_number(city_owner(pcity));
     info->tindex = tile_index(city_tile(pcity));
 
-    texai_send_msg(msgtype, NULL, info);
+    texai_send_msg(msgtype, nullptr, info);
   }
 }
 
@@ -185,7 +185,7 @@ void texai_city_info_recv(void *data, enum texaimsgtype msgtype)
     struct tile *ptile;
     struct texai_plr *plr_data;
 
-    if (idex_lookup_city(&texai_world, info->id) != NULL) {
+    if (idex_lookup_city(&texai_world, info->id) != nullptr) {
       return;
     }
 
@@ -202,7 +202,7 @@ void texai_city_info_recv(void *data, enum texaimsgtype msgtype)
   } else {
     pcity = idex_lookup_city(&texai_world, info->id);
 
-    if (pcity != NULL) {
+    if (pcity != nullptr) {
       pcity->owner = pplayer;
     } else {
       log_error("Tex: requested change on city id %d that's not known.",
@@ -231,7 +231,7 @@ void texai_city_destroyed(struct city *pcity)
 
     info->id = pcity->id;
 
-    texai_send_msg(TEXAI_MSG_CITY_DESTROYED, NULL, info);
+    texai_send_msg(TEXAI_MSG_CITY_DESTROYED, nullptr, info);
   }
 }
 
@@ -243,11 +243,11 @@ void texai_city_destruction_recv(void *data)
   struct texai_id_msg *info = (struct texai_id_msg *)data;
   struct city *pcity = idex_lookup_city(&texai_world, info->id);
 
-  if (pcity != NULL) {
+  if (pcity != nullptr) {
     struct texai_plr *plr_data;
 
     adv_city_free(pcity);
-    tile_set_worked(city_tile(pcity), NULL);
+    tile_set_worked(city_tile(pcity), nullptr);
     plr_data = player_ai_data(city_owner(pcity), texai_get_self());
     city_list_remove(plr_data->cities, pcity);
     idex_unregister_city(&texai_world, pcity);
@@ -274,7 +274,7 @@ static void texai_unit_update(struct unit *punit, enum texaimsgtype msgtype)
     info->tindex = tile_index(unit_tile(punit));
     info->type = utype_number(unit_type_get(punit));
 
-    texai_send_msg(msgtype, NULL, info);
+    texai_send_msg(msgtype, nullptr, info);
   }
 }
 
@@ -308,13 +308,13 @@ void texai_unit_info_recv(void *data, enum texaimsgtype msgtype)
   if (msgtype == TEXAI_MSG_UNIT_CREATED) {
     struct texai_plr *plr_data;
 
-    if (idex_lookup_unit(&texai_world, info->id) != NULL) {
+    if (idex_lookup_unit(&texai_world, info->id) != nullptr) {
       return;
     }
 
     plr_data = player_ai_data(pplayer, texai_get_self());
 
-    punit = unit_virtual_create(pplayer, NULL, type, 0);
+    punit = unit_virtual_create(pplayer, nullptr, type, 0);
     punit->id = info->id;
 
     idex_register_unit(&texai_world, punit);
@@ -343,7 +343,7 @@ void texai_unit_destroyed(struct unit *punit)
 
     info->id = punit->id;
 
-    texai_send_msg(TEXAI_MSG_UNIT_DESTROYED, NULL, info);
+    texai_send_msg(TEXAI_MSG_UNIT_DESTROYED, nullptr, info);
   }
 }
 
@@ -355,7 +355,7 @@ void texai_unit_destruction_recv(void *data)
   struct texai_id_msg *info = (struct texai_id_msg *)data;
   struct unit *punit = idex_lookup_unit(&texai_world, info->id);
 
-  if (punit != NULL) {
+  if (punit != nullptr) {
     struct texai_plr *plr_data = player_ai_data(punit->owner,
                                                 texai_get_self());
 
@@ -382,7 +382,7 @@ void texai_unit_move_seen(struct unit *punit)
     info->id = punit->id;
     info->tindex = tile_index(unit_tile(punit));
 
-    texai_send_msg(TEXAI_MSG_UNIT_MOVED, NULL, info);
+    texai_send_msg(TEXAI_MSG_UNIT_MOVED, nullptr, info);
   }
 }
 
@@ -395,7 +395,7 @@ void texai_unit_moved_recv(void *data)
   struct unit *punit = idex_lookup_unit(&texai_world, info->id);
   struct tile *ptile = index_to_tile(&(texai_world.map), info->tindex);
 
-  if (punit != NULL) {
+  if (punit != nullptr) {
     unit_list_remove(punit->tile->units, punit);
     unit_list_prepend(ptile->units, punit);
 
-- 
2.53.0

