From b43db0bcd4fc0a9d0dd90701b34a7867a8ee2e91 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Thu, 17 Sep 2026 00:40:34 +0300
Subject: [PATCH 73/73] agents/: Replace NULL with nullptr

See RM #2255

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 client/agents/agents.c   | 14 ++++++++------
 client/agents/cma_core.c | 22 +++++++++++-----------
 client/agents/cma_core.h |  2 +-
 client/agents/cma_fec.c  | 18 +++++++++---------
 client/agents/sha.c      | 10 ++++++----
 5 files changed, 35 insertions(+), 31 deletions(-)

diff --git a/client/agents/agents.c b/client/agents/agents.c
index cc151953dc..53900090a3 100644
--- a/client/agents/agents.c
+++ b/client/agents/agents.c
@@ -45,7 +45,7 @@
 #define log_meta_callback(...)          log_debug(__VA_ARGS__)
 #define log_debug_freeze(...)           /* log_test(__VA_ARGS__) */
 
-#define MAX_AGENTS			10
+#define MAX_AGENTS                      10
 
 struct my_agent;
 
@@ -191,14 +191,14 @@ static void enqueue_call(enum oct type,
 
 /************************************************************************//**
   Return an outstanding call. The call is removed from the agents.calls
-  list. Returns NULL if there no more outstanding calls.
+  list. Returns nullptr if there no more outstanding calls.
 ****************************************************************************/
 static struct call *remove_and_return_a_call(void)
 {
   struct call *result;
 
   if (call_list_size(agents.calls) == 0) {
-    return NULL;
+    return nullptr;
   }
 
   result = call_list_front(agents.calls);
@@ -305,7 +305,7 @@ static struct my_agent *agent_by_name(const char *agent_name)
       return &agents.entries[i];
   }
 
-  return NULL;
+  return nullptr;
 }
 
 /************************************************************************//**
@@ -780,7 +780,8 @@ void cause_a_unit_changed_for_agent(const char *name_of_calling_agent,
 {
   struct my_agent *agent = agent_by_name(name_of_calling_agent);
 
-  fc_assert_ret(agent->agent.unit_callbacks[CB_CHANGE] != NULL);
+  fc_assert_ret(agent->agent.unit_callbacks[CB_CHANGE] != nullptr);
+
   enqueue_call(OCT_UNIT, CB_CHANGE, agent, punit->id);
   call_handle_methods();
 }
@@ -793,7 +794,8 @@ void cause_a_city_changed_for_agent(const char *name_of_calling_agent,
 {
   struct my_agent *agent = agent_by_name(name_of_calling_agent);
 
-  fc_assert_ret(agent->agent.city_callbacks[CB_CHANGE] != NULL);
+  fc_assert_ret(agent->agent.city_callbacks[CB_CHANGE] != nullptr);
+
   enqueue_call(OCT_CITY, CB_CHANGE, agent, pcity->id);
   call_handle_methods();
 }
diff --git a/client/agents/cma_core.c b/client/agents/cma_core.c
index 8bf037901c..60281cabaa 100644
--- a/client/agents/cma_core.c
+++ b/client/agents/cma_core.c
@@ -137,7 +137,7 @@ static bool fc_results_are_equal(const struct cm_result *result1,
 
 /************************************************************************//**
   Returns TRUE if the city is valid for CMA. Fills parameter if TRUE
-  is returned. Parameter can be NULL.
+  is returned. Parameter can be nullptr.
 ****************************************************************************/
 static struct city *check_city(int city_id, struct cm_parameter *parameter)
 {
@@ -150,13 +150,13 @@ static struct city *check_city(int city_id, struct cm_parameter *parameter)
 
   if (!pcity
       || !cma_get_parameter(ATTR_CITY_CMA_PARAMETER, city_id, parameter)) {
-    return NULL;
+    return nullptr;
   }
 
   if (city_owner(pcity) != client.conn.playing) {
     cma_release_city(pcity);
 
-    return NULL;
+    return nullptr;
   }
 
   return pcity;
@@ -244,7 +244,7 @@ static bool apply_result_on_server(struct city *pcity,
    * DEFAULT_SPECIALIST! */
   city_tile_iterate_skip_free_worked(&(wld.map), city_radius_sq, pcenter, ptile, idx,
                                      x, y) {
-    if (NULL == tile_worked(ptile)
+    if (tile_worked(ptile) == nullptr
         && result->worker_positions[idx]) {
       log_apply_result("Putting worker at {%d,%d}.", x, y);
       fc_assert_action(city_can_work_tile(pcity, ptile), break);
@@ -298,7 +298,7 @@ static bool apply_result_on_server(struct city *pcity,
     int city_id = pcity->id;
 
     wait_for_requests("CMA", first_request_id, last_request_id);
-    if (pcity != check_city(city_id, NULL)) {
+    if (pcity != check_city(city_id, nullptr)) {
       log_verbose("apply_result_on_server(city %d) !check_city()!", city_id);
       return FALSE;
     }
@@ -357,7 +357,7 @@ static void report_stats(void)
 ****************************************************************************/
 static void release_city(int city_id)
 {
-  attr_city_set(ATTR_CITY_CMA_PARAMETER, city_id, 0, NULL);
+  attr_city_set(ATTR_CITY_CMA_PARAMETER, city_id, 0, nullptr);
 }
 
 /****************************************************************************
@@ -407,7 +407,7 @@ static void handle_city(struct city *pcity)
     } else {
       if (!apply_result_on_server(pcity, result)) {
         log_handle_city2("  doesn't cleanly apply");
-        if (pcity == check_city(city_id, NULL) && i == 0) {
+        if (pcity == check_city(city_id, nullptr) && i == 0) {
           create_event(city_tile(pcity), E_CITY_CMA_RELEASE, ftc_client,
                        _("The citizen governor has gotten confused dealing "
                          "with %s. You may want to have a look."),
@@ -425,7 +425,7 @@ static void handle_city(struct city *pcity)
   cm_result_destroy(result);
 
   if (!handled) {
-    fc_assert_ret(pcity == check_city(city_id, NULL));
+    fc_assert_ret(pcity == check_city(city_id, nullptr));
     log_handle_city2("  not handled");
 
     create_event(city_tile(pcity), E_CITY_CMA_RELEASE, ftc_client,
@@ -492,7 +492,7 @@ void cma_init(void)
    * called multiple times per client invocation so that lead to memory
    * leaks. */
   stats.wall_timer = timer_renew(timer, TIMER_USER, TIMER_ACTIVE,
-                                 timer != NULL ? NULL : "agent: stats");
+                                 timer != nullptr ? nullptr : "agent: stats");
 
   memset(&self, 0, sizeof(self));
   strcpy(self.name, "CMA");
@@ -509,7 +509,7 @@ void cma_init(void)
 ****************************************************************************/
 bool cma_apply_result(struct city *pcity, const struct cm_result *result)
 {
-  fc_assert(!cma_is_city_under_agent(pcity, NULL));
+  fc_assert(!cma_is_city_under_agent(pcity, nullptr));
 
   if (result->found_a_valid) {
     return apply_result_on_server(pcity, result);
@@ -558,7 +558,7 @@ bool cma_is_city_under_agent(const struct city *pcity,
     return FALSE;
   }
 
-  if (parameter != NULL) {
+  if (parameter != nullptr) {
     memcpy(parameter, &my_parameter, sizeof(struct cm_parameter));
   }
 
diff --git a/client/agents/cma_core.h b/client/agents/cma_core.h
index 9eae47a790..13e4111bd1 100644
--- a/client/agents/cma_core.h
+++ b/client/agents/cma_core.h
@@ -53,7 +53,7 @@ void cma_release_city(struct city *pcity);
 
 /*
  * Test if the citizen in the given city are managed by the agent. The
- * given parameter is filled if pointer is non-NULL. The parameter is
+ * given parameter is filled if pointer is non-nullptr. The parameter is
  * only valid if cma_is_city_under_agent returns true.
  */
 bool cma_is_city_under_agent(const struct city *pcity,
diff --git a/client/agents/cma_fec.c b/client/agents/cma_fec.c
index f9f8a4d913..89f3acd0c6 100644
--- a/client/agents/cma_fec.c
+++ b/client/agents/cma_fec.c
@@ -42,9 +42,9 @@
 #include "cma_fec.h"
 
 
-#define RESULT_COLUMNS		10
-#define BUFFER_SIZE		100
-#define MAX_LEN_PRESET_NAME	80
+#define RESULT_COLUMNS          10
+#define BUFFER_SIZE             100
+#define MAX_LEN_PRESET_NAME     80
 
 struct cma_preset {
   char *descr;
@@ -59,7 +59,7 @@ struct cma_preset {
     TYPED_LIST_ITERATE(struct cma_preset, presetlist, ppreset)
 #define preset_list_iterate_end  LIST_ITERATE_END
 
-static struct preset_list *preset_list = NULL;
+static struct preset_list *preset_list = nullptr;
 
 /**********************************************************************//**
   Is called if the game removes a city. It will clear the
@@ -67,7 +67,7 @@ static struct preset_list *preset_list = NULL;
 **************************************************************************/
 static void city_remove(int city_id)
 {
-  attr_city_set(ATTR_CITY_CMAFE_PARAMETER, city_id, 0, NULL);
+  attr_city_set(ATTR_CITY_CMAFE_PARAMETER, city_id, 0, nullptr);
 }
 
 /**********************************************************************//**
@@ -77,7 +77,7 @@ void cmafec_init(void)
 {
   struct agent self;
 
-  if (preset_list == NULL) {
+  if (preset_list == nullptr) {
     preset_list = preset_list_new();
   }
 
@@ -137,7 +137,7 @@ void cmafec_preset_add(const char *descr_name, struct cm_parameter *pparam)
 {
   struct cma_preset *ppreset = fc_malloc(sizeof(struct cma_preset));
 
-  if (preset_list == NULL) {
+  if (preset_list == nullptr) {
     preset_list = preset_list_new();
   }
 
@@ -170,7 +170,7 @@ char *cmafec_preset_get_descr(int idx)
 {
   struct cma_preset *ppreset;
 
-  fc_assert_ret_val(idx >= 0 && idx < cmafec_preset_num(), NULL);
+  fc_assert_ret_val(idx >= 0 && idx < cmafec_preset_num(), nullptr);
 
   ppreset = preset_list_get(preset_list, idx);
   return ppreset->descr;
@@ -183,7 +183,7 @@ const struct cm_parameter *cmafec_preset_get_parameter(int idx)
 {
   struct cma_preset *ppreset;
 
-  fc_assert_ret_val(idx >= 0 && idx < cmafec_preset_num(), NULL);
+  fc_assert_ret_val(idx >= 0 && idx < cmafec_preset_num(), nullptr);
 
   ppreset = preset_list_get(preset_list, idx);
   return &ppreset->parameter;
diff --git a/client/agents/sha.c b/client/agents/sha.c
index 2754ae4f11..70a9eb6f69 100644
--- a/client/agents/sha.c
+++ b/client/agents/sha.c
@@ -38,7 +38,7 @@
   already got the new ones.
 **************************************************************************/
 
-static struct tile *previous_tiles = NULL;
+static struct tile *previous_tiles = nullptr;
 static struct unit_list *previous_units;
 
 /**********************************************************************//**
@@ -64,7 +64,8 @@ static void sha_unit_change(int id)
 
   log_debug("sha got unit: %d", id);
 
-  fc_assert_ret(NULL != pold_unit);
+  fc_assert_ret(pold_unit != nullptr);
+
   *pold_unit = *punit;
 }
 
@@ -74,7 +75,7 @@ static void sha_unit_change(int id)
 static void sha_unit_new(int id)
 {
   struct unit *punit = game_unit_by_number(id);
-  struct unit *pold_unit = unit_virtual_create(unit_owner(punit), NULL,
+  struct unit *pold_unit = unit_virtual_create(unit_owner(punit), nullptr,
                                                unit_type_get(punit), 0);
 
   log_debug("sha got unit: %d", id);
@@ -92,7 +93,8 @@ static void sha_unit_remove(int id)
 
   log_debug("sha got unit: %d", id);
 
-  fc_assert_ret(NULL != pold_unit);
+  fc_assert_ret(pold_unit != nullptr);
+
   unit_list_remove(previous_units, pold_unit);
   /* List pointers were struct copied, cannot unit_virtual_destroy() */
   memset(pold_unit, 0, sizeof(*pold_unit)); /* Ensure no pointers remain */
-- 
2.53.0

