From a1b368d5e3205272dba7696aaf6dccb2f3aab650 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 10 Oct 2026 07:42:53 +0300
Subject: [PATCH 78/78] Move special functions to savegame2.c

...and make them static.

See RM #2112

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 server/savegame/savecompat.c | 45 ---------------------------------
 server/savegame/savecompat.h |  6 +----
 server/savegame/savegame2.c  | 48 ++++++++++++++++++++++++++++++++++++
 3 files changed, 49 insertions(+), 50 deletions(-)

diff --git a/server/savegame/savecompat.c b/server/savegame/savecompat.c
index 0b45995a4e..1c0064f4c3 100644
--- a/server/savegame/savecompat.c
+++ b/server/savegame/savecompat.c
@@ -34,12 +34,6 @@
 
 bool sg_success;
 
-static char *special_names[] =
-  {
-    "Irrigation", "Mine", "Pollution", "Hut", "Farmland",
-    "Fallout", nullptr
-  };
-
 /*
   For each savefile format after 2.3.0, compatibility functions are defined
   which translate secfile structures from previous version to that version;
@@ -288,45 +282,6 @@ int char2num(char ch)
   return pch - num_chars;
 }
 
-/************************************************************************//**
-  Return the special with the given name, or S_LAST.
-****************************************************************************/
-enum tile_special_type special_by_rule_name(const char *name)
-{
-  int i;
-
-  for (i = 0; special_names[i] != nullptr; i++) {
-    if (!strcmp(name, special_names[i])) {
-      return i;
-    }
-  }
-
-  return S_LAST;
-}
-
-/************************************************************************//**
-  Return the untranslated name of the given special.
-****************************************************************************/
-const char *special_rule_name(enum tile_special_type type)
-{
-  fc_assert(type >= 0 && type < S_LAST);
-
-  return special_names[type];
-}
-
-/************************************************************************//**
-  Get extra of the given special
-****************************************************************************/
-struct extra_type *special_extra_get(int spe)
-{
-  struct extra_type_list *elist = extra_type_list_by_cause(EC_SPECIAL);
-
-  if (spe < extra_type_list_size(elist)) {
-    return extra_type_list_get(elist, spe);
-  }
-
-  return nullptr;
-}
 
 /* =======================================================================
  * Compatibility functions for loading a game.
diff --git a/server/savegame/savecompat.h b/server/savegame/savecompat.h
index 9749ec61e2..f7b4acd682 100644
--- a/server/savegame/savecompat.h
+++ b/server/savegame/savecompat.h
@@ -34,7 +34,7 @@ enum tile_special_type {
   S_FARMLAND,
   S_FALLOUT,
 
-  /* internal values not saved */
+  /* Internal values not saved */
   S_LAST,
 
   S_OLD_ROAD,
@@ -207,10 +207,6 @@ int ascii_hex2bin(char ch, int halfbyte);
 
 int char2num(char ch);
 
-enum tile_special_type special_by_rule_name(const char *name);
-const char *special_rule_name(enum tile_special_type type);
-struct extra_type *special_extra_get(int spe);
-
 enum ai_level ai_level_convert(int old_level);
 enum barbarian_type barb_type_convert(int old_type);
 
diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c
index 626fb17846..62212e5537 100644
--- a/server/savegame/savegame2.c
+++ b/server/savegame/savegame2.c
@@ -149,6 +149,12 @@ extern bool sg_success;
 #define ACTIVITY_OLD_FALLOUT_SG2 (ACTIVITY_OLD_POLLUTION_SG2 + 1)
 #define ACTIVITY_LAST_SAVEGAME2 (ACTIVITY_OLD_FALLOUT_SG2 + 1)
 
+static char *special_names[] =
+  {
+    "Irrigation", "Mine", "Pollution", "Hut", "Farmland",
+    "Fallout", nullptr
+  };
+
 /*
  * This loops over the entire map to save data. It collects all the data of
  * a line using GET_XY_CHAR and then executes the macro SECFILE_INSERT_LINE.
@@ -857,6 +863,48 @@ static void unit_ordering_apply(void)
   } whole_map_iterate_end;
 }
 
+/************************************************************************//**
+  Return the special with the given name, or S_LAST.
+****************************************************************************/
+static enum tile_special_type special_by_rule_name(const char *name)
+{
+  int i;
+
+  for (i = 0; special_names[i] != nullptr; i++) {
+    if (!strcmp(name, special_names[i])) {
+      return i;
+    }
+  }
+
+  return S_LAST;
+}
+
+/************************************************************************//**
+  Return the untranslated name of the given special.
+****************************************************************************/
+static const char *special_rule_name(enum tile_special_type type)
+{
+  fc_assert(type >= 0 && type < S_LAST);
+
+  fc__unreachable(type >= S_LAST);
+
+  return special_names[type];
+}
+
+/************************************************************************//**
+  Get extra of the given special
+****************************************************************************/
+static struct extra_type *special_extra_get(int spe)
+{
+  struct extra_type_list *elist = extra_type_list_by_cause(EC_SPECIAL);
+
+  if (spe < extra_type_list_size(elist)) {
+    return extra_type_list_get(elist, spe);
+  }
+
+  return nullptr;
+}
+
 /************************************************************************//**
   Helper function for loading extras from a savegame.
 
-- 
2.53.0

