From b8b67a01fc57b825e41a567b7c9317e3f43029c6 Mon Sep 17 00:00:00 2001 From: Marko Lindqvist <cazfi74@gmail.com> Date: Sat, 1 Apr 2023 12:54:03 +0300 Subject: [PATCH 29/29] Add ACTRES_ENABLER_CHECK Result type to indicate actions that are not to be initiated by the user. No actions using yet, nor would actions API work correctly in respect to it. See osdn #47734 Signed-off-by: Marko Lindqvist <cazfi74@gmail.com> --- ai/default/daicity.c | 1 + ai/default/daidiplomacy.c | 1 + common/actions.c | 15 +++++++++++++++ common/actres.c | 2 ++ common/fc_types.h | 2 ++ server/advisors/advdata.c | 1 + server/unithand.c | 4 ++++ 7 files changed, 26 insertions(+) diff --git a/ai/default/daicity.c b/ai/default/daicity.c index 1f086a8315..c698efc70a 100644 --- a/ai/default/daicity.c +++ b/ai/default/daicity.c @@ -1311,6 +1311,7 @@ static int action_target_neg_util(action_id act_id, case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: case ACTRES_HOMELESS: + case ACTRES_ENABLER_CHECK: fc_assert_msg(action_id_get_target_kind(act_id) == ATK_CITY, "Action not aimed at cities"); } diff --git a/ai/default/daidiplomacy.c b/ai/default/daidiplomacy.c index be7bbee43a..3fb69a783d 100644 --- a/ai/default/daidiplomacy.c +++ b/ai/default/daidiplomacy.c @@ -2056,6 +2056,7 @@ void dai_incident(struct ai_type *ait, enum incident_type type, case ACTRES_TRANSPORT_EMBARK: case ACTRES_HUT_ENTER: case ACTRES_HUT_FRIGHTEN: + case ACTRES_ENABLER_CHECK: case ACTRES_NONE: /* Various */ dai_incident_simple(receiver, violator, victim, scope, 1); diff --git a/common/actions.c b/common/actions.c index 1f991b92ee..8f506da0a2 100644 --- a/common/actions.c +++ b/common/actions.c @@ -2283,6 +2283,7 @@ bool action_creates_extra(const struct action *paction, case ACTRES_HUT_FRIGHTEN: case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_NONE: break; } @@ -2374,6 +2375,7 @@ bool action_removes_extra(const struct action *paction, case ACTRES_SPY_SPREAD_PLAGUE: case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_NONE: break; } @@ -3494,6 +3496,7 @@ action_actor_utype_hard_reqs_ok_full(const struct action *paction, case ACTRES_SPY_ATTACK: case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_NONE: /* No hard unit type requirements. */ break; @@ -3689,6 +3692,7 @@ action_hard_reqs_actor(const struct action *paction, case ACTRES_SPY_ATTACK: case ACTRES_HUT_ENTER: case ACTRES_HUT_FRIGHTEN: + case ACTRES_ENABLER_CHECK: case ACTRES_NONE: /* No hard unit requirements. */ break; @@ -4717,6 +4721,7 @@ is_action_possible(const action_id wanted_action, case ACTRES_STRIKE_PRODUCTION: case ACTRES_FORTIFY: case ACTRES_HOMELESS: + case ACTRES_ENABLER_CHECK: case ACTRES_NONE: /* No known hard coded requirements. */ break; @@ -5855,6 +5860,10 @@ action_prob(const action_id wanted_action, case ACTRES_TELEPORT: chance = ACTPROB_CERTAIN; break; + /* Not UI action, so chance is meaningless */ + case ACTRES_ENABLER_CHECK: + chance = ACTPROB_CERTAIN; + break; case ACTRES_NONE: /* Accommodate ruleset authors that wishes to roll the dice in Lua. * Would be ACTPROB_CERTAIN if not for that. */ @@ -7149,6 +7158,7 @@ int action_dice_roll_initial_odds(const struct action *paction) case ACTRES_HUT_FRIGHTEN: case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_SPY_ESCAPE: case ACTRES_NONE: /* No additional dice roll. */ @@ -8324,6 +8334,7 @@ int action_min_range_default(enum action_result result) case ACTRES_HUT_FRIGHTEN: case ACTRES_UNIT_MOVE: case ACTRES_SPY_ESCAPE: + case ACTRES_ENABLER_CHECK: /* Non ruleset defined action min range not supported here */ fc_assert_msg(FALSE, "Probably wrong value."); return RS_DEFAULT_ACTION_MIN_RANGE; @@ -8556,6 +8567,7 @@ int action_max_range_default(enum action_result result) case ACTRES_HUT_FRIGHTEN: case ACTRES_UNIT_MOVE: case ACTRES_SPY_ESCAPE: + case ACTRES_ENABLER_CHECK: /* Non ruleset defined action max range not supported here */ fc_assert_msg(FALSE, "Probably wrong value."); return RS_DEFAULT_ACTION_MAX_RANGE; @@ -8804,6 +8816,7 @@ action_target_kind_default(enum action_result result) case ACTRES_CONVERT: case ACTRES_FORTIFY: case ACTRES_HOMELESS: + case ACTRES_ENABLER_CHECK: return ATK_SELF; case ACTRES_NONE: return RS_DEFAULT_USER_ACTION_TARGET_KIND; @@ -8895,6 +8908,7 @@ bool action_result_legal_target_kind(enum action_result result, case ACTRES_CONVERT: case ACTRES_FORTIFY: case ACTRES_HOMELESS: + case ACTRES_ENABLER_CHECK: return tgt_kind == ATK_SELF; case ACTRES_PILLAGE: return (tgt_kind == ATK_TILE || tgt_kind == ATK_EXTRAS); @@ -8989,6 +9003,7 @@ action_sub_target_kind_default(enum action_result result) case ACTRES_HUT_FRIGHTEN: case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_SPY_ESCAPE: return ASTK_NONE; case ACTRES_PILLAGE: diff --git a/common/actres.c b/common/actres.c index 5607a95a31..ec383b6037 100644 --- a/common/actres.c +++ b/common/actres.c @@ -149,6 +149,8 @@ static struct actres act_results[ACTRES_LAST] = { { ACT_TGT_COMPL_FLEXIBLE, ABK_NONE, /* ACTRES_CLEAN */ FALSE }, { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_TELEPORT */ + FALSE }, + { ACT_TGT_COMPL_SIMPLE, ABK_NONE, /* ACTRES_ENABLER_CHECK */ FALSE } }; diff --git a/common/fc_types.h b/common/fc_types.h index 39c9c83ce0..ba8a3ceac2 100644 --- a/common/fc_types.h +++ b/common/fc_types.h @@ -324,6 +324,8 @@ enum counter_target { CTGT_CITY }; /* TODO: Move close to "Move" */ #define SPECENUM_VALUE65 ACTRES_TELEPORT #define SPECENUM_VALUE65NAME "Teleport" +/* Hardcoded action that's just controlled by enablers */ +#define SPECENUM_VALUE66 ACTRES_ENABLER_CHECK /* All consequences are handled as (ruleset) action data. */ #define SPECENUM_COUNT ACTRES_LAST #include "specenum_gen.h" diff --git a/server/advisors/advdata.c b/server/advisors/advdata.c index d350c7bb5b..d546f5a208 100644 --- a/server/advisors/advdata.c +++ b/server/advisors/advdata.c @@ -887,6 +887,7 @@ adv_want adv_gov_action_immunity_want(struct government *gov) case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_MARKETPLACE: case ACTRES_FOUND_CITY: case ACTRES_DISBAND_UNIT: diff --git a/server/unithand.c b/server/unithand.c index cf91c13e22..80b39a2420 100644 --- a/server/unithand.c +++ b/server/unithand.c @@ -1177,6 +1177,7 @@ static struct player *need_war_player_hlp(const struct unit *actor, case ACTRES_HUT_FRIGHTEN: case ACTRES_UNIT_MOVE: case ACTRES_TELEPORT: + case ACTRES_ENABLER_CHECK: case ACTRES_SPY_ESCAPE: case ACTRES_NONE: /* No special help. */ @@ -3968,6 +3969,9 @@ bool unit_perform_action(struct player *pplayer, ACTION_PERFORM_UNIT_ANY(paction, actor_unit, pcity, punit, target_tile, TRUE); break; + case ACTRES_ENABLER_CHECK: + fc_assert(paction->result != ACTRES_ENABLER_CHECK); + return FALSE; } /* Something must have gone wrong. */ -- 2.39.2