Feature #253 ยป 0039-Move-action_result_legal_target_kind-to-actres.c.patch
common/actions.c | ||
---|---|---|
return NULL;
|
||
}
|
||
/**********************************************************************//**
|
||
Returns TRUE iff the specified action result works with the specified
|
||
action target kind.
|
||
**************************************************************************/
|
||
bool action_result_legal_target_kind(enum action_result result,
|
||
enum action_target_kind tgt_kind)
|
||
{
|
||
fc_assert_ret_val(action_result_is_valid(result) || result == ACTRES_NONE,
|
||
FALSE);
|
||
fc_assert_ret_val(action_target_kind_is_valid(tgt_kind),
|
||
FALSE);
|
||
switch (result) {
|
||
case ACTRES_ESTABLISH_EMBASSY:
|
||
case ACTRES_SPY_INVESTIGATE_CITY:
|
||
case ACTRES_SPY_POISON:
|
||
case ACTRES_SPY_STEAL_GOLD:
|
||
case ACTRES_SPY_SABOTAGE_CITY:
|
||
case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
|
||
case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
|
||
case ACTRES_SPY_STEAL_TECH:
|
||
case ACTRES_SPY_TARGETED_STEAL_TECH:
|
||
case ACTRES_SPY_INCITE_CITY:
|
||
case ACTRES_TRADE_ROUTE:
|
||
case ACTRES_MARKETPLACE:
|
||
case ACTRES_HELP_WONDER:
|
||
case ACTRES_JOIN_CITY:
|
||
case ACTRES_STEAL_MAPS:
|
||
case ACTRES_SPY_NUKE:
|
||
case ACTRES_DESTROY_CITY:
|
||
case ACTRES_DISBAND_UNIT_RECOVER:
|
||
case ACTRES_HOME_CITY:
|
||
case ACTRES_UPGRADE_UNIT:
|
||
case ACTRES_AIRLIFT:
|
||
case ACTRES_STRIKE_BUILDING:
|
||
case ACTRES_STRIKE_PRODUCTION:
|
||
case ACTRES_CONQUER_CITY:
|
||
case ACTRES_SPY_SPREAD_PLAGUE:
|
||
case ACTRES_SPY_ESCAPE:
|
||
return tgt_kind == ATK_CITY;
|
||
case ACTRES_SPY_BRIBE_UNIT:
|
||
case ACTRES_SPY_SABOTAGE_UNIT:
|
||
case ACTRES_EXPEL_UNIT:
|
||
case ACTRES_HEAL_UNIT:
|
||
case ACTRES_TRANSPORT_DEBOARD:
|
||
case ACTRES_TRANSPORT_UNLOAD:
|
||
case ACTRES_TRANSPORT_LOAD:
|
||
case ACTRES_TRANSPORT_BOARD:
|
||
case ACTRES_TRANSPORT_EMBARK:
|
||
return tgt_kind == ATK_UNIT;
|
||
case ACTRES_CAPTURE_UNITS:
|
||
case ACTRES_BOMBARD:
|
||
case ACTRES_NUKE_UNITS:
|
||
case ACTRES_ATTACK:
|
||
case ACTRES_WIPE_UNITS:
|
||
case ACTRES_SPY_ATTACK:
|
||
case ACTRES_COLLECT_RANSOM:
|
||
return tgt_kind == ATK_UNITS;
|
||
case ACTRES_FOUND_CITY:
|
||
case ACTRES_PARADROP:
|
||
case ACTRES_PARADROP_CONQUER:
|
||
case ACTRES_TRANSFORM_TERRAIN:
|
||
case ACTRES_CULTIVATE:
|
||
case ACTRES_PLANT:
|
||
case ACTRES_CLEAN:
|
||
case ACTRES_ROAD:
|
||
case ACTRES_BASE:
|
||
case ACTRES_MINE:
|
||
case ACTRES_IRRIGATE:
|
||
case ACTRES_TRANSPORT_DISEMBARK:
|
||
case ACTRES_HUT_ENTER:
|
||
case ACTRES_HUT_FRIGHTEN:
|
||
case ACTRES_UNIT_MOVE:
|
||
case ACTRES_TELEPORT:
|
||
case ACTRES_TELEPORT_CONQUER:
|
||
return tgt_kind == ATK_TILE;
|
||
case ACTRES_CONQUER_EXTRAS:
|
||
return tgt_kind == ATK_EXTRAS;
|
||
case ACTRES_DISBAND_UNIT:
|
||
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);
|
||
case ACTRES_NUKE:
|
||
return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
|
||
case ACTRES_NONE:
|
||
switch (tgt_kind) {
|
||
case ATK_CITY:
|
||
case ATK_UNIT:
|
||
case ATK_UNITS:
|
||
case ATK_TILE:
|
||
case ATK_EXTRAS:
|
||
case ATK_SELF:
|
||
/* Works with all existing target kinds. */
|
||
return TRUE;
|
||
case ATK_COUNT:
|
||
fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
|
||
break;
|
||
}
|
||
break;
|
||
ASSERT_UNUSED_ACTRES_CASES;
|
||
}
|
||
/* Should never be reached. */
|
||
return FALSE;
|
||
}
|
||
/**********************************************************************//**
|
||
Return actor consuming always ruleset variable name for the action or
|
||
NULL if actor consuming always can't be set in the ruleset.
|
common/actions.h | ||
---|---|---|
const char *action_max_range_ruleset_var_name(int act);
|
||
const char *action_target_kind_ruleset_var_name(int act);
|
||
bool action_result_legal_target_kind(enum action_result result,
|
||
enum action_target_kind tgt_kind);
|
||
const char *action_target_kind_help(enum action_target_kind kind);
|
||
const char *action_actor_consuming_always_ruleset_var_name(action_id act);
|
common/actres.c | ||
---|---|---|
return 0;
|
||
}
|
||
/**********************************************************************//**
|
||
Returns TRUE iff the specified action result works with the specified
|
||
action target kind.
|
||
**************************************************************************/
|
||
bool actres_legal_target_kind(enum action_result result,
|
||
enum action_target_kind tgt_kind)
|
||
{
|
||
fc_assert_ret_val(action_result_is_valid(result) || result == ACTRES_NONE,
|
||
FALSE);
|
||
fc_assert_ret_val(action_target_kind_is_valid(tgt_kind),
|
||
FALSE);
|
||
switch (result) {
|
||
case ACTRES_ESTABLISH_EMBASSY:
|
||
case ACTRES_SPY_INVESTIGATE_CITY:
|
||
case ACTRES_SPY_POISON:
|
||
case ACTRES_SPY_STEAL_GOLD:
|
||
case ACTRES_SPY_SABOTAGE_CITY:
|
||
case ACTRES_SPY_TARGETED_SABOTAGE_CITY:
|
||
case ACTRES_SPY_SABOTAGE_CITY_PRODUCTION:
|
||
case ACTRES_SPY_STEAL_TECH:
|
||
case ACTRES_SPY_TARGETED_STEAL_TECH:
|
||
case ACTRES_SPY_INCITE_CITY:
|
||
case ACTRES_TRADE_ROUTE:
|
||
case ACTRES_MARKETPLACE:
|
||
case ACTRES_HELP_WONDER:
|
||
case ACTRES_JOIN_CITY:
|
||
case ACTRES_STEAL_MAPS:
|
||
case ACTRES_SPY_NUKE:
|
||
case ACTRES_DESTROY_CITY:
|
||
case ACTRES_DISBAND_UNIT_RECOVER:
|
||
case ACTRES_HOME_CITY:
|
||
case ACTRES_UPGRADE_UNIT:
|
||
case ACTRES_AIRLIFT:
|
||
case ACTRES_STRIKE_BUILDING:
|
||
case ACTRES_STRIKE_PRODUCTION:
|
||
case ACTRES_CONQUER_CITY:
|
||
case ACTRES_SPY_SPREAD_PLAGUE:
|
||
case ACTRES_SPY_ESCAPE:
|
||
return tgt_kind == ATK_CITY;
|
||
case ACTRES_SPY_BRIBE_UNIT:
|
||
case ACTRES_SPY_SABOTAGE_UNIT:
|
||
case ACTRES_EXPEL_UNIT:
|
||
case ACTRES_HEAL_UNIT:
|
||
case ACTRES_TRANSPORT_DEBOARD:
|
||
case ACTRES_TRANSPORT_UNLOAD:
|
||
case ACTRES_TRANSPORT_LOAD:
|
||
case ACTRES_TRANSPORT_BOARD:
|
||
case ACTRES_TRANSPORT_EMBARK:
|
||
return tgt_kind == ATK_UNIT;
|
||
case ACTRES_CAPTURE_UNITS:
|
||
case ACTRES_BOMBARD:
|
||
case ACTRES_NUKE_UNITS:
|
||
case ACTRES_ATTACK:
|
||
case ACTRES_WIPE_UNITS:
|
||
case ACTRES_SPY_ATTACK:
|
||
case ACTRES_COLLECT_RANSOM:
|
||
return tgt_kind == ATK_UNITS;
|
||
case ACTRES_FOUND_CITY:
|
||
case ACTRES_PARADROP:
|
||
case ACTRES_PARADROP_CONQUER:
|
||
case ACTRES_TRANSFORM_TERRAIN:
|
||
case ACTRES_CULTIVATE:
|
||
case ACTRES_PLANT:
|
||
case ACTRES_CLEAN:
|
||
case ACTRES_ROAD:
|
||
case ACTRES_BASE:
|
||
case ACTRES_MINE:
|
||
case ACTRES_IRRIGATE:
|
||
case ACTRES_TRANSPORT_DISEMBARK:
|
||
case ACTRES_HUT_ENTER:
|
||
case ACTRES_HUT_FRIGHTEN:
|
||
case ACTRES_UNIT_MOVE:
|
||
case ACTRES_TELEPORT:
|
||
case ACTRES_TELEPORT_CONQUER:
|
||
return tgt_kind == ATK_TILE;
|
||
case ACTRES_CONQUER_EXTRAS:
|
||
return tgt_kind == ATK_EXTRAS;
|
||
case ACTRES_DISBAND_UNIT:
|
||
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);
|
||
case ACTRES_NUKE:
|
||
return (tgt_kind == ATK_TILE || tgt_kind == ATK_CITY);
|
||
case ACTRES_NONE:
|
||
switch (tgt_kind) {
|
||
case ATK_CITY:
|
||
case ATK_UNIT:
|
||
case ATK_UNITS:
|
||
case ATK_TILE:
|
||
case ATK_EXTRAS:
|
||
case ATK_SELF:
|
||
/* Works with all existing target kinds. */
|
||
return TRUE;
|
||
case ATK_COUNT:
|
||
fc_assert_ret_val(tgt_kind != ATK_COUNT, FALSE);
|
||
break;
|
||
}
|
||
break;
|
||
ASSERT_UNUSED_ACTRES_CASES;
|
||
}
|
||
/* Should never be reached. */
|
||
return FALSE;
|
||
}
|
||
/**********************************************************************//**
|
||
Return default sub target kind for the action with the specified result.
|
||
**************************************************************************/
|
common/actres.h | ||
---|---|---|
int actres_min_range_default(enum action_result result);
|
||
int actres_max_range_default(enum action_result result);
|
||
bool actres_legal_target_kind(enum action_result result,
|
||
enum action_target_kind tgt_kind);
|
||
enum action_target_kind
|
||
actres_target_kind_default(enum action_result result);
|
||
enum action_sub_target_kind
|
server/ruleset/rssanity.c | ||
---|---|---|
action_iterate(act) {
|
||
struct action *paction = action_by_number(act);
|
||
if (!action_result_legal_target_kind(paction->result,
|
||
paction->target_kind)) {
|
||
if (!actres_legal_target_kind(paction->result, paction->target_kind)) {
|
||
ruleset_error(logger, LOG_ERROR, "Action \"%s\": unsupported target kind %s.",
|
||
action_id_rule_name(act),
|
||
action_target_kind_name(paction->target_kind));
|