From bac4f4800593e2545a15e7e85845cd712c6abe36 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 15 Nov 2026 12:46:52 +0200
Subject: [PATCH 76/76] climisc.c: Replace NULL with nullptr

See RM #2489

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/climisc.c | 106 +++++++++++++++++++++++++----------------------
 1 file changed, 56 insertions(+), 50 deletions(-)

diff --git a/client/climisc.c b/client/climisc.c
index 154d03f0ce..ed6ad2dae2 100644
--- a/client/climisc.c
+++ b/client/climisc.c
@@ -82,7 +82,7 @@ void client_remove_unit(struct unit *punit)
             punit->id, nation_rule_name(nation_of_unit(punit)),
             unit_rule_name(punit), TILE_XY(unit_tile(punit)), hc);
 
-  update = (get_focus_unit_on_tile(unit_tile(punit)) != NULL);
+  update = (get_focus_unit_on_tile(unit_tile(punit)) != nullptr);
 
   /* Check transport status. */
   unit_transport_unload(punit);
@@ -95,7 +95,7 @@ void client_remove_unit(struct unit *punit)
 
   control_unit_killed(punit);
   game_remove_unit(&wld, punit);
-  punit = NULL;
+  punit = nullptr;
   if (old > 0 && get_num_units_in_focus() == 0) {
     unit_focus_advance(TRUE);
   } else if (update) {
@@ -104,7 +104,7 @@ void client_remove_unit(struct unit *punit)
   }
 
   pcity = tile_city(ptile);
-  if (NULL != pcity) {
+  if (pcity != nullptr) {
     if (can_player_see_units_in_city(client_player(), pcity)) {
       pcity->client.occupied = (0 < unit_list_size(pcity->tile->units));
       refresh_city_dialog(pcity);
@@ -117,7 +117,7 @@ void client_remove_unit(struct unit *punit)
 
   if (!client_has_player() || unit_owner(&old_unit) == client_player()) {
     pcity = game_city_by_number(hc);
-    if (NULL != pcity) {
+    if (pcity != nullptr) {
       refresh_city_dialog(pcity);
       log_debug("home city %s, %s, (%d %d)",
                 city_name_get(pcity), nation_rule_name(nation_of_city(pcity)),
@@ -159,7 +159,7 @@ void client_remove_city(struct city *pcity)
 }
 
 /**********************************************************************//**
-  Change all cities building X to building Y, if possible.  X and Y
+  Change all cities building X to building Y, if possible. X and Y
   could be improvements or units. X and Y are compound ids.
 **************************************************************************/
 void client_change_all(struct universal *from, struct universal *to)
@@ -168,7 +168,7 @@ void client_change_all(struct universal *from, struct universal *to)
     return;
   }
 
-  create_event(NULL, E_CITY_PRODUCTION_CHANGED, ftc_client,
+  create_event(nullptr, E_CITY_PRODUCTION_CHANGED, ftc_client,
                _("Changing production of every %s into %s."),
                VUT_UTYPE == from->kind
                ? utype_name_translation(from->value.utype)
@@ -353,7 +353,7 @@ void nuclear_winter_scaled(int *chance, int *rate, int max)
 **************************************************************************/
 struct sprite *client_research_sprite(void)
 {
-  if (NULL != client.conn.playing && can_client_change_view()) {
+  if (client.conn.playing != nullptr && can_client_change_view()) {
     const struct research *presearch = research_get(client_player());
     int idx = 0;
 
@@ -380,7 +380,7 @@ struct sprite *client_warming_sprite(void)
 
   if (can_client_change_view()) {
     /* Highest sprite kicks in at about 25% risk */
-    global_warming_scaled(&idx, NULL, (NUM_TILES_PROGRESS-1)*4);
+    global_warming_scaled(&idx, nullptr, (NUM_TILES_PROGRESS-1)*4);
     idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
   } else {
     idx = 0;
@@ -397,7 +397,7 @@ struct sprite *client_cooling_sprite(void)
 
   if (can_client_change_view()) {
     /* Highest sprite kicks in at about 25% risk */
-    nuclear_winter_scaled(&idx, NULL, (NUM_TILES_PROGRESS-1)*4);
+    nuclear_winter_scaled(&idx, nullptr, (NUM_TILES_PROGRESS-1)*4);
     idx = CLIP(0, idx, NUM_TILES_PROGRESS-1);
   } else {
     idx = 0;
@@ -411,15 +411,15 @@ struct sprite *client_cooling_sprite(void)
 **************************************************************************/
 struct sprite *client_government_sprite(void)
 {
-  if (NULL != client.conn.playing && can_client_change_view()
+  if (client.conn.playing != nullptr && can_client_change_view()
       && government_count() > 0) {
     struct government *gov = government_of_player(client.conn.playing);
 
     return get_government_sprite(tileset, gov);
   } else {
-    /* HACK: the UNHAPPY citizen is used for the government
+    /* HACK: The UNHAPPY citizen is used for the government
      * when we don't know any better. */
-    return get_citizen_sprite(tileset, CITIZEN_UNHAPPY, 0, NULL);
+    return get_citizen_sprite(tileset, CITIZEN_UNHAPPY, 0, nullptr);
   }
 }
 
@@ -441,20 +441,24 @@ void center_on_something(void)
   if (get_num_units_in_focus() > 0) {
     center_tile_mapcanvas(unit_tile(head_of_units_in_focus()));
   } else if (client_has_player()
-             && NULL != (pcity = player_primary_capital(client_player()))) {
+             && (pcity = player_primary_capital(client_player())) != nullptr) {
     /* Else focus on the capital. */
     center_tile_mapcanvas(pcity->tile);
-  } else if (NULL != client.conn.playing
+  } else if (client.conn.playing != nullptr
              && 0 < city_list_size(client.conn.playing->cities)) {
     /* Just focus on any city. */
     pcity = city_list_get(client.conn.playing->cities, 0);
-    fc_assert_ret(pcity != NULL);
+
+    fc_assert_ret(pcity != nullptr);
+
     center_tile_mapcanvas(pcity->tile);
-  } else if (NULL != client.conn.playing
+  } else if (client.conn.playing != nullptr
              && 0 < unit_list_size(client.conn.playing->units)) {
     /* Just focus on any unit. */
     punit = unit_list_get(client.conn.playing->units, 0);
-    fc_assert_ret(punit != NULL);
+
+    fc_assert_ret(punit != nullptr);
+
     center_tile_mapcanvas(unit_tile(punit));
   } else {
     struct tile *ctile = native_pos_to_tile(nmap, MAP_NATIVE_WIDTH / 2,
@@ -669,10 +673,11 @@ void name_and_sort_items(struct universal *targets, int num_targets,
       if (is_convert_improvement(target.value.building)) {
         cost = -1;
       } else {
-        if (pcity != NULL) {
+        if (pcity != nullptr) {
           cost = impr_build_shield_cost(pcity, target.value.building);
         } else {
-          cost = MAX(target.value.building->build_cost * game.info.shieldbox / 100, 1);
+          cost = MAX(target.value.building->build_cost * game.info.shieldbox
+                     / 100, 1);
         }
       }
     }
@@ -751,7 +756,7 @@ int collect_production_targets(struct universal *targets,
   Collect the cids of all targets (improvements and units) which are
   currently built in a city.
 
-  FIXME: this should probably take a pplayer argument.
+  FIXME: This should probably take a pplayer argument.
 **************************************************************************/
 int collect_currently_building_targets(struct universal *targets)
 {
@@ -759,7 +764,7 @@ int collect_currently_building_targets(struct universal *targets)
   int cids_used = 0;
   cid id;
 
-  if (NULL == client.conn.playing) {
+  if (client.conn.playing == nullptr) {
     return 0;
   }
 
@@ -783,13 +788,13 @@ int collect_currently_building_targets(struct universal *targets)
   Collect the cids of all targets (improvements and units) which can
   be build in a city.
 
-  FIXME: this should probably take a pplayer argument.
+  FIXME: This should probably take a pplayer argument.
 **************************************************************************/
 int collect_buildable_targets(struct universal *targets)
 {
   int cids_used = 0;
 
-  if (NULL == client.conn.playing) {
+  if (client.conn.playing == nullptr) {
     return 0;
   }
 
@@ -830,13 +835,13 @@ int collect_eventually_buildable_targets(struct universal *targets,
     bool can_build;
     bool can_eventually_build;
 
-    if (NULL != pcity) {
+    if (pcity != nullptr) {
       /* Can the city build? */
       can_build = can_city_build_improvement_now(pcity, pimprove,
                                                  RPT_CERTAIN);
       can_eventually_build = can_city_build_improvement_later(pcity,
                                                               pimprove);
-    } else if (NULL != pplayer) {
+    } else if (pplayer != nullptr) {
       /* Can our player build? */
       can_build = can_player_build_improvement_now(pplayer, pimprove,
                                                    RPT_CERTAIN);
@@ -874,11 +879,11 @@ int collect_eventually_buildable_targets(struct universal *targets,
     bool can_build;
     bool can_eventually_build;
 
-    if (NULL != pcity) {
+    if (pcity != nullptr) {
       /* Can the city build? */
       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) {
+    } else if (pplayer != nullptr) {
       /* Can our player build? */
       can_build = can_player_build_unit_now(pplayer, punittype, RPT_CERTAIN);
       can_eventually_build = can_player_build_unit_later(pplayer, punittype);
@@ -920,7 +925,7 @@ int collect_already_built_targets(struct universal *targets,
 {
   int cids_used = 0;
 
-  fc_assert_ret_val(pcity != NULL, 0);
+  fc_assert_ret_val(pcity != nullptr, 0);
 
   city_built_iterate(pcity, pimprove) {
     targets[cids_used].kind = VUT_IMPROVEMENT;
@@ -975,8 +980,8 @@ void handle_event(const char *featured_text, struct tile *ptile,
 {
   char plain_text[MAX_LEN_MSG];
   struct text_tag_list *tags;
-  int where = MW_OUTPUT;	/* where to display the message */
-  bool fallback_needed = FALSE; /* we want fallback if actual 'where' is not
+  int where = MW_OUTPUT;        /* Where to display the message */
+  bool fallback_needed = FALSE; /* We want fallback if actual 'where' is not
                                  * usable */
   bool shown = FALSE;           /* Message displayed somewhere at least */
 
@@ -1008,40 +1013,40 @@ void handle_event(const char *featured_text, struct tile *ptile,
     const char *username = client.conn.username;
     size_t userlen = strlen(username);
     const char *playername = ((client_player() && !client_is_observer())
-                              ? player_name(client_player()) : NULL);
+                              ? player_name(client_player()) : nullptr);
     size_t playerlen = playername ? strlen(playername) : 0;
     const char *p;
 
     if (playername && playername[0] == '\0') {
-      playername = NULL;
+      playername = nullptr;
     }
 
     if (username && username[0] == '\0') {
-      username = NULL;
+      username = nullptr;
     }
 
     for (p = plain_text; *p != '\0'; p++) {
-      if (NULL != username
+      if (username != nullptr
           && 0 == fc_strncasecmp(p, username, userlen)) {
         struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
                                              p - plain_text + userlen,
                                              gui_options.highlight_our_names);
 
-        fc_assert(ptag != NULL);
+        fc_assert(ptag != nullptr);
 
-        if (ptag != NULL) {
+        if (ptag != nullptr) {
           /* Appends to be sure it will be applied at last. */
           text_tag_list_append(tags, ptag);
         }
-      } else if (NULL != playername
+      } else if (playername != nullptr
                  && 0 == fc_strncasecmp(p, playername, playerlen)) {
         struct text_tag *ptag = text_tag_new(TTT_COLOR, p - plain_text,
                                              p - plain_text + playerlen,
                                              gui_options.highlight_our_names);
 
-        fc_assert(ptag != NULL);
+        fc_assert(ptag != nullptr);
 
-        if (ptag != NULL) {
+        if (ptag != nullptr) {
           /* Appends to be sure it will be applied at last. */
           text_tag_list_append(tags, ptag);
         }
@@ -1053,7 +1058,7 @@ void handle_event(const char *featured_text, struct tile *ptile,
   if (BOOL_VAL(where & MW_POPUP)) {
     /* Popups are usually not shown if player is under AI control.
      * Server operator messages are shown always. */
-    if (NULL == client.conn.playing
+    if (client.conn.playing == nullptr
         || is_human(client.conn.playing)
         || event == E_MESSAGE_WALL) {
       popup_notify_goto_dialog(_("Popup Request"), plain_text, tags, ptile);
@@ -1118,8 +1123,9 @@ void create_event(struct tile *ptile, enum event_type event,
 
 /**********************************************************************//**
   Find city nearest to given unit and optionally return squared city
-  distance Parameter sq_dist may be NULL. Returns NULL only if no city is
-  known. Favors punit owner's cities over other cities if equally distant.
+  distance Parameter sq_dist may be nullptr. Returns nullptr only if
+  no city is known. Favors punit owner's cities over other cities
+  if equally distant.
 **************************************************************************/
 struct city *get_nearest_city(const struct unit *punit, int *sq_dist)
 {
@@ -1129,7 +1135,7 @@ struct city *get_nearest_city(const struct unit *punit, int *sq_dist)
   if ((pcity_near = tile_city(unit_tile(punit)))) {
     pcity_near_dist = 0;
   } else {
-    pcity_near = NULL;
+    pcity_near = nullptr;
     pcity_near_dist = -1;
     players_iterate(pplayer) {
       city_list_iterate(pplayer->cities, pcity_current) {
@@ -1183,7 +1189,7 @@ void cityrep_buy(struct city *pcity)
                                           "%s costs %d gold", value),
                 city_production_name_translation(pcity),
                 value);
-    create_event(NULL, E_BAD_COMMAND, ftc_client,
+    create_event(nullptr, E_BAD_COMMAND, ftc_client,
                  /* TRANS: %s is a pre-pluralised sentence fragment:
                   * "%s costs %d gold" */
                  PL_("%s and you only have %d gold.",
@@ -1264,7 +1270,7 @@ bool can_units_do_connect(struct unit_list *punits,
 void client_unit_init_act_prob_cache(struct unit *punit)
 {
   /* A double init would cause a leak. */
-  fc_assert_ret(punit->client.act_prob_cache == NULL);
+  fc_assert_ret(punit->client.act_prob_cache == nullptr);
 
   punit->client.act_prob_cache = (struct act_prob*)fc_malloc(
         NUM_ACTIONS * sizeof(*punit->client.act_prob_cache));
@@ -1378,7 +1384,7 @@ void unit_focus_set_status(struct player *pplayer)
 void client_player_init(struct player *pplayer)
 {
   vision_layer_iterate(v) {
-    pplayer->client.tile_vision[v].vec = NULL;
+    pplayer->client.tile_vision[v].vec = nullptr;
     pplayer->client.tile_vision[v].bits = 0;
   } vision_layer_iterate_end;
 }
@@ -1473,7 +1479,7 @@ bool mapimg_client_createmap(const char *filename)
   struct mapdef *pmapdef;
   char mapimgfile[512];
 
-  if (NULL == filename || '\0' == filename[0]) {
+  if (filename == nullptr || '\0' == filename[0]) {
     sz_strlcpy(mapimgfile, gui_options.mapimg_filename);
   } else {
     sz_strlcpy(mapimgfile, filename);
@@ -1488,7 +1494,7 @@ bool mapimg_client_createmap(const char *filename)
     return FALSE;
   }
 
-  return mapimg_create(pmapdef, TRUE, mapimgfile, NULL);
+  return mapimg_create(pmapdef, TRUE, mapimgfile, nullptr);
 }
 
 /**********************************************************************//**
@@ -1499,9 +1505,9 @@ struct nation_set *client_current_nation_set(void)
   struct option *poption = optset_option_by_name(server_optset, "nationset");
   const char *setting_str;
 
-  if (poption == NULL
+  if (poption == nullptr
       || option_type(poption) != OT_STRING
-      || (setting_str = option_str_get(poption)) == NULL) {
+      || (setting_str = option_str_get(poption)) == nullptr) {
     setting_str = "";
   }
 
-- 
2.53.0

