Project

General

Profile

Feature #115 ยป 0022-Move-action_-min-max-_range_default-to-actres.c-as-a.patch

Marko Lindqvist, 01/02/2024 11:49 PM

View differences:

common/actions.c
return NULL;
}
/**********************************************************************//**
Return default min range for the action if it is ruleset settable.
**************************************************************************/
int action_min_range_default(enum action_result result)
{
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_SPY_BRIBE_UNIT:
case ACTRES_SPY_SABOTAGE_UNIT:
case ACTRES_CAPTURE_UNITS:
case ACTRES_FOUND_CITY:
case ACTRES_JOIN_CITY:
case ACTRES_STEAL_MAPS:
case ACTRES_BOMBARD:
case ACTRES_SPY_NUKE:
case ACTRES_DESTROY_CITY:
case ACTRES_EXPEL_UNIT:
case ACTRES_DISBAND_UNIT_RECOVER:
case ACTRES_DISBAND_UNIT:
case ACTRES_HOME_CITY:
case ACTRES_HOMELESS:
case ACTRES_UPGRADE_UNIT:
case ACTRES_PARADROP:
case ACTRES_PARADROP_CONQUER:
case ACTRES_AIRLIFT:
case ACTRES_STRIKE_BUILDING:
case ACTRES_STRIKE_PRODUCTION:
case ACTRES_ATTACK:
case ACTRES_WIPE_UNITS:
case ACTRES_COLLECT_RANSOM:
case ACTRES_CONQUER_CITY:
case ACTRES_HEAL_UNIT:
case ACTRES_TRANSFORM_TERRAIN:
case ACTRES_CULTIVATE:
case ACTRES_PLANT:
case ACTRES_PILLAGE:
case ACTRES_CLEAN:
case ACTRES_FORTIFY:
case ACTRES_ROAD:
case ACTRES_CONVERT:
case ACTRES_BASE:
case ACTRES_MINE:
case ACTRES_IRRIGATE:
case ACTRES_TRANSPORT_DEBOARD:
case ACTRES_TRANSPORT_UNLOAD:
case ACTRES_TRANSPORT_LOAD:
case ACTRES_TRANSPORT_DISEMBARK:
case ACTRES_TRANSPORT_BOARD:
case ACTRES_TRANSPORT_EMBARK:
case ACTRES_SPY_ATTACK:
case ACTRES_SPY_SPREAD_PLAGUE:
case ACTRES_CONQUER_EXTRAS:
case ACTRES_HUT_ENTER:
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;
case ACTRES_NUKE:
case ACTRES_NUKE_UNITS:
return RS_DEFAULT_ACTION_MIN_RANGE;
case ACTRES_TELEPORT:
case ACTRES_TELEPORT_CONQUER:
return RS_DEFAULT_MOVE_MIN_RANGE;
case ACTRES_NONE:
return RS_DEFAULT_ACTION_MIN_RANGE;
ASSERT_UNUSED_ACTRES_CASES;
}
fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
return 0;
}
/**********************************************************************//**
Return max range ruleset variable name for the action or NULL if max
range can't be set in the ruleset.
......
return NULL;
}
/**********************************************************************//**
Return default max range for the action if it is ruleset settable.
**************************************************************************/
int action_max_range_default(enum action_result result)
{
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_SPY_BRIBE_UNIT:
case ACTRES_SPY_SABOTAGE_UNIT:
case ACTRES_CAPTURE_UNITS:
case ACTRES_FOUND_CITY:
case ACTRES_JOIN_CITY:
case ACTRES_STEAL_MAPS:
case ACTRES_SPY_NUKE:
case ACTRES_DESTROY_CITY:
case ACTRES_EXPEL_UNIT:
case ACTRES_DISBAND_UNIT:
case ACTRES_HOME_CITY:
case ACTRES_HOMELESS:
case ACTRES_UPGRADE_UNIT:
case ACTRES_PARADROP:
case ACTRES_PARADROP_CONQUER:
case ACTRES_STRIKE_BUILDING:
case ACTRES_STRIKE_PRODUCTION:
case ACTRES_ATTACK:
case ACTRES_WIPE_UNITS:
case ACTRES_COLLECT_RANSOM:
case ACTRES_CONQUER_CITY:
case ACTRES_HEAL_UNIT:
case ACTRES_TRANSFORM_TERRAIN:
case ACTRES_CULTIVATE:
case ACTRES_PLANT:
case ACTRES_PILLAGE:
case ACTRES_CLEAN:
case ACTRES_FORTIFY:
case ACTRES_ROAD:
case ACTRES_CONVERT:
case ACTRES_BASE:
case ACTRES_MINE:
case ACTRES_IRRIGATE:
case ACTRES_TRANSPORT_DEBOARD:
case ACTRES_TRANSPORT_UNLOAD:
case ACTRES_TRANSPORT_LOAD:
case ACTRES_TRANSPORT_DISEMBARK:
case ACTRES_TRANSPORT_BOARD:
case ACTRES_TRANSPORT_EMBARK:
case ACTRES_SPY_ATTACK:
case ACTRES_SPY_SPREAD_PLAGUE:
case ACTRES_CONQUER_EXTRAS:
case ACTRES_HUT_ENTER:
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;
case ACTRES_HELP_WONDER:
case ACTRES_DISBAND_UNIT_RECOVER:
return RS_DEFAULT_ACTION_MAX_RANGE;
case ACTRES_BOMBARD:
return RS_DEFAULT_ACTION_MAX_RANGE;
case ACTRES_NUKE:
return RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE;
case ACTRES_NUKE_UNITS:
return RS_DEFAULT_ACTION_MAX_RANGE;
case ACTRES_AIRLIFT:
case ACTRES_TELEPORT:
case ACTRES_TELEPORT_CONQUER:
return ACTION_DISTANCE_UNLIMITED;
case ACTRES_NONE:
return RS_DEFAULT_ACTION_MAX_RANGE;
ASSERT_UNUSED_ACTRES_CASES;
}
fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
return 0;
}
/**********************************************************************//**
Return target kind ruleset variable name for the action or NULL if
target kind can't be set in the ruleset.
common/actions.h
const char *action_ui_name_default(int act);
const char *action_min_range_ruleset_var_name(int act);
int action_min_range_default(enum action_result result);
const char *action_max_range_ruleset_var_name(int act);
int action_max_range_default(enum action_result result);
const char *action_target_kind_ruleset_var_name(int act);
enum action_target_kind
common/actres.c
return act_results[result].dice;
}
/**********************************************************************//**
Return default min range for the action if it is ruleset settable.
**************************************************************************/
int actres_min_range_default(enum action_result result)
{
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_SPY_BRIBE_UNIT:
case ACTRES_SPY_SABOTAGE_UNIT:
case ACTRES_CAPTURE_UNITS:
case ACTRES_FOUND_CITY:
case ACTRES_JOIN_CITY:
case ACTRES_STEAL_MAPS:
case ACTRES_BOMBARD:
case ACTRES_SPY_NUKE:
case ACTRES_DESTROY_CITY:
case ACTRES_EXPEL_UNIT:
case ACTRES_DISBAND_UNIT_RECOVER:
case ACTRES_DISBAND_UNIT:
case ACTRES_HOME_CITY:
case ACTRES_HOMELESS:
case ACTRES_UPGRADE_UNIT:
case ACTRES_PARADROP:
case ACTRES_PARADROP_CONQUER:
case ACTRES_AIRLIFT:
case ACTRES_STRIKE_BUILDING:
case ACTRES_STRIKE_PRODUCTION:
case ACTRES_ATTACK:
case ACTRES_WIPE_UNITS:
case ACTRES_COLLECT_RANSOM:
case ACTRES_CONQUER_CITY:
case ACTRES_HEAL_UNIT:
case ACTRES_TRANSFORM_TERRAIN:
case ACTRES_CULTIVATE:
case ACTRES_PLANT:
case ACTRES_PILLAGE:
case ACTRES_CLEAN:
case ACTRES_FORTIFY:
case ACTRES_ROAD:
case ACTRES_CONVERT:
case ACTRES_BASE:
case ACTRES_MINE:
case ACTRES_IRRIGATE:
case ACTRES_TRANSPORT_DEBOARD:
case ACTRES_TRANSPORT_UNLOAD:
case ACTRES_TRANSPORT_LOAD:
case ACTRES_TRANSPORT_DISEMBARK:
case ACTRES_TRANSPORT_BOARD:
case ACTRES_TRANSPORT_EMBARK:
case ACTRES_SPY_ATTACK:
case ACTRES_SPY_SPREAD_PLAGUE:
case ACTRES_CONQUER_EXTRAS:
case ACTRES_HUT_ENTER:
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;
case ACTRES_NUKE:
case ACTRES_NUKE_UNITS:
return RS_DEFAULT_ACTION_MIN_RANGE;
case ACTRES_TELEPORT:
case ACTRES_TELEPORT_CONQUER:
return RS_DEFAULT_MOVE_MIN_RANGE;
case ACTRES_NONE:
return RS_DEFAULT_ACTION_MIN_RANGE;
ASSERT_UNUSED_ACTRES_CASES;
}
fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
return 0;
}
/**********************************************************************//**
Return default max range for the action if it is ruleset settable.
**************************************************************************/
int actres_max_range_default(enum action_result result)
{
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_SPY_BRIBE_UNIT:
case ACTRES_SPY_SABOTAGE_UNIT:
case ACTRES_CAPTURE_UNITS:
case ACTRES_FOUND_CITY:
case ACTRES_JOIN_CITY:
case ACTRES_STEAL_MAPS:
case ACTRES_SPY_NUKE:
case ACTRES_DESTROY_CITY:
case ACTRES_EXPEL_UNIT:
case ACTRES_DISBAND_UNIT:
case ACTRES_HOME_CITY:
case ACTRES_HOMELESS:
case ACTRES_UPGRADE_UNIT:
case ACTRES_PARADROP:
case ACTRES_PARADROP_CONQUER:
case ACTRES_STRIKE_BUILDING:
case ACTRES_STRIKE_PRODUCTION:
case ACTRES_ATTACK:
case ACTRES_WIPE_UNITS:
case ACTRES_COLLECT_RANSOM:
case ACTRES_CONQUER_CITY:
case ACTRES_HEAL_UNIT:
case ACTRES_TRANSFORM_TERRAIN:
case ACTRES_CULTIVATE:
case ACTRES_PLANT:
case ACTRES_PILLAGE:
case ACTRES_CLEAN:
case ACTRES_FORTIFY:
case ACTRES_ROAD:
case ACTRES_CONVERT:
case ACTRES_BASE:
case ACTRES_MINE:
case ACTRES_IRRIGATE:
case ACTRES_TRANSPORT_DEBOARD:
case ACTRES_TRANSPORT_UNLOAD:
case ACTRES_TRANSPORT_LOAD:
case ACTRES_TRANSPORT_DISEMBARK:
case ACTRES_TRANSPORT_BOARD:
case ACTRES_TRANSPORT_EMBARK:
case ACTRES_SPY_ATTACK:
case ACTRES_SPY_SPREAD_PLAGUE:
case ACTRES_CONQUER_EXTRAS:
case ACTRES_HUT_ENTER:
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;
case ACTRES_HELP_WONDER:
case ACTRES_DISBAND_UNIT_RECOVER:
return RS_DEFAULT_ACTION_MAX_RANGE;
case ACTRES_BOMBARD:
return RS_DEFAULT_ACTION_MAX_RANGE;
case ACTRES_NUKE:
return RS_DEFAULT_EXPLODE_NUCLEAR_MAX_RANGE;
case ACTRES_NUKE_UNITS:
return RS_DEFAULT_ACTION_MAX_RANGE;
case ACTRES_AIRLIFT:
case ACTRES_TELEPORT:
case ACTRES_TELEPORT_CONQUER:
return ACTION_DISTANCE_UNLIMITED;
case ACTRES_NONE:
return RS_DEFAULT_ACTION_MAX_RANGE;
ASSERT_UNUSED_ACTRES_CASES;
}
fc_assert(action_result_is_valid(result) || result == ACTRES_NONE);
return 0;
}
/**********************************************************************//**
Does action with the result create the extra
common/actres.h
bool omniscient,
const struct city *homecity);
int actres_min_range_default(enum action_result result);
int actres_max_range_default(enum action_result result);
#ifdef __cplusplus
}
#endif /* __cplusplus */
server/ruleset/ruleload.c
pentry = secfile_entry_lookup(file, "actions.%s", vname);
if (pentry == NULL) {
max_range = action_max_range_default(paction->result);
max_range = actres_max_range_default(paction->result);
} else {
const char *custom;
......
} else {
ruleset_error(NULL, LOG_ERROR, "Bad actions.%s",
action_max_range_ruleset_var_name(act));
action_by_number(act)->max_distance = action_max_range_default(paction->result);
action_by_number(act)->max_distance = actres_max_range_default(paction->result);
return FALSE;
}
......
/* Min range can be loaded from the ruleset. */
action_by_number(act)->min_distance
= secfile_lookup_int_default(file,
action_min_range_default(paction->result),
actres_min_range_default(paction->result),
"actions.%s",
vname);
}
tools/ruleutil/rulesave.c
action_max_range_ruleset_var_name(act)) != NULL;
} else {
return save_default_int(sfile, action_by_number(act)->max_distance,
action_max_range_default(paction->result),
actres_max_range_default(paction->result),
"actions",
action_max_range_ruleset_var_name(act));
}
......
/* Min range can be loaded from the ruleset. */
save_default_int(sfile,
paction->min_distance,
action_min_range_default(paction->result),
actres_min_range_default(paction->result),
"actions",
action_min_range_ruleset_var_name(act));
}
    (1-1/1)