From 72cc5dd1371d1c86be2db248729c5a1360e2fb5d Mon Sep 17 00:00:00 2001 From: Marko Lindqvist Date: Sun, 22 Oct 2023 09:22:10 +0300 Subject: [PATCH 45/45] Unhardcode barbarian requirement of "Collect Ransom" See osdn #48885 Signed-off-by: Marko Lindqvist --- common/actres.c | 3 +- data/alien/actions.ruleset | 20 ++++++++---- data/civ1/actions.ruleset | 20 ++++++++---- data/civ2/actions.ruleset | 36 ++++++++++++++------- data/civ2civ3/actions.ruleset | 24 ++++++++++---- data/classic/actions.ruleset | 24 ++++++++++---- data/goldkeep/actions.ruleset | 24 ++++++++++---- data/multiplayer/actions.ruleset | 24 ++++++++++---- data/sandbox/actions.ruleset | 52 ++++++++++++++++++++++-------- data/webperimental/actions.ruleset | 24 ++++++++++---- server/rscompat.c | 13 +++++++- 11 files changed, 193 insertions(+), 71 deletions(-) diff --git a/common/actres.c b/common/actres.c index 3f71d3a6ea..031c0cf4d8 100644 --- a/common/actres.c +++ b/common/actres.c @@ -672,8 +672,7 @@ enum fc_tristate actres_possible(enum action_result result, break; case ACTRES_COLLECT_RANSOM: - if (!is_barbarian(actor->player) - || !uclass_has_flag(unit_class_get(actor->unit), UCF_COLLECT_RANSOM)) { + if (!uclass_has_flag(unit_class_get(actor->unit), UCF_COLLECT_RANSOM)) { return FALSE; } diff --git a/data/alien/actions.ruleset b/data/alien/actions.ruleset index a017433b79..e493f665a4 100644 --- a/data/alien/actions.ruleset +++ b/data/alien/actions.ruleset @@ -600,16 +600,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_uclass_sea] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitClass", "Sea", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitClass", "Sea", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_explode_missile] diff --git a/data/civ1/actions.ruleset b/data/civ1/actions.ruleset index bbd0beda2f..6723e02084 100644 --- a/data/civ1/actions.ruleset +++ b/data/civ1/actions.ruleset @@ -589,16 +589,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_uclass_sea] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitClass", "Sea", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitClass", "Sea", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_explode_missile] diff --git a/data/civ2/actions.ruleset b/data/civ2/actions.ruleset index dda788a271..1d641ced4c 100644 --- a/data/civ2/actions.ruleset +++ b/data/civ2/actions.ruleset @@ -777,27 +777,39 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_uclass_sea] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitClass", "Sea", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitClass", "Sea", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_explode_missile] diff --git a/data/civ2civ3/actions.ruleset b/data/civ2civ3/actions.ruleset index 923b886656..3598410690 100644 --- a/data/civ2civ3/actions.ruleset +++ b/data/civ2civ3/actions.ruleset @@ -924,16 +924,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_att_from_non_native] @@ -946,6 +954,10 @@ actor_reqs = "UnitClassFlag", "AttFromNonNative", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_explode_missile] action = "Suicide Attack" diff --git a/data/classic/actions.ruleset b/data/classic/actions.ruleset index 38bcc8563a..f0e7b204f7 100644 --- a/data/classic/actions.ruleset +++ b/data/classic/actions.ruleset @@ -850,16 +850,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_att_from_non_native] @@ -872,6 +880,10 @@ actor_reqs = "UnitClassFlag", "AttFromNonNative", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_explode_missile] action = "Suicide Attack" diff --git a/data/goldkeep/actions.ruleset b/data/goldkeep/actions.ruleset index d80e6d2714..4b545b86b6 100644 --- a/data/goldkeep/actions.ruleset +++ b/data/goldkeep/actions.ruleset @@ -864,16 +864,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_att_from_non_native] @@ -886,6 +894,10 @@ actor_reqs = "UnitClassFlag", "AttFromNonNative", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_explode_missile] action = "Suicide Attack" diff --git a/data/multiplayer/actions.ruleset b/data/multiplayer/actions.ruleset index 51f03fb39d..2f94c2f812 100644 --- a/data/multiplayer/actions.ruleset +++ b/data/multiplayer/actions.ruleset @@ -838,16 +838,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_att_from_non_native] @@ -860,6 +868,10 @@ actor_reqs = "UnitClassFlag", "AttFromNonNative", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_explode_missile] action = "Suicide Attack" diff --git a/data/sandbox/actions.ruleset b/data/sandbox/actions.ruleset index 11fea4f7a7..7d1641d186 100644 --- a/data/sandbox/actions.ruleset +++ b/data/sandbox/actions.ruleset @@ -1555,6 +1555,10 @@ actor_reqs = "DiplRel", "War", "Local", TRUE "Building", "Treuga Dei", "World", FALSE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_from_native_despite_treuga_dei] action = "Collect Ransom" @@ -1567,29 +1571,41 @@ actor_reqs = "DiplRel", "War", "Local", TRUE, FALSE "Tech", "Communism", "World", TRUE, TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE - "Building", "Treuga Dei", "World", FALSE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + "Building", "Treuga Dei", "World", FALSE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_marines_despite_treuga_dei] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present", "survives" - "UnitFlag", "NonMil", "Local", FALSE, FALSE - "UnitClassFlag", "Missile", "Local", FALSE, FALSE - "MinMoveFrags", "1", "Local", TRUE, FALSE - "UnitFlag", "Marines", "Local", TRUE, FALSE - "DiplRel", "War", "Local", TRUE, FALSE - "Tech", "Communism", "World", TRUE, TRUE + { "type", "name", "range", "present", "survives" + "UnitFlag", "NonMil", "Local", FALSE, FALSE + "UnitClassFlag", "Missile", "Local", FALSE, FALSE + "MinMoveFrags", "1", "Local", TRUE, FALSE + "UnitFlag", "Marines", "Local", TRUE, FALSE + "DiplRel", "War", "Local", TRUE, FALSE + "Tech", "Communism", "World", TRUE, TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_att_from_non_native] @@ -1603,6 +1619,10 @@ actor_reqs = "DiplRel", "War", "Local", TRUE "Building", "Treuga Dei", "World", FALSE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_att_from_non_native_despite_treuga_dei] action = "Collect Ransom" @@ -1615,6 +1635,10 @@ actor_reqs = "DiplRel", "War", "Local", TRUE, FALSE "Tech", "Communism", "World", TRUE, TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_explode_missile] action = "Suicide Attack" diff --git a/data/webperimental/actions.ruleset b/data/webperimental/actions.ruleset index d02280c2a2..38f67fe82b 100644 --- a/data/webperimental/actions.ruleset +++ b/data/webperimental/actions.ruleset @@ -1117,16 +1117,24 @@ actor_reqs = "UnitState", "OnNativeTile", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_ransom_marines] action = "Collect Ransom" actor_reqs = - { "type", "name", "range", "present" - "UnitFlag", "NonMil", "Local", FALSE - "UnitClassFlag", "Missile", "Local", FALSE - "MinMoveFrags", "1", "Local", TRUE - "UnitFlag", "Marines", "Local", TRUE - "DiplRel", "War", "Local", TRUE + { "type", "name", "range", "present" + "UnitFlag", "NonMil", "Local", FALSE + "UnitClassFlag", "Missile", "Local", FALSE + "MinMoveFrags", "1", "Local", TRUE + "UnitFlag", "Marines", "Local", TRUE + "DiplRel", "War", "Local", TRUE + } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" } [actionenabler_ransom_att_from_non_native] @@ -1139,6 +1147,10 @@ actor_reqs = "UnitClassFlag", "AttFromNonNative", "Local", TRUE "DiplRel", "War", "Local", TRUE } +target_reqs = + { "type", "name", "range" + "PlayerState", "Barbarian", "Player" + } [actionenabler_explode_missile] action = "Suicide Attack" diff --git a/server/rscompat.c b/server/rscompat.c index 65c0943490..2c874c3ea5 100644 --- a/server/rscompat.c +++ b/server/rscompat.c @@ -298,6 +298,16 @@ void rscompat_enablers_add_obligatory_hard_reqs(void) action_iterate(act_id) { bool restart_enablers_for_action; + /* RSFORMAT_3_3 */ + if (action_has_result(action_by_number(act_id), ACTRES_COLLECT_RANSOM)) { + action_enabler_list_iterate(action_enablers_for_action(act_id), ae) { + requirement_vector_append(&ae->target_reqs, + req_from_str("PlayerState", "Player", + FALSE, TRUE, TRUE, + "Barbarian")); + } action_enabler_list_iterate_end; + } + do { restart_enablers_for_action = FALSE; action_enabler_list_iterate(action_enablers_for_action(act_id), ae) { @@ -314,6 +324,7 @@ void rscompat_enablers_add_obligatory_hard_reqs(void) } } action_enabler_list_iterate_end; } while (restart_enablers_for_action); + } action_iterate_end; } @@ -392,7 +403,7 @@ static bool effect_list_compat_cb(struct effect *peffect, void *data) **************************************************************************/ void rscompat_postprocess(struct rscompat_info *info) { - if (!info->compat_mode) { + if (!info->compat_mode || info->version >= RSFORMAT_CURRENT) { /* There isn't anything here that should be done outside of compat * mode. */ return; -- 2.42.0