From 3b016cae3498f5cce3f920ea6cd1c6d0605c2dce Mon Sep 17 00:00:00 2001 From: dark-ether Date: Sat, 9 Jul 2022 10:45:20 -0300 Subject: [PATCH] add dummy actions.c, fixed coding style violations data/**/Makefile.am: added actions.c to files included data/**/actions.ruleset: added this file to in the future move relevant rules meson.build: added actions.ruleset to list of included files server/ruleset.c: added code to open actions.ruleset if in version equal or higher than 3.2 tools/ruleutil/rulesave.c: added saving actions.ruleset to saving code --- 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 | 20 +++++++++++++++-- 22 files changed, 232 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..4cb17f4b41 --- /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 web-compatible" +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..fd07a12425 --- /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 web-compatible" +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..93fc30b9ce --- /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 web-compatible" +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..87fbd7f9b6 --- /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 web-compatible" +format_version = 30 diff --git a/data/granularity/actions.ruleset b/data/granularity/actions.ruleset new file mode 100644 index 0000000000..3b55d2355e --- /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 web-compatible" +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..f9e24e7080 --- /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 web-compatible" +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..6320d98976 --- /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 web-compatible" +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 d868ce3881..079beb89f8 100644 --- a/meson.build +++ b/meson.build @@ -3225,6 +3225,7 @@ rulesets = [ ] ruleset_files = [ + 'actions.ruleset', 'buildings.ruleset', 'cities.ruleset', 'effects.ruleset', diff --git a/server/ruleset.c b/server/ruleset.c index 8e596f98e2..e50ee03d00 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,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. @@ -8977,6 +8989,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; @@ -9045,6 +9058,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 713ba41059..12d274f8e8 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -1048,6 +1048,17 @@ 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 @@ -1286,7 +1297,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 @@ -1404,7 +1415,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); } @@ -3313,6 +3324,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