From 82f2661de4cf135cfc5e3713f80c028e12a68cde Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 3 May 2025 11:13:08 +0300
Subject: [PATCH 45/45] api_game_find.c: Replace NULL with nullptr

See RM #1361

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/scriptcore/api_game_find.c | 100 +++++++++++++++---------------
 1 file changed, 50 insertions(+), 50 deletions(-)

diff --git a/common/scriptcore/api_game_find.c b/common/scriptcore/api_game_find.c
index d24295c54d..250c05952a 100644
--- a/common/scriptcore/api_game_find.c
+++ b/common/scriptcore/api_game_find.c
@@ -31,7 +31,7 @@
 **************************************************************************/
 Player *api_find_player_by_name(lua_State *L, const char *name)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return player_by_name(name);
 }
@@ -41,7 +41,7 @@ Player *api_find_player_by_name(lua_State *L, const char *name)
 **************************************************************************/
 Player *api_find_player(lua_State *L, int player_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return player_by_number(player_id);
 }
@@ -51,7 +51,7 @@ Player *api_find_player(lua_State *L, int player_id)
 **************************************************************************/
 City *api_find_city(lua_State *L, Player *pplayer, int city_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   if (pplayer) {
     return player_city_by_number(pplayer, city_id);
@@ -65,7 +65,7 @@ City *api_find_city(lua_State *L, Player *pplayer, int city_id)
 **************************************************************************/
 Unit *api_find_unit(lua_State *L, Player *pplayer, int unit_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   if (pplayer) {
     return player_unit_by_number(pplayer, unit_id);
@@ -80,14 +80,14 @@ Unit *api_find_unit(lua_State *L, Player *pplayer, int unit_id)
 Unit *api_find_transport_unit(lua_State *L, Player *pplayer,
                               Unit_Type *ptype, Tile *ptile)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, ptype, 3, Unit_Type, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, ptile, 4, Tile, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, pplayer, 2, Player, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, ptype, 3, Unit_Type, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, ptile, 4, Tile, nullptr);
 
   {
     struct unit *ptransport;
-    struct unit *pvirt = unit_virtual_create(pplayer, NULL, ptype, 0);
+    struct unit *pvirt = unit_virtual_create(pplayer, nullptr, ptype, 0);
     unit_tile_set(pvirt, ptile);
     pvirt->homecity = 0;
     ptransport = transporter_for_unit(pvirt);
@@ -105,15 +105,15 @@ Unit_Type *api_find_role_unit_type(lua_State *L, const char *role_name,
 {
   int role_or_flag;
 
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, role_name, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, role_name, 2, string, nullptr);
 
   role_or_flag = unit_role_id_by_name(role_name, fc_strcasecmp);
 
   if (!unit_role_id_is_valid(role_or_flag)) {
     role_or_flag = unit_type_flag_id_by_name(role_name, fc_strcasecmp);
     if (!unit_type_flag_id_is_valid(role_or_flag)) {
-      return NULL;
+      return nullptr;
     }
   }
 
@@ -122,7 +122,7 @@ Unit_Type *api_find_role_unit_type(lua_State *L, const char *role_name,
   } else if (num_role_units(role_or_flag) > 0) {
     return get_role_unit(role_or_flag, 0);
   } else {
-    return NULL;
+    return nullptr;
   }
 }
 
@@ -131,7 +131,7 @@ Unit_Type *api_find_role_unit_type(lua_State *L, const char *role_name,
 **************************************************************************/
 Tile *api_find_tile(lua_State *L, int nat_x, int nat_y)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return native_pos_to_tile(&(wld.map), nat_x, nat_y);
 }
@@ -141,7 +141,7 @@ Tile *api_find_tile(lua_State *L, int nat_x, int nat_y)
 **************************************************************************/
 Tile *api_find_tile_by_index(lua_State *L, int tindex)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return index_to_tile(&(wld.map), tindex);
 }
@@ -151,7 +151,7 @@ Tile *api_find_tile_by_index(lua_State *L, int tindex)
 **************************************************************************/
 Government *api_find_government(lua_State *L, int government_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return government_by_number(government_id);
 }
@@ -162,8 +162,8 @@ Government *api_find_government(lua_State *L, int government_id)
 Government *api_find_government_by_name(lua_State *L,
                                         const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return government_by_rule_name(name_orig);
 }
@@ -173,7 +173,7 @@ Government *api_find_government_by_name(lua_State *L,
 **************************************************************************/
 Nation_Type *api_find_nation_type(lua_State *L, int nation_type_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return nation_by_number(nation_type_id);
 }
@@ -184,8 +184,8 @@ Nation_Type *api_find_nation_type(lua_State *L, int nation_type_id)
 Nation_Type *api_find_nation_type_by_name(lua_State *L,
                                           const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return nation_by_rule_name(name_orig);
 }
@@ -195,7 +195,7 @@ Nation_Type *api_find_nation_type_by_name(lua_State *L,
 **************************************************************************/
 Action *api_find_action(lua_State *L, action_id act_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return action_by_number(act_id);
 }
@@ -206,8 +206,8 @@ Action *api_find_action(lua_State *L, action_id act_id)
 Action *api_find_action_by_name(lua_State *L, const char *name_orig)
 {
 
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return action_by_rule_name(name_orig);
 }
@@ -217,7 +217,7 @@ Action *api_find_action_by_name(lua_State *L, const char *name_orig)
 **************************************************************************/
 Building_Type *api_find_building_type(lua_State *L, int building_type_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return improvement_by_number(building_type_id);
 }
@@ -228,8 +228,8 @@ Building_Type *api_find_building_type(lua_State *L, int building_type_id)
 Building_Type *api_find_building_type_by_name(lua_State *L,
                                               const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return improvement_by_rule_name(name_orig);
 }
@@ -239,7 +239,7 @@ Building_Type *api_find_building_type_by_name(lua_State *L,
 **************************************************************************/
 Unit_Type *api_find_unit_type(lua_State *L, int unit_type_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return utype_by_number(unit_type_id);
 }
@@ -249,8 +249,8 @@ Unit_Type *api_find_unit_type(lua_State *L, int unit_type_id)
 **************************************************************************/
 Unit_Type *api_find_unit_type_by_name(lua_State *L, const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return unit_type_by_rule_name(name_orig);
 }
@@ -260,7 +260,7 @@ Unit_Type *api_find_unit_type_by_name(lua_State *L, const char *name_orig)
 **************************************************************************/
 Tech_Type *api_find_tech_type(lua_State *L, int tech_type_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return advance_by_number(tech_type_id);
 }
@@ -270,8 +270,8 @@ Tech_Type *api_find_tech_type(lua_State *L, int tech_type_id)
 **************************************************************************/
 Tech_Type *api_find_tech_type_by_name(lua_State *L, const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return advance_by_rule_name(name_orig);
 }
@@ -281,7 +281,7 @@ Tech_Type *api_find_tech_type_by_name(lua_State *L, const char *name_orig)
 **************************************************************************/
 Terrain *api_find_terrain(lua_State *L, int terrain_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return terrain_by_number(terrain_id);
 }
@@ -291,8 +291,8 @@ Terrain *api_find_terrain(lua_State *L, int terrain_id)
 **************************************************************************/
 Terrain *api_find_terrain_by_name(lua_State *L, const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return terrain_by_rule_name(name_orig);
 }
@@ -302,7 +302,7 @@ Terrain *api_find_terrain_by_name(lua_State *L, const char *name_orig)
 **************************************************************************/
 Achievement *api_find_achievement(lua_State *L, int achievement_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return achievement_by_number(achievement_id);
 }
@@ -312,8 +312,8 @@ Achievement *api_find_achievement(lua_State *L, int achievement_id)
 **************************************************************************/
 Achievement *api_find_achievement_by_name(lua_State *L, const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return achievement_by_rule_name(name_orig);
 }
@@ -323,7 +323,7 @@ Achievement *api_find_achievement_by_name(lua_State *L, const char *name_orig)
 **************************************************************************/
 Disaster *api_find_disaster(lua_State *L, int disaster_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return disaster_by_number(disaster_id);
 }
@@ -333,8 +333,8 @@ Disaster *api_find_disaster(lua_State *L, int disaster_id)
 **************************************************************************/
 Disaster *api_find_disaster_by_name(lua_State *L, const char *name_orig)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name_orig, 2, string, nullptr);
 
   return disaster_by_rule_name(name_orig);
 }
@@ -344,7 +344,7 @@ Disaster *api_find_disaster_by_name(lua_State *L, const char *name_orig)
 **************************************************************************/
 const Direction *api_find_direction(lua_State *L, int id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return luascript_dir((enum direction8) id);
 }
@@ -354,7 +354,7 @@ const Direction *api_find_direction(lua_State *L, int id)
 **************************************************************************/
 Action *api_find_action_type_by_id(lua_State *L, int id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return action_by_number(id);
 }
@@ -364,8 +364,8 @@ Action *api_find_action_type_by_id(lua_State *L, int id)
 **************************************************************************/
 Action *api_find_action_type_by_name(lua_State *L, const char *name)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name, 2, string, nullptr);
 
   return action_by_rule_name(name);
 }
@@ -375,7 +375,7 @@ Action *api_find_action_type_by_name(lua_State *L, const char *name)
 **************************************************************************/
 Counter *api_find_counter(lua_State *L, int counter_id)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return counter_by_id(counter_id);
 }
@@ -385,8 +385,8 @@ Counter *api_find_counter(lua_State *L, int counter_id)
 **************************************************************************/
 Counter *api_find_counter_by_name(lua_State *L, const char *name)
 {
-  LUASCRIPT_CHECK_STATE(L, NULL);
-  LUASCRIPT_CHECK_ARG_NIL(L, name, 2, string, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
+  LUASCRIPT_CHECK_ARG_NIL(L, name, 2, string, nullptr);
 
   return counter_by_rule_name(name);
 }
@@ -398,7 +398,7 @@ Nonexistent *api_find_nonexistent(lua_State *L)
 {
   static char *p = "";
 
-  LUASCRIPT_CHECK_STATE(L, NULL);
+  LUASCRIPT_CHECK_STATE(L, nullptr);
 
   return p;
 }
-- 
2.47.2

