From 319bc40e9fe1189910f332fab8c67e2a0957a2b1 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sun, 15 Nov 2026 21:36:53 +0200
Subject: [PATCH 78/78] Inline unit_is_alive()

See RM #2490

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 common/game.h | 10 ++++++++++
 common/unit.c | 14 --------------
 common/unit.h |  2 --
 3 files changed, 10 insertions(+), 16 deletions(-)

diff --git a/common/game.h b/common/game.h
index feba1a9ca1..2c513e9da4 100644
--- a/common/game.h
+++ b/common/game.h
@@ -340,6 +340,16 @@ struct unit *game_unit_by_number(int id);
 
 void game_remove_unit(struct world *gworld, struct unit *punit);
 void game_remove_city(struct world *gworld, struct city *pcity);
+
+/**********************************************************************//**
+  Check if unit with given id is still alive. Use this before using
+  old unit pointers when unit might have died.
+**************************************************************************/
+inline bool unit_is_alive(int id)
+{
+  return game_unit_by_number(id) != nullptr;
+}
+
 void initialize_globals(void);
 
 bool is_player_phase(const struct player *pplayer, int phase);
diff --git a/common/unit.c b/common/unit.c
index 7629e75712..233fdd01f6 100644
--- a/common/unit.c
+++ b/common/unit.c
@@ -2300,20 +2300,6 @@ bool unit_type_is_losing_hp(const struct player *pplayer,
        utype_class(punittype)->hp_loss_pct / 100);
 }
 
-/**********************************************************************//**
-  Check if unit with given id is still alive. Use this before using
-  old unit pointers when unit might have died.
-**************************************************************************/
-bool unit_is_alive(int id)
-{
-  /* Check if unit exist in game */
-  if (game_unit_by_number(id)) {
-    return TRUE;
-  }
-
-  return FALSE;
-}
-
 /**********************************************************************//**
   Return TRUE if this is a valid unit pointer but does not correspond to
   any unit that exists in the game.
diff --git a/common/unit.h b/common/unit.h
index 40b09f523a..86dbe49d33 100644
--- a/common/unit.h
+++ b/common/unit.h
@@ -543,8 +543,6 @@ bool is_losing_hp(const struct unit *punit);
 bool unit_type_is_losing_hp(const struct player *pplayer,
                             const struct unit_type *punittype);
 
-bool unit_is_alive(int id);
-
 void *unit_ai_data(const struct unit *punit, const struct ai_type *ai);
 void unit_set_ai_data(struct unit *punit, const struct ai_type *ai,
                       void *data);
-- 
2.53.0

