From 1d774d1b9828db237fdd537dfe5e117ee28f3b01 Mon Sep 17 00:00:00 2001 From: dark-ether Date: Wed, 6 Jul 2022 20:31:27 -0300 Subject: [PATCH 3/4] server/ruleset.c: started work on separating action related configuration from game.ruleset --- server/ruleset.c | 38 +++++++++++++++++++++++++++++++++++++- 1 file changed, 37 insertions(+), 1 deletion(-) diff --git a/server/ruleset.c b/server/ruleset.c index 8e596f98e2..412b0ef205 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -173,6 +173,8 @@ static bool load_ruleset_effects(struct section_file *file, struct rscompat_info *compat); static bool load_ruleset_game(struct section_file *file, bool act, struct rscompat_info *compat); +static bool load_ruleset_actions(struct section_file *file, + struct rscompat_info *compat); static void send_ruleset_tech_classes(struct conn_list *dest); static void send_ruleset_techs(struct conn_list *dest); @@ -7635,6 +7637,15 @@ static bool load_ruleset_game(struct section_file *file, bool act, return ok; } +/**********************************************************************//** + +**************************************************************************/ +static bool load_ruleset_actions(struct section_file *file, + struct rscompat_info *compat) { + /* For now no code is here */ + return TRUE; +} + /**********************************************************************//** Send the units ruleset information (all individual unit classes) to the specified connections. @@ -8977,6 +8988,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, { struct section_file *techfile, *unitfile, *buildfile, *govfile, *terrfile; struct section_file *stylefile, *cityfile, *nationfile, *effectfile, *gamefile; + struct section_file *actionfile; bool ok = TRUE; struct rscompat_info compat_info; @@ -9018,7 +9030,7 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, } else { game.server.luadata = NULL; } - + if (techfile == NULL || buildfile == NULL || govfile == NULL @@ -9044,6 +9056,30 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, && load_style_names(stylefile, &compat_info) && load_nation_names(nationfile, &compat_info); } + + if (ok) { + /* Can only happen here because 3.1 rulesets may not have a + * actions.ruleset. remember to in 3.3 move it with the others. */ + if (compat_info.version < RSFORMAT_3_2) { + if (!compat_info.compat_mode) { + ok = FALSE; + ruleset_error(LOG_ERROR, "Tried to load ruleset of earlier version without compatibility mode."); + } + else { + load_ruleset_actions(gamefile, &compat_info); + } + } + else { + actionfile = openload_ruleset_file("actions", rsdir); + if (actionfile == NULL) { + ok = FALSE; + } + if (ok) { + /* It may be necessary to further divide load_ruleset_actions in a load_action_names. */ + load_ruleset_actions(actionfile,&compat_info); + } + } + } if (ok) { ok = rscompat_names(&compat_info); -- 2.37.0