From 8b74b6d2245aba2a12da07f35c2488b860d197c7 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Wed, 24 Mar 2021 23:58:46 +0200 Subject: [PATCH 36/36] Introduce RSFORMAT_3_1 macro to use instead of Magic Number Use macro RSFORMAT_3_1 instead of value 20 when referring to format version of the current freeciv version. See osdn #41853 Signed-off-by: Marko Lindqvist --- server/rscompat.c | 20 ++++++++++---------- server/ruleset.c | 8 ++++---- server/ruleset.h | 2 ++ tools/ruleutil/rulesave.c | 2 +- 4 files changed, 17 insertions(+), 15 deletions(-) diff --git a/server/rscompat.c b/server/rscompat.c index 486b271490..2ca5fcc8db 100644 --- a/server/rscompat.c +++ b/server/rscompat.c @@ -323,7 +323,7 @@ static int first_free_terrain_user_flag(void) **************************************************************************/ bool rscompat_names(struct rscompat_info *info) { - if (info->ver_units < 20) { + if (info->ver_units < RSFORMAT_3_1) { /* Some unit type flags moved to the ruleset between 3.0 and 3.1. * Add them back as user flags. * XXX: ruleset might not need all of these, and may have enough @@ -414,7 +414,7 @@ bool rscompat_names(struct rscompat_info *info) } } - if (info->ver_terrain < 20) { + if (info->ver_terrain < RSFORMAT_3_1) { /* Some terrain flags moved to the ruleset between 3.0 and 3.1. * Add them back as user flags. * XXX: ruleset might not need all of these, and may have enough @@ -509,7 +509,7 @@ static bool effect_list_compat_cb(struct effect *peffect, void *data) { struct rscompat_info *info = (struct rscompat_info *)data; - if (info->ver_effects < 20) { + if (info->ver_effects < RSFORMAT_3_1) { /* Attack has been split in regular "Attack" and "Suicide Attack". */ effect_handle_split_universal(peffect, universal_by_number(VUT_ACTION, ACTION_ATTACK), @@ -657,7 +657,7 @@ static void effect_to_enabler(action_id action, struct section_file *file, bool rscompat_old_effect_3_1(const char *type, struct section_file *file, const char *sec_name, struct rscompat_info *compat) { - if (compat->ver_effects < 20) { + if (compat->ver_effects < RSFORMAT_3_1) { if (!fc_strcasecmp(type, "Transform_Possible")) { effect_to_enabler(ACTION_TRANSFORM_TERRAIN, file, sec_name, compat, type); return TRUE; @@ -698,7 +698,7 @@ void rscompat_postprocess(struct rscompat_info *info) * the new effects from being upgraded by accident. */ iterate_effect_cache(effect_list_compat_cb, info); - if (info->ver_effects < 20) { + if (info->ver_effects < RSFORMAT_3_1) { struct effect *peffect; /* Post successful action move fragment loss for "Bombard" @@ -945,7 +945,7 @@ void rscompat_postprocess(struct rscompat_info *info) FALSE, FALSE, FALSE, "HutNothing")); } - if (info->ver_game < 20) { + if (info->ver_game < RSFORMAT_3_1) { /* New enablers */ struct action_enabler *enabler; struct requirement e_req; @@ -1522,7 +1522,7 @@ void rscompat_postprocess(struct rscompat_info *info) } action_enablers_iterate_end; } - if (info->ver_units < 20) { + if (info->ver_units < RSFORMAT_3_1) { enum unit_class_flag_id nothing = unit_class_flag_id_by_name("HutNothing", fc_strcasecmp); @@ -1558,7 +1558,7 @@ bool rscompat_auto_attack_3_1(struct rscompat_info *compat, { int i; - if (compat->ver_game < 20) { + if (compat->ver_game < RSFORMAT_3_1) { /* Auto attack happens during war. */ requirement_vector_append(&auto_perf->reqs, req_from_values(VUT_DIPLREL, @@ -1713,7 +1713,7 @@ static bool slow_invasion_effects(const char *action_rule_name) bool rscompat_old_slow_invasions_3_1(struct rscompat_info *compat, bool slow_invasions) { - if (compat->ver_effects < 20 && compat->ver_game < 20) { + if (compat->ver_effects < RSFORMAT_3_1 && compat->ver_game < RSFORMAT_3_1) { /* BeachLander and slow_invasions has moved to the ruleset. Use a "fake * generalized" Transport Disembark, Conquer City, Enter Hut and * Frighten Hut to handle it. */ @@ -1895,7 +1895,7 @@ const char *rscompat_utype_flag_name_3_1(struct rscompat_info *compat, void rscompat_extra_adjust_3_1(struct rscompat_info *compat, struct extra_type *pextra) { - if (compat->compat_mode && compat->ver_terrain < 20) { + if (compat->compat_mode && compat->ver_terrain < RSFORMAT_3_1) { /* Give remove cause ERM_ENTER for huts */ if (is_extra_caused_by(pextra, EC_HUT)) { diff --git a/server/ruleset.c b/server/ruleset.c index 843c8a3dfc..582bda7e5d 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -2070,7 +2070,7 @@ static bool load_ruleset_units(struct section_file *file, "%s.non_native_def_pct", sec_name); - if (compat->compat_mode && compat->ver_units < 20) { + if (compat->compat_mode && compat->ver_units < RSFORMAT_3_1) { const char *hut_str; hut_str = secfile_lookup_str_default(file, "Normal", @@ -2462,7 +2462,7 @@ static bool load_ruleset_units(struct section_file *file, u->paratroopers_range = secfile_lookup_int_default(file, 0, "%s.paratroopers_range", sec_name); - if (compat->compat_mode && compat->ver_units < 20) { + if (compat->compat_mode && compat->ver_units < RSFORMAT_3_1) { u->rscompat_cache.paratroopers_mr_req = SINGLE_MOVE * secfile_lookup_int_default( file, 0, "%s.paratroopers_mr_req", sec_name); @@ -6846,7 +6846,7 @@ static bool load_ruleset_game(struct section_file *file, bool act, /* section: actions */ if (ok) { - if (compat->compat_mode && compat->ver_game < 20) { + if (compat->compat_mode && compat->ver_game < RSFORMAT_3_1) { int force_capture_units, force_bombard, force_explode_nuclear; if (secfile_lookup_bool_default(file, FALSE, @@ -7223,7 +7223,7 @@ static bool load_ruleset_game(struct section_file *file, bool act, } } - if (compat->compat_mode && compat->ver_game < 20) { + if (compat->compat_mode && compat->ver_game < RSFORMAT_3_1) { bool slow_invasions = secfile_lookup_bool_default(file, TRUE, "global_unit_options.slow_invasions"); diff --git a/server/ruleset.h b/server/ruleset.h index a7e19227ff..ce91e5b9d6 100644 --- a/server/ruleset.h +++ b/server/ruleset.h @@ -33,6 +33,8 @@ extern "C" { * - ruleset of the development version at the given data */ +#define RSFORMAT_3_1 20 + struct conn_list; typedef void (*rs_conversion_logger)(const char *msg); diff --git a/tools/ruleutil/rulesave.c b/tools/ruleutil/rulesave.c index 18cc0df085..d13f9eeb77 100644 --- a/tools/ruleutil/rulesave.c +++ b/tools/ruleutil/rulesave.c @@ -46,7 +46,7 @@ * 10 - Freeciv-3.0 * 20 - Freeciv-3.1 */ -#define FORMAT_VERSION 20 +#define FORMAT_VERSION RSFORMAT_3_1 /**********************************************************************//** Create new ruleset section file with common header. -- 2.30.2