From c7efc10fb05cbfd306e4ac9c6fffa55d19e18820 Mon Sep 17 00:00:00 2001 From: dark-ether Date: Tue, 12 Jul 2022 09:51:44 -0300 Subject: [PATCH] Fixed tools/ruleutil/rulesave.c not being compliant with coding standards. data/*/Makefile.am: Added actions.ruleset to packaging data/*/actions.ruleset: Added empty action files meson.build: Added actions.ruleset to list of ruleset files server/ruleset.c: Added opening actions file. tools/ruleutil/rulesave.c: Added saving to actions file. --- data/alien/Makefile.am | 1 + data/alien/actions.ruleset | 17 ++++++++++++++ data/civ1/Makefile.am | 1 + data/civ1/actions.ruleset | 15 +++++++++++++ data/civ2/Makefile.am | 1 + data/civ2/actions.ruleset | 15 +++++++++++++ data/civ2civ3/Makefile.am | 1 + data/civ2civ3/actions.ruleset | 15 +++++++++++++ data/classic/Makefile.am | 1 + data/classic/actions.ruleset | 16 +++++++++++++ data/goldkeep/actions.ruleset | 19 ++++++++++++++++ data/granularity/actions.ruleset | 16 +++++++++++++ data/multiplayer/Makefile.am | 1 + data/multiplayer/actions.ruleset | 16 +++++++++++++ data/sandbox/Makefile.am | 1 + data/sandbox/actions.ruleset | 16 +++++++++++++ data/stub/Makefile.am | 1 + data/stub/actions.ruleset | 8 +++++++ data/webperimental/actions.ruleset | 16 +++++++++++++ meson.build | 1 + server/ruleset.c | 36 ++++++++++++++++++++++++++++++ tools/ruleutil/rulesave.c | 22 ++++++++++++++++-- 22 files changed, 234 insertions(+), 2 deletions(-) create mode 100644 data/alien/actions.ruleset create mode 100644 data/civ1/actions.ruleset create mode 100644 data/civ2/actions.ruleset create mode 100644 data/civ2civ3/actions.ruleset create mode 100644 data/classic/actions.ruleset create mode 100644 data/goldkeep/actions.ruleset create mode 100644 data/granularity/actions.ruleset create mode 100644 data/multiplayer/actions.ruleset create mode 100644 data/sandbox/actions.ruleset create mode 100644 data/stub/actions.ruleset create mode 100644 data/webperimental/actions.ruleset diff --git a/data/alien/Makefile.am b/data/alien/Makefile.am index 3278688520..f9e93694b3 100644 --- a/data/alien/Makefile.am +++ b/data/alien/Makefile.am @@ -6,6 +6,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/alien SUBDIRS = nation pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/alien/actions.ruleset b/data/alien/actions.ruleset new file mode 100644 index 0000000000..d54a5f0b50 --- /dev/null +++ b/data/alien/actions.ruleset @@ -0,0 +1,17 @@ +; This is actions ruleset for Alien World. + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. +[datafile] +description = "Alien World actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 + diff --git a/data/civ1/Makefile.am b/data/civ1/Makefile.am index ded8c40930..59f2b1ac5b 100644 --- a/data/civ1/Makefile.am +++ b/data/civ1/Makefile.am @@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/civ1 pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/civ1/actions.ruleset b/data/civ1/actions.ruleset new file mode 100644 index 0000000000..951f4d0129 --- /dev/null +++ b/data/civ1/actions.ruleset @@ -0,0 +1,15 @@ +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Civ1 actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 diff --git a/data/civ2/Makefile.am b/data/civ2/Makefile.am index fec81d5aee..6d03d5e065 100644 --- a/data/civ2/Makefile.am +++ b/data/civ2/Makefile.am @@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/civ2 pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/civ2/actions.ruleset b/data/civ2/actions.ruleset new file mode 100644 index 0000000000..72b1f47208 --- /dev/null +++ b/data/civ2/actions.ruleset @@ -0,0 +1,15 @@ +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Civ2 actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 diff --git a/data/civ2civ3/Makefile.am b/data/civ2civ3/Makefile.am index 42548f8f00..1528915378 100644 --- a/data/civ2civ3/Makefile.am +++ b/data/civ2civ3/Makefile.am @@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/civ2civ3 pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/civ2civ3/actions.ruleset b/data/civ2civ3/actions.ruleset new file mode 100644 index 0000000000..b7e335b4d5 --- /dev/null +++ b/data/civ2civ3/actions.ruleset @@ -0,0 +1,15 @@ +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Civ2Civ3 actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02 web-compatible" +format_version = 30 diff --git a/data/classic/Makefile.am b/data/classic/Makefile.am index 8df2f17355..0203f6d204 100644 --- a/data/classic/Makefile.am +++ b/data/classic/Makefile.am @@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/classic pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/classic/actions.ruleset b/data/classic/actions.ruleset new file mode 100644 index 0000000000..02b6b3486b --- /dev/null +++ b/data/classic/actions.ruleset @@ -0,0 +1,16 @@ + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Classic actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02 web-compatible" +format_version = 30 diff --git a/data/goldkeep/actions.ruleset b/data/goldkeep/actions.ruleset new file mode 100644 index 0000000000..a52f31ab4b --- /dev/null +++ b/data/goldkeep/actions.ruleset @@ -0,0 +1,19 @@ + +; This is the goldkeep ruleset. See README.goldkeep +; for a detailed description. + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Goldkeep actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 diff --git a/data/granularity/actions.ruleset b/data/granularity/actions.ruleset new file mode 100644 index 0000000000..f2c0b5b275 --- /dev/null +++ b/data/granularity/actions.ruleset @@ -0,0 +1,16 @@ + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Granularity actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 diff --git a/data/multiplayer/Makefile.am b/data/multiplayer/Makefile.am index 6da9c6463a..ae393a2f95 100644 --- a/data/multiplayer/Makefile.am +++ b/data/multiplayer/Makefile.am @@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/multiplayer pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/multiplayer/actions.ruleset b/data/multiplayer/actions.ruleset new file mode 100644 index 0000000000..f9ffddf966 --- /dev/null +++ b/data/multiplayer/actions.ruleset @@ -0,0 +1,16 @@ + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Multiplayer actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02 web-compatible" +format_version = 30 diff --git a/data/sandbox/Makefile.am b/data/sandbox/Makefile.am index d02763ad1f..a1b6a5553e 100644 --- a/data/sandbox/Makefile.am +++ b/data/sandbox/Makefile.am @@ -4,6 +4,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/sandbox pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/sandbox/actions.ruleset b/data/sandbox/actions.ruleset new file mode 100644 index 0000000000..9a60f6903f --- /dev/null +++ b/data/sandbox/actions.ruleset @@ -0,0 +1,16 @@ + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Sandbox actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 diff --git a/data/stub/Makefile.am b/data/stub/Makefile.am index ea148ef257..b9eabbc795 100644 --- a/data/stub/Makefile.am +++ b/data/stub/Makefile.am @@ -6,6 +6,7 @@ pkgdatadir = $(datadir)/$(PACKAGE)/stub SUBDIRS = nations pkgdata_DATA = \ + actions.ruleset \ buildings.ruleset \ cities.ruleset \ effects.ruleset \ diff --git a/data/stub/actions.ruleset b/data/stub/actions.ruleset new file mode 100644 index 0000000000..a47d4c8f3c --- /dev/null +++ b/data/stub/actions.ruleset @@ -0,0 +1,8 @@ + +; This is minimal buildings ruleset. Replace with your module name in +; description. + +[datafile] +description = " actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02" +format_version = 30 diff --git a/data/webperimental/actions.ruleset b/data/webperimental/actions.ruleset new file mode 100644 index 0000000000..b5651af479 --- /dev/null +++ b/data/webperimental/actions.ruleset @@ -0,0 +1,16 @@ + +; Modifying this file: +; You should not modify this file except to make bugfixes or +; for other "maintenance". If you want to make custom changes, +; you should create a new datadir subdirectory and copy this file +; into that directory, and then modify that copy. Then use the +; command "rulesetdir " in the server to have freeciv +; use your new customized file. + +; Note that the freeciv AI may not cope well with anything more +; than minor changes. + +[datafile] +description = "Experimental web-client actions data for Freeciv" +options = "+Freeciv-ruleset-3.2-Devel-2022.Feb.02 web-compatible" +format_version = 30 diff --git a/meson.build b/meson.build index e1f1c75106..c8b10fb339 100644 --- a/meson.build +++ b/meson.build @@ -3246,6 +3246,7 @@ rulesets = [ ] ruleset_files = [ + 'actions.ruleset', 'buildings.ruleset', 'cities.ruleset', 'effects.ruleset', diff --git a/server/ruleset.c b/server/ruleset.c index 8c9f660fa2..069eeaa8f7 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -175,6 +175,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); @@ -7721,6 +7723,16 @@ static bool load_ruleset_game(struct section_file *file, bool act, return ok; } +/**********************************************************************//** + loads action information from a file +**************************************************************************/ +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. @@ -9063,6 +9075,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; @@ -9131,6 +9144,29 @@ static bool load_rulesetdir(const char *rsdir, bool compat_mode, && 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. */ + ok = load_ruleset_actions(actionfile, &compat_info); + } + } + } + if (ok) { ok = rscompat_names(&compat_info); } diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 8481413f8b..39a569baba 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1049,6 +1049,19 @@ static bool save_bv_actions(struct section_file *sfile, return TRUE; } +/**********************************************************************//** + Save actions.ruleset +**************************************************************************/ +static bool save_actions_ruleset(const char *filename, const char *name) +{ + struct section_file *sfile = create_ruleset_file(name, "actions"); + + /* TODO: move action logic from save_game_ruleset to here */ + if (sfile == NULL) { + return FALSE; + } + return save_ruleset_file(sfile, filename); +} /**********************************************************************//** Save game.ruleset @@ -1287,7 +1300,7 @@ static bool save_game_ruleset(const char *filename, const char *name) save_default_int(sfile, game.server.incite_total_factor, RS_DEFAULT_INCITE_TOTAL_FCT, "incite_cost.total_factor", NULL); - + /*start of action related code */ { /* Action auto performers aren't ready to be exposed in the ruleset * yet. The behavior when two action auto performers for the same @@ -1405,7 +1418,7 @@ static bool save_game_ruleset(const char *filename, const char *name) save_reqs_vector(sfile, &(pae->actor_reqs), path, "actor_reqs"); save_reqs_vector(sfile, &(pae->target_reqs), path, "target_reqs"); } action_enablers_iterate_end; - + /* action related code seems to end here */ if (game.info.tired_attack != RS_DEFAULT_TIRED_ATTACK) { comment_combat_rules_tired_attack(sfile); } @@ -3329,6 +3342,11 @@ bool save_ruleset(const char *path, const char *name, struct rule_data *data) success = save_units_ruleset(filename, name); } + if (success) { + fc_snprintf(filename,sizeof(filename), "%s/actions.ruleset",path); + success = save_actions_ruleset(filename, name); + } + if (success) { fc_snprintf(filename, sizeof(filename), "%s/script.lua", path); success = save_script_lua(filename, name, get_script_buffer()); -- 2.37.0