From 44ed48e260e45c59f6cf82b40f960dcac2ea3285 Mon Sep 17 00:00:00 2001
From: Marko Lindqvist <cazfi74@gmail.com>
Date: Sat, 9 Dec 2023 01:46:05 +0200
Subject: [PATCH 37/37] Move ruleset loading files to server/ruleset.

See RM #39

Signed-off-by: Marko Lindqvist <cazfi74@gmail.com>
---
 configure.ac                             |  7 ++++---
 meson.build                              | 10 +++++-----
 server/Makefile.am                       | 10 +++-------
 server/connecthand.c                     |  2 +-
 server/ruleset/Makefile.am               | 21 +++++++++++++++++++++
 server/{ => ruleset}/rscompat.c          |  2 +-
 server/{ => ruleset}/rscompat.h          |  2 +-
 server/{ => ruleset}/rssanity.c          |  2 +-
 server/{ => ruleset}/rssanity.h          |  0
 server/{ruleset.c => ruleset/ruleload.c} |  2 +-
 server/{ruleset.h => ruleset/ruleload.h} |  0
 server/savegame/Makefile.am              |  1 +
 server/savegame/savegame2.c              |  2 +-
 server/savegame/savegame3.c              |  2 +-
 server/srv_main.c                        |  2 +-
 server/stdinhand.c                       |  2 +-
 tools/Makefile.am                        |  1 +
 tools/manual/Makefile.am                 |  1 +
 tools/manual/fc_manual.c                 |  2 +-
 tools/ruledit/Makefile.am                |  1 +
 tools/ruledit/ruledit_qt.cpp             |  2 +-
 tools/ruleup.c                           |  2 +-
 tools/ruleutil/Makefile.am               |  1 +
 tools/ruleutil/rulesave.c                |  2 +-
 24 files changed, 51 insertions(+), 28 deletions(-)
 create mode 100644 server/ruleset/Makefile.am
 rename server/{ => ruleset}/rscompat.c (99%)
 rename server/{ => ruleset}/rscompat.h (99%)
 rename server/{ => ruleset}/rssanity.c (99%)
 rename server/{ => ruleset}/rssanity.h (100%)
 rename server/{ruleset.c => ruleset/ruleload.c} (99%)
 rename server/{ruleset.h => ruleset/ruleload.h} (100%)

diff --git a/configure.ac b/configure.ac
index cc6d21b8fa..3998628ca0 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1966,11 +1966,12 @@ AC_CONFIG_FILES([Makefile
           client/gui-qt/Makefile
           client/gui-stub/Makefile
           client/luascript/Makefile
-	  server/Makefile
+          server/Makefile
           server/advisors/Makefile
-	  server/generator/Makefile
+          server/generator/Makefile
+          server/ruleset/Makefile
           server/savegame/Makefile
-	  server/scripting/Makefile
+          server/scripting/Makefile
           tools/Makefile
           tools/fcmp/Makefile
           tools/manual/Makefile
diff --git a/meson.build b/meson.build
index ba6c887fbd..caeb42198f 100644
--- a/meson.build
+++ b/meson.build
@@ -1075,8 +1075,8 @@ common_inc = include_directories(cross_inc_path,
   'common/aicore')
 
 server_inc = [common_inc, include_directories('server', 'server/advisors',
-              'server/scripting', 'server/generator', 'server/savegame',
-              'ai', 'ai/classic')]
+              'server/scripting', 'server/generator', 'server/ruleset',
+              'server/savegame', 'ai', 'ai/classic')]
 
 client_inc = [common_inc, include_directories('client', 'client/include',
               'client/luascript', 'client/agents')]
@@ -1449,6 +1449,9 @@ server_lib = static_library('fc_server',
   'server/generator/mapgen_utils.c',
   'server/generator/startpos.c',
   'server/generator/temperature_map.c',
+  'server/ruleset/rscompat.c',
+  'server/ruleset/rssanity.c',
+  'server/ruleset/ruleload.c',
   'server/savegame/savecompat.c',
   'server/savegame/savegame2.c',
   'server/savegame/savegame3.c',
@@ -1488,9 +1491,6 @@ server_lib = static_library('fc_server',
   'server/notify.c',
   'server/plrhand.c',
   'server/report.c',
-  'server/rscompat.c',
-  'server/rssanity.c',
-  'server/ruleset.c',
   'server/sanitycheck.c',
   'server/score.c',
   'server/sernet.c',
diff --git a/server/Makefile.am b/server/Makefile.am
index 94fff72819..6b958c92b7 100644
--- a/server/Makefile.am
+++ b/server/Makefile.am
@@ -1,6 +1,6 @@
 ## Process this file with automake to produce Makefile.in
 
-SUBDIRS = advisors generator savegame scripting
+SUBDIRS = advisors generator savegame scripting ruleset
 
 bin_PROGRAMS = freeciv-server
 
@@ -15,6 +15,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/utility \
 	-I$(srcdir)/advisors \
 	-I$(srcdir)/generator \
+	-I$(srcdir)/ruleset \
 	-I$(srcdir)/savegame \
 	-I$(srcdir)/scripting \
 	-I$(top_srcdir)/dependencies/tinycthread \
@@ -81,12 +82,6 @@ libfreeciv_srv_la_SOURCES = \
 		plrhand.h	\
 		report.c	\
 		report.h	\
-		rscompat.c	\
-		rscompat.h	\
-		rssanity.c	\
-		rssanity.h	\
-		ruleset.c	\
-		ruleset.h	\
 		sanitycheck.c	\
 		sanitycheck.h	\
 		score.c		\
@@ -146,6 +141,7 @@ srvlibs = \
  $(top_builddir)/ai/libaicommon.la \
  $(top_builddir)/server/advisors/libadvisors.la \
  $(top_builddir)/server/generator/libgenerator.la \
+ $(top_builddir)/server/ruleset/libruleload.la \
  $(top_builddir)/server/savegame/libsavegame.la \
  $(top_builddir)/server/scripting/libscripting_fcdb.la \
  $(top_builddir)/server/scripting/libscripting_server.la
diff --git a/server/connecthand.c b/server/connecthand.c
index f4f3dfe7b3..83735b7947 100644
--- a/server/connecthand.c
+++ b/server/connecthand.c
@@ -44,7 +44,7 @@
 #include "notify.h"
 #include "plrhand.h"
 #include "report.h"
-#include "ruleset.h"
+#include "ruleload.h"
 #include "sernet.h"
 #include "settings.h"
 #include "srv_main.h"
diff --git a/server/ruleset/Makefile.am b/server/ruleset/Makefile.am
new file mode 100644
index 0000000000..5ef855db21
--- /dev/null
+++ b/server/ruleset/Makefile.am
@@ -0,0 +1,21 @@
+## Process this file with automake to produce Makefile.in
+noinst_LTLIBRARIES = libruleload.la
+
+AM_CPPFLAGS = \
+	-I$(top_srcdir)/utility \
+	-I$(top_srcdir)/common \
+	-I$(top_srcdir)/common/aicore \
+	-I$(top_srcdir)/common/networking \
+	-I$(top_srcdir)/common/scriptcore \
+	-I$(top_srcdir)/server \
+	-I$(top_srcdir)/server/advisors \
+	-I$(top_srcdir)/server/scripting \
+	-I$(top_srcdir)/gen_headers/enums
+
+libruleload_la_SOURCES = \
+	rscompat.c	\
+	rscompat.h	\
+	rssanity.c	\
+	rssanity.h	\
+	ruleload.c	\
+	ruleload.h
diff --git a/server/rscompat.c b/server/ruleset/rscompat.c
similarity index 99%
rename from server/rscompat.c
rename to server/ruleset/rscompat.c
index 73bec63a93..7bc7c9cbec 100644
--- a/server/rscompat.c
+++ b/server/ruleset/rscompat.c
@@ -36,7 +36,7 @@
 
 /* server */
 #include "rssanity.h"
-#include "ruleset.h"
+#include "ruleload.h"
 #include "settings.h"
 
 #include "rscompat.h"
diff --git a/server/rscompat.h b/server/ruleset/rscompat.h
similarity index 99%
rename from server/rscompat.h
rename to server/ruleset/rscompat.h
index e459a0a9bd..1c72e1cdbb 100644
--- a/server/rscompat.h
+++ b/server/ruleset/rscompat.h
@@ -21,7 +21,7 @@ extern "C" {
 #include "support.h"
 
 /* server */
-#include "ruleset.h"
+#include "ruleload.h"
 #include "settings.h"
 
 #define RULESET_COMPAT_CAP "+Freeciv-ruleset-3.2-Devel-2022.Feb.02"
diff --git a/server/rssanity.c b/server/ruleset/rssanity.c
similarity index 99%
rename from server/rssanity.c
rename to server/ruleset/rssanity.c
index e86e2e7c81..94069d6646 100644
--- a/server/rssanity.c
+++ b/server/ruleset/rssanity.c
@@ -33,7 +33,7 @@
 #include "tech.h"
 
 /* server */
-#include "ruleset.h"
+#include "ruleload.h"
 #include "settings.h"
 
 #include "rssanity.h"
diff --git a/server/rssanity.h b/server/ruleset/rssanity.h
similarity index 100%
rename from server/rssanity.h
rename to server/ruleset/rssanity.h
diff --git a/server/ruleset.c b/server/ruleset/ruleload.c
similarity index 99%
rename from server/ruleset.c
rename to server/ruleset/ruleload.c
index 11e4bc7561..7b111ee264 100644
--- a/server/ruleset.c
+++ b/server/ruleset/ruleload.c
@@ -78,7 +78,7 @@
 /* server/scripting */
 #include "script_server.h"
 
-#include "ruleset.h"
+#include "ruleload.h"
 
 /* RULESET_SUFFIX already used, no leading dot here */
 #define RULES_SUFFIX "ruleset"
diff --git a/server/ruleset.h b/server/ruleset/ruleload.h
similarity index 100%
rename from server/ruleset.h
rename to server/ruleset/ruleload.h
diff --git a/server/savegame/Makefile.am b/server/savegame/Makefile.am
index 8438716c45..b676bd573a 100644
--- a/server/savegame/Makefile.am
+++ b/server/savegame/Makefile.am
@@ -10,6 +10,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/server \
 	-I$(top_srcdir)/server/advisors \
 	-I$(top_srcdir)/server/generator \
+	-I$(top_srcdir)/server/ruleset \
 	-I$(top_srcdir)/server/scripting \
 	-I$(top_srcdir)/ai \
 	-I$(top_srcdir)/dependencies/tinycthread \
diff --git a/server/savegame/savegame2.c b/server/savegame/savegame2.c
index 0f9c22fea4..cd33dc9e3a 100644
--- a/server/savegame/savegame2.c
+++ b/server/savegame/savegame2.c
@@ -109,7 +109,7 @@
 #include "notify.h"
 #include "plrhand.h"
 #include "report.h"
-#include "ruleset.h"
+#include "ruleload.h"
 #include "sanitycheck.h"
 #include "savecompat.h"
 #include "score.h"
diff --git a/server/savegame/savegame3.c b/server/savegame/savegame3.c
index 36f4dea321..c533af00f1 100644
--- a/server/savegame/savegame3.c
+++ b/server/savegame/savegame3.c
@@ -117,7 +117,7 @@
 #include "notify.h"
 #include "plrhand.h"
 #include "report.h"
-#include "ruleset.h"
+#include "ruleload.h"
 #include "sanitycheck.h"
 #include "savecompat.h"
 #include "score.h"
diff --git a/server/srv_main.c b/server/srv_main.c
index 9eae8cc5ae..9a08d9ac83 100644
--- a/server/srv_main.c
+++ b/server/srv_main.c
@@ -108,7 +108,7 @@
 #include "notify.h"
 #include "plrhand.h"
 #include "report.h"
-#include "ruleset.h"
+#include "ruleload.h"
 #include "sanitycheck.h"
 #include "score.h"
 #include "sernet.h"
diff --git a/server/stdinhand.c b/server/stdinhand.c
index 713d3cd694..d214c1c366 100644
--- a/server/stdinhand.c
+++ b/server/stdinhand.c
@@ -70,7 +70,7 @@
 #include "notify.h"
 #include "plrhand.h"
 #include "report.h"
-#include "ruleset.h"
+#include "ruleload.h"
 #include "sanitycheck.h"
 #include "score.h"
 #include "sernet.h"
diff --git a/tools/Makefile.am b/tools/Makefile.am
index 1c471e7487..041814e99a 100644
--- a/tools/Makefile.am
+++ b/tools/Makefile.am
@@ -25,6 +25,7 @@ common_cppflags = \
 	-I$(top_srcdir)/common/aicore \
 	-I$(top_srcdir)/common/networking \
 	-I$(top_srcdir)/server \
+	-I$(top_srcdir)/server/ruleset \
 	-I$(top_srcdir)/tools/ruleutil \
 	-I$(top_srcdir)/tools/shared \
 	-I$(top_srcdir)/dependencies/tinycthread \
diff --git a/tools/manual/Makefile.am b/tools/manual/Makefile.am
index e3105a6b29..35e60de1c5 100644
--- a/tools/manual/Makefile.am
+++ b/tools/manual/Makefile.am
@@ -9,6 +9,7 @@ common_cppflags = \
 	-I$(top_srcdir)/common/aicore \
 	-I$(top_srcdir)/common/networking \
 	-I$(top_srcdir)/server \
+	-I$(top_srcdir)/server/ruleset \
 	-I$(top_srcdir)/client \
 	-I$(top_srcdir)/client/include \
 	-I$(top_srcdir)/tools/shared \
diff --git a/tools/manual/fc_manual.c b/tools/manual/fc_manual.c
index 299f4ae953..2d76cf69a8 100644
--- a/tools/manual/fc_manual.c
+++ b/tools/manual/fc_manual.c
@@ -47,7 +47,7 @@
 #include "tilespec.h"
 
 /* server */
-#include "ruleset.h"
+#include "ruleload.h"
 #include "settings.h"
 #include "sernet.h"
 #include "srv_main.h"
diff --git a/tools/ruledit/Makefile.am b/tools/ruledit/Makefile.am
index 0b2b712e60..0afc971f31 100644
--- a/tools/ruledit/Makefile.am
+++ b/tools/ruledit/Makefile.am
@@ -17,6 +17,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/common/aicore \
 	-I$(top_srcdir)/common/networking \
 	-I$(top_srcdir)/server \
+	-I$(top_srcdir)/server/ruleset \
 	-I$(top_srcdir)/tools/shared \
 	-I$(top_srcdir)/tools/ruleutil \
 	-I$(top_srcdir)/dependencies/tinycthread \
diff --git a/tools/ruledit/ruledit_qt.cpp b/tools/ruledit/ruledit_qt.cpp
index a445596fbf..ef62cec020 100644
--- a/tools/ruledit/ruledit_qt.cpp
+++ b/tools/ruledit/ruledit_qt.cpp
@@ -36,7 +36,7 @@
 #include "version.h"
 
 // server
-#include "ruleset.h"
+#include "ruleload.h"
 
 // ruledit
 #include "conversion_log.h"
diff --git a/tools/ruleup.c b/tools/ruleup.c
index aa1bcd7843..d51ab8a032 100644
--- a/tools/ruleup.c
+++ b/tools/ruleup.c
@@ -32,7 +32,7 @@
 #include "fc_interface.h"
 
 /* server */
-#include "ruleset.h"
+#include "ruleload.h"
 #include "sernet.h"
 #include "settings.h"
 
diff --git a/tools/ruleutil/Makefile.am b/tools/ruleutil/Makefile.am
index e63f1f422a..ee747a9a86 100644
--- a/tools/ruleutil/Makefile.am
+++ b/tools/ruleutil/Makefile.am
@@ -8,6 +8,7 @@ AM_CPPFLAGS = \
 	-I$(top_srcdir)/common/aicore \
 	-I$(top_srcdir)/common/networking \
 	-I$(top_srcdir)/server \
+	-I$(top_srcdir)/server/ruleset \
 	-I$(top_srcdir)/dependencies/tinycthread \
 	-I$(top_srcdir)/gen_headers/enums
 
diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c
index 6dde0db53e..1a70334826 100644
--- a/tools/ruleutil/rulesave.c
+++ b/tools/ruleutil/rulesave.c
@@ -37,7 +37,7 @@
 #include "version.h"
 
 /* server */
-#include "ruleset.h"
+#include "ruleload.h"
 #include "settings.h"
 
 /* tools/ruleutil */
-- 
2.42.0

