From faa0bbbd97d383de8bec5bcd4f606ebbd0fdf6c5 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sat, 13 Nov 2021 09:30:59 +0200 Subject: [PATCH 18/18] Rename "Firepower1" combat bonus as "LowFirepower" This prepares us to having the actual firepower value being something else than 1. See osdn #43075 Signed-off-by: Marko Lindqvist --- ai/default/aiunit.c | 2 +- client/helpdata.c | 2 +- common/combat.c | 2 +- common/unittype.h | 4 ++-- data/civ2/units.ruleset | 4 ++-- data/classic/units.ruleset | 4 ++-- data/experimental/units.ruleset | 4 ++-- data/multiplayer/units.ruleset | 4 ++-- data/webperimental/units.ruleset | 4 ++-- server/rscompat.c | 15 +++++++++++++++ server/rscompat.h | 2 ++ server/ruleset.c | 1 + 12 files changed, 33 insertions(+), 15 deletions(-) diff --git a/ai/default/aiunit.c b/ai/default/aiunit.c index 95f8d3039d..565eb5b028 100644 --- a/ai/default/aiunit.c +++ b/ai/default/aiunit.c @@ -3120,7 +3120,7 @@ void dai_units_ruleset_init(struct ai_type *ait) /* Confirm firepower */ combat_bonus_list_iterate(punittype->bonuses, pbonus) { - if (pbonus->type == CBONUS_FIREPOWER1) { + if (pbonus->type == CBONUS_LOW_FIREPOWER) { unit_type_iterate(penemy) { if (utype_has_flag(penemy, pbonus->flag)) { struct unit_type_ai *utai = utype_ai_data(penemy, ait); diff --git a/client/helpdata.c b/client/helpdata.c index 811d16791c..067e8b4021 100644 --- a/client/helpdata.c +++ b/client/helpdata.c @@ -1847,7 +1847,7 @@ char *helptext_unit(char *buf, size_t bufsz, struct player *pplayer, cbonus->value + 1, astr_build_or_list(&list, against, targets)); break; - case CBONUS_FIREPOWER1: + case CBONUS_LOW_FIREPOWER: cat_snprintf(buf, bufsz, /* TRANS: or-list of unit types */ _("* Reduces target's firepower to 1 when " diff --git a/common/combat.c b/common/combat.c index d905632274..6f23fc6ee6 100644 --- a/common/combat.c +++ b/common/combat.c @@ -406,7 +406,7 @@ void get_modified_firepower(const struct unit *attacker, */ if (combat_bonus_against(unit_type_get(attacker)->bonuses, unit_type_get(defender), - CBONUS_FIREPOWER1)) { + CBONUS_LOW_FIREPOWER)) { *def_fp = 1; } diff --git a/common/unittype.h b/common/unittype.h index c05d0342a8..0d456d58b4 100644 --- a/common/unittype.h +++ b/common/unittype.h @@ -427,8 +427,8 @@ BV_DEFINE(bv_unit_type_roles, L_MAX); #define SPECENUM_VALUE0NAME "DefenseMultiplier" #define SPECENUM_VALUE1 CBONUS_DEFENSE_DIVIDER #define SPECENUM_VALUE1NAME "DefenseDivider" -#define SPECENUM_VALUE2 CBONUS_FIREPOWER1 -#define SPECENUM_VALUE2NAME "Firepower1" +#define SPECENUM_VALUE2 CBONUS_LOW_FIREPOWER +#define SPECENUM_VALUE2NAME "LowFirepower" #define SPECENUM_VALUE3 CBONUS_DEFENSE_MULTIPLIER_PCT #define SPECENUM_VALUE3NAME "DefenseMultiplierPct" #define SPECENUM_VALUE4 CBONUS_DEFENSE_DIVIDER_PCT diff --git a/data/civ2/units.ruleset b/data/civ2/units.ruleset index c5d8e6eb73..cd3d36d215 100644 --- a/data/civ2/units.ruleset +++ b/data/civ2/units.ruleset @@ -1285,7 +1285,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value", "quiet" "Helicopter", "DefenseDivider", 1, FALSE - "Helicopter", "Firepower1", 1, FALSE + "Helicopter", "LowFirepower", 1, FALSE "Fighter", "CityDefensePct", 100 "Bomber", "CityDefensePct", 300 } @@ -1394,7 +1394,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Fighter", "CityDefensePct", 100 "Bomber", "CityDefensePct", 300 } diff --git a/data/classic/units.ruleset b/data/classic/units.ruleset index ba608c8da5..304b0bbd20 100644 --- a/data/classic/units.ruleset +++ b/data/classic/units.ruleset @@ -1327,7 +1327,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Bomber", "DefenseMultiplier", 1 } flags = "AirAttacker" @@ -1435,7 +1435,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Bomber", "DefenseMultiplier", 1 } vision_layer = "Stealth" diff --git a/data/experimental/units.ruleset b/data/experimental/units.ruleset index 46d18ca033..64364a69bb 100644 --- a/data/experimental/units.ruleset +++ b/data/experimental/units.ruleset @@ -1350,7 +1350,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Bomber", "DefenseMultiplier", 1 } flags = "AirAttacker", "Shield2Gold" @@ -1459,7 +1459,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Bomber", "DefenseMultiplier", 1 } vision_layer = "Stealth" diff --git a/data/multiplayer/units.ruleset b/data/multiplayer/units.ruleset index 265a9fb98a..42eb5e0ffa 100644 --- a/data/multiplayer/units.ruleset +++ b/data/multiplayer/units.ruleset @@ -1427,7 +1427,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Bomber", "DefenseMultiplier", 1 } flags = "AirAttacker" @@ -1534,7 +1534,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 "Bomber", "DefenseMultiplier", 1 } vision_layer = "Stealth" diff --git a/data/webperimental/units.ruleset b/data/webperimental/units.ruleset index f1d6ba7d15..7c084fd097 100644 --- a/data/webperimental/units.ruleset +++ b/data/webperimental/units.ruleset @@ -1335,7 +1335,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 } flags = "AirAttacker", "MediumWeight" roles = "" @@ -1448,7 +1448,7 @@ targets = "Air", "Missile" bonuses = { "flag", "type", "value" "Helicopter", "DefenseDivider", 1 - "Helicopter", "Firepower1", 1 + "Helicopter", "LowFirepower", 1 } vision_layer = "Stealth" flags = "AirAttacker", "MediumWeight" diff --git a/server/rscompat.c b/server/rscompat.c index ac110d925b..6feb6bf7d9 100644 --- a/server/rscompat.c +++ b/server/rscompat.c @@ -2026,6 +2026,21 @@ const char *rscompat_utype_flag_name_3_1(struct rscompat_info *compat, return old_type; } +/**********************************************************************//** + Replace deprecated combat bonus names with currently valid ones. +**************************************************************************/ +const char *rscompat_combat_bonus_name_3_1(struct rscompat_info *compat, + const char *old_type) +{ + if (compat->compat_mode && compat->ver_units < RSFORMAT_3_1) { + if (!fc_strcasecmp("Firepower1", old_type)) { + return combat_bonus_type_name(CBONUS_LOW_FIREPOWER); + } + } + + return old_type; +} + /**********************************************************************//** Adjust freeciv-3.0 ruleset extra definitions to freeciv-3.1 **************************************************************************/ diff --git a/server/rscompat.h b/server/rscompat.h index 9013736ffd..30748b8888 100644 --- a/server/rscompat.h +++ b/server/rscompat.h @@ -72,6 +72,8 @@ const char *rscompat_req_name_3_1(const char *type, const char *old_name); const char *rscompat_utype_flag_name_3_1(struct rscompat_info *info, const char *old_type); +const char *rscompat_combat_bonus_name_3_1(struct rscompat_info *compat, + const char *old_type); bool rscompat_old_effect_3_1(const char *type, struct section_file *file, const char *sec_name, struct rscompat_info *compat); void rscompat_extra_adjust_3_1(struct rscompat_info *compat, diff --git a/server/ruleset.c b/server/ruleset.c index 786a73136c..95391a1f9a 100644 --- a/server/ruleset.c +++ b/server/ruleset.c @@ -813,6 +813,7 @@ static bool lookup_cbonus_list(struct rscompat_info *compat, continue; } type = secfile_lookup_str(file, "%s.%s%d.type", sec, sub, j); + type = rscompat_combat_bonus_name_3_1(compat, type); bonus->type = combat_bonus_type_by_name(type, fc_strcasecmp); if (!combat_bonus_type_is_valid(bonus->type)) { log_error("\"%s\": unknown bonus type \"%s\" in '%s.%s'.", -- 2.33.0