Freeciv21
Develop your civilization from humble roots to a global empire
actions.cpp File Reference
#include <cmath>
#include <cstdarg>
#include "fcintl.h"
#include "actions.h"
#include "city.h"
#include "combat.h"
#include "fc_interface.h"
#include "game.h"
#include "map.h"
#include "movement.h"
#include "nation.h"
#include "research.h"
#include "server_settings.h"
#include "tile.h"
#include "unit.h"
#include "specvec.h"
+ Include dependency graph for actions.cpp:

Go to the source code of this file.

Classes

struct  action_enabler_contradiction
 
struct  ae_contra_or
 
struct  obligatory_req
 

Macros

#define SPECVEC_TAG   obligatory_req
 
#define SPECVEC_TYPE   struct obligatory_req
 
#define obligatory_req_vector_iterate(obreq_vec, pobreq)    TYPED_VECTOR_ITERATE(struct obligatory_req, obreq_vec, pobreq)
 
#define obligatory_req_vector_iterate_end   VECTOR_ITERATE_END
 
#define ACTPROB_VAL_MIN   0
 
#define ACTPROB_VAL_MAX   200
 
#define ACTPROB_VAL_1_PCT   (ACTPROB_VAL_MAX / 100)
 
#define ACTPROB_VAL_NA   253
 
#define ACTPROB_VAL_NOT_IMPL   254
 

Functions

static struct actionunit_action_new (action_id id, enum action_result result, enum action_target_kind target_kind, enum action_sub_target_kind sub_target_kind, enum act_tgt_compl tgt_compl, bool rare_pop_up, bool unitwaittime_controlled, enum moves_actor_kind moves_actor, const int min_distance, const int max_distance, bool actor_consuming_always)
 Create a new action performed by a unit actor. More...
 
static bool is_enabler_active (const struct action_enabler *enabler, const struct player *actor_player, const struct city *actor_city, const struct impr_type *actor_building, const struct tile *actor_tile, const struct unit *actor_unit, const struct unit_type *actor_unittype, const struct output_type *actor_output, const struct specialist *actor_specialist, const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist)
 Return TRUE iff the action enabler is active. More...
 
static bool action_prob_is_signal (const struct act_prob probability)
 Returns TRUE iff the given action probability represents a special signal value rather than a regular action probability value. More...
 
static bool action_prob_not_relevant (const struct act_prob probability)
 Returns TRUE iff the given action probability represents the lack of an action probability. More...
 
static bool action_prob_not_impl (const struct act_prob probability)
 Returns TRUE iff the given action probability represents that support for finding this action probability currently is missing from Freeciv. More...
 
 FC_STATIC_ASSERT (MAP_DISTANCE_MAX<=ACTION_DISTANCE_LAST_NON_SIGNAL, action_range_can_not_cover_the_whole_map)
 
static struct ae_contra_orreq_contradiction_or (int alternatives,...)
 Returns a new array of alternative action enabler contradictions. More...
 
static void ae_contra_close (struct ae_contra_or *contra)
 Tell an ae_contra_or that one of its users is done with it. More...
 
static void voblig_hard_req_reg (struct ae_contra_or *contras, const char *error_message, va_list args)
 Register an obligatory hard requirement for the specified action results. More...
 
static void oblig_hard_req_reg (struct ae_contra_or *contras, const char *error_message,...)
 Register an obligatory hard requirement for the specified action results. More...
 
static void oblig_hard_req_register (const struct requirement &contradiction, bool is_target, const char *error_message,...)
 Register an obligatory hard requirement for the action results it applies to. More...
 
static void hard_code_oblig_hard_reqs ()
 Hard code the obligatory hard requirements that don't depend on the rest of the ruleset. More...
 
static void hard_code_oblig_hard_reqs_ruleset ()
 Hard code the obligatory hard requirements that needs access to the ruleset before they can be generated. More...
 
static void hard_code_actions ()
 Hard code the actions. More...
 
void actions_init ()
 Initialize the actions and the action enablers. More...
 
void actions_rs_pre_san_gen ()
 Generate action related data based on the currently loaded ruleset. More...
 
void actions_free ()
 Free the actions and the action enablers. More...
 
bool actions_are_ready ()
 Returns TRUE iff the actions are initialized. More...
 
static struct actionaction_new (action_id id, enum action_result result, enum action_target_kind target_kind, enum action_sub_target_kind sub_target_kind, enum act_tgt_compl tgt_compl, const int min_distance, const int max_distance, bool actor_consuming_always)
 Create a new action. More...
 
bool action_id_exists (const action_id act_id)
 Returns TRUE iff the specified action ID refers to a valid action. More...
 
struct actionaction_by_number (action_id act_id)
 Return the action with the given id. More...
 
struct actionaction_by_rule_name (const char *name)
 Return the action with the given name. More...
 
enum action_actor_kind action_get_actor_kind (const struct action *paction)
 Get the actor kind of an action. More...
 
enum action_target_kind action_get_target_kind (const struct action *paction)
 Get the target kind of an action. More...
 
enum action_sub_target_kind action_get_sub_target_kind (const struct action *paction)
 Get the sub target kind of an action. More...
 
enum action_battle_kind action_get_battle_kind (const struct action *pact)
 Get the battle kind that can prevent an action. More...
 
bool action_has_result (const struct action *paction, enum action_result result)
 Returns TRUE iff performing the specified action has the specified result. More...
 
bool action_has_complex_target (const struct action *paction)
 Returns TRUE iff the specified action allows the player to provide details in addition to actor and target. More...
 
bool action_requires_details (const struct action *paction)
 Returns TRUE iff the specified action REQUIRES the player to provide details in addition to actor and target. More...
 
bool action_id_is_rare_pop_up (action_id act_id)
 Returns TRUE iff a unit's ability to perform this action will pop up the action selection dialog before the player asks for it only in exceptional cases. More...
 
bool action_distance_inside_max (const struct action *action, const int distance)
 Returns TRUE iff the specified distance between actor and target is sm,aller or equal to the max range accepted by the specified action. More...
 
bool action_distance_accepted (const struct action *action, const int distance)
 Returns TRUE iff the specified distance between actor and target is within the range acceptable to the specified action. More...
 
bool action_would_be_blocked_by (const struct action *blocked, const struct action *blocker)
 Returns TRUE iff blocked will be illegal if blocker is legal. More...
 
int action_number (const struct action *action)
 Get the universal number of the action. More...
 
const char * action_rule_name (const struct action *action)
 Get the rule name of the action. More...
 
const QString action_name_translation (const struct action *action)
 Get the action name used when displaying the action in the UI. More...
 
const char * action_id_rule_name (action_id act_id)
 Get the rule name of the action. More...
 
const QString action_id_name_translation (action_id act_id)
 Get the action name used when displaying the action in the UI. More...
 
static QString action_prob_to_text (const struct act_prob prob)
 Returns a text representation of the action probability prob unless it is a signal. More...
 
const QString action_prepare_ui_name (action_id act_id, const char *mnemonic, const struct act_prob prob, const QString &custom)
 Get the UI name ready to show the action in the UI. More...
 
const QString action_prob_explain (const struct act_prob prob)
 Explain an action probability in a way suitable for a tool tip for the button that starts it. More...
 
int action_get_role (const struct action *paction)
 Get the unit type role corresponding to the ability to do the specified action. More...
 
enum unit_activity action_get_activity (const struct action *paction)
 Returns the unit activity this action may cause or ACTIVITY_LAST if the action doesn't result in a unit activity. More...
 
int action_get_act_time (const struct action *paction, const struct unit *actor_unit, const struct tile *tgt_tile, const struct extra_type *tgt_extra)
 Returns the unit activity time (work) this action takes (requires) or ACT_TIME_INSTANTANEOUS if the action happens at once. More...
 
bool action_creates_extra (const struct action *paction, const struct extra_type *pextra)
 Returns TRUE iff the specified action can create the specified extra. More...
 
bool action_removes_extra (const struct action *paction, const struct extra_type *pextra)
 Returns TRUE iff the specified action can remove the specified extra. More...
 
struct action_enableraction_enabler_new ()
 Create a new action enabler. More...
 
void action_enabler_free (struct action_enabler *enabler)
 Free resources allocated for the action enabler. More...
 
struct action_enableraction_enabler_copy (const struct action_enabler *original)
 Create a new copy of an existing action enabler. More...
 
void action_enabler_add (struct action_enabler *enabler)
 Add an action enabler to the current ruleset. More...
 
bool action_enabler_remove (struct action_enabler *enabler)
 Remove an action enabler from the current ruleset. More...
 
struct action_enabler_list * action_enablers_for_action (action_id action)
 Get all enablers for an action in the current ruleset. More...
 
struct req_vec_problemaction_enabler_suggest_repair_oblig (const struct action_enabler *enabler)
 Returns a suggestion to add an obligatory hard requirement to an action enabler or nullptr if no hard obligatory reqs were missing. More...
 
static struct requirementreq_vec_first_local_diplrel (const struct requirement_vector *vec)
 Returns the first local DiplRel requirement in the specified requirement vector or nullptr if it doesn't have a local DiplRel requirement. More...
 
static struct requirementreq_vec_first_contradiction_in_vec (const struct requirement *req, const struct requirement_vector *vec)
 Returns the first requirement in the specified requirement vector that contradicts the specified requirement or nullptr if no contradiction was detected. More...
 
static struct req_vec_problemenabler_tile_tgt_local_diplrel_implies_claimed (const struct action_enabler *enabler)
 Detects a local DiplRel requirement in a tile targeted action without an explicit claimed requirement in the target reqs. More...
 
static struct req_vec_problemenabler_first_self_contradiction (const struct action_enabler *enabler)
 Returns the first action enabler specific contradiction in the specified enabler or nullptr if no enabler specific contradiction is found. More...
 
struct req_vec_problemaction_enabler_suggest_repair (const struct action_enabler *enabler)
 Returns a suggestion to fix the specified action enabler or nullptr if no fix is found to be needed. More...
 
static struct req_vec_problemenabler_first_clarification (const struct action_enabler *enabler)
 Returns the first action enabler specific clarification possibility in the specified enabler or nullptr if no enabler specific contradiction is found. More...
 
struct req_vec_problemaction_enabler_suggest_improvement (const struct action_enabler *enabler)
 Returns a suggestion to improve the specified action enabler or nullptr if nothing to improve is found to be needed. More...
 
req_vec_num_in_item action_enabler_vector_number (const void *enabler, const struct requirement_vector *vec)
 Returns the requirement vector number of the specified requirement vector in the specified action enabler. More...
 
struct requirement_vector * action_enabler_vector_by_number (const void *enabler, req_vec_num_in_item number)
 Returns a writable pointer to the specified requirement vector in the action enabler or nullptr if the action enabler doesn't have a requirement vector with that requirement vector number. More...
 
const char * action_enabler_vector_by_number_name (req_vec_num_in_item vec)
 Returns the name of the given requirement vector number n in an action enabler or nullptr if enablers don't have a requirement vector with that number. More...
 
static bool plr_knows_tile (const struct player *plr, const struct tile *ttile)
 Returns TRUE iff the specified player knows (has seen) the specified tile. More...
 
static bool plr_sees_tile (const struct player *plr, const struct tile *ttile)
 Returns TRUE iff the specified player can see the specified tile. More...
 
static const struct impr_typetgt_city_local_building (const struct city *target_city)
 Returns the local building type of a city target. More...
 
static const struct unit_typetgt_city_local_utype (const struct city *target_city)
 Returns the local unit type of a city target. More...
 
static const struct tileblocked_find_target_tile (const action_id act_id, const struct unit *actor_unit, const struct tile *target_tile_arg, const struct city *target_city, const struct unit *target_unit)
 Returns the target tile for actions that may block the specified action. More...
 
static const struct cityblocked_find_target_city (const action_id act_id, const struct unit *actor_unit, const struct tile *target_tile, const struct city *target_city_arg, const struct unit *target_unit)
 Returns the target city for actions that may block the specified action. More...
 
struct actionaction_is_blocked_by (const action_id act_id, const struct unit *actor_unit, const struct tile *target_tile_arg, const struct city *target_city_arg, const struct unit *target_unit)
 Returns the action that blocks the specified action or nullptr if the specified action isn't blocked. More...
 
static bool action_actor_utype_hard_reqs_ok_full (enum action_result result, const struct unit_type *actor_unittype, bool ignore_third_party)
 Returns TRUE if the specified unit type can perform an action with the wanted result given that an action enabler later will enable it. More...
 
bool action_actor_utype_hard_reqs_ok (enum action_result result, const struct unit_type *actor_unittype)
 Returns TRUE if the specified unit type can perform an action with the wanted result given that an action enabler later will enable it. More...
 
static enum fc_tristate action_hard_reqs_actor (enum action_result result, const struct player *actor_player, const struct city *actor_city, const struct impr_type *actor_building, const struct tile *actor_tile, const struct unit *actor_unit, const struct unit_type *actor_unittype, const struct output_type *actor_output, const struct specialist *actor_specialist, const bool omniscient, const struct city *homecity)
 Returns TRUE iff the wanted action is possible as far as the actor is concerned given that an action enabler later will enable it. More...
 
static enum fc_tristate is_action_possible (const action_id wanted_action, const struct player *actor_player, const struct city *actor_city, const struct impr_type *actor_building, const struct tile *actor_tile, const struct unit *actor_unit, const struct unit_type *actor_unittype, const struct output_type *actor_output, const struct specialist *actor_specialist, const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct extra_type *target_extra, const bool omniscient, const struct city *homecity)
 Returns if the wanted action is possible given that an action enabler later will enable it. More...
 
static bool is_action_enabled (const action_id wanted_action, const struct player *actor_player, const struct city *actor_city, const struct impr_type *actor_building, const struct tile *actor_tile, const struct unit *actor_unit, const struct unit_type *actor_unittype, const struct output_type *actor_output, const struct specialist *actor_specialist, const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct extra_type *target_extra, const struct city *actor_home)
 Returns TRUE if the wanted action is enabled. More...
 
static bool is_action_enabled_unit_on_city_full (const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct city *target_city)
 Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerned. More...
 
bool is_action_enabled_unit_on_city (const action_id wanted_action, const struct unit *actor_unit, const struct city *target_city)
 Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerned. More...
 
static bool is_action_enabled_unit_on_unit_full (const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct unit *target_unit)
 Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerned. More...
 
bool is_action_enabled_unit_on_unit (const action_id wanted_action, const struct unit *actor_unit, const struct unit *target_unit)
 Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerned. More...
 
static bool is_action_enabled_unit_on_units_full (const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct tile *target_tile)
 Returns TRUE if actor_unit can do wanted_action to all units on the target_tile as far as action enablers are concerned. More...
 
bool is_action_enabled_unit_on_units (const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile)
 Returns TRUE if actor_unit can do wanted_action to all units on the target_tile as far as action enablers are concerned. More...
 
static bool is_action_enabled_unit_on_tile_full (const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const struct tile *target_tile, const struct extra_type *target_extra)
 Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are concerned. More...
 
bool is_action_enabled_unit_on_tile (const action_id wanted_action, const struct unit *actor_unit, const struct tile *target_tile, const struct extra_type *target_extra)
 Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are concerned. More...
 
static bool is_action_enabled_unit_on_self_full (const action_id wanted_action, const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile)
 Returns TRUE if actor_unit can do wanted_action to itself as far as action enablers are concerned. More...
 
bool is_action_enabled_unit_on_self (const action_id wanted_action, const struct unit *actor_unit)
 Returns TRUE if actor_unit can do wanted_action to itself as far as action enablers are concerned. More...
 
static enum fc_tristate action_enabled_local (const action_id wanted_action, const struct player *actor_player, const struct city *actor_city, const struct impr_type *actor_building, const struct tile *actor_tile, const struct unit *actor_unit, const struct output_type *actor_output, const struct specialist *actor_specialist, const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct output_type *target_output, const struct specialist *target_specialist)
 Find out if the action is enabled, may be enabled or isn't enabled given what the player owning the actor knowns. More...
 
static bool is_effect_val_known (enum effect_type effect_type, const struct player *pow_player, const struct player *target_player, const struct player *other_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct output_type *target_output, const struct specialist *target_specialist)
 Find out if the effect value is known. More...
 
static enum fc_tristate tech_can_be_stolen (const struct player *actor_player, const struct player *target_player)
 Does the target has any techs the actor don't? More...
 
static struct act_prob ap_dipl_battle_win (const struct unit *pattacker, const struct unit *pdefender)
 The action probability that pattacker will win a diplomatic battle. More...
 
static struct act_prob ap_diplomat_battle (const struct unit *pattacker, const struct unit *pvictim, const struct tile *tgt_tile)
 The action probability that pattacker will win a diplomatic battle. More...
 
static struct act_prob act_prob_unseen_target (action_id act_id, const struct unit *actor_unit)
 Returns the action probability for when a target is unseen. More...
 
static struct act_prob action_prob (const action_id wanted_action, const struct player *actor_player, const struct city *actor_city, const struct impr_type *actor_building, const struct tile *actor_tile, const struct unit *actor_unit, const struct unit_type *actor_unittype_p, const struct output_type *actor_output, const struct specialist *actor_specialist, const struct city *actor_home, const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype_p, const struct output_type *target_output, const struct specialist *target_specialist, const struct extra_type *target_extra)
 An action's probability of success. More...
 
static struct act_prob action_prob_vs_city_full (const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct city *target_city)
 Get the actor unit's probability of successfully performing the chosen action on the target city. More...
 
struct act_prob action_prob_vs_city (const struct unit *actor_unit, const action_id act_id, const struct city *target_city)
 Get the actor unit's probability of successfully performing the chosen action on the target city. More...
 
static struct act_prob action_prob_vs_unit_full (const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct unit *target_unit)
 Get the actor unit's probability of successfully performing the chosen action on the target unit. More...
 
struct act_prob action_prob_vs_unit (const struct unit *actor_unit, const action_id act_id, const struct unit *target_unit)
 Get the actor unit's probability of successfully performing the chosen action on the target unit. More...
 
static struct act_prob action_prob_vs_units_full (const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct tile *target_tile)
 Get the actor unit's probability of successfully performing the chosen action on all units at the target tile. More...
 
struct act_prob action_prob_vs_units (const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile)
 Get the actor unit's probability of successfully performing the chosen action on all units at the target tile. More...
 
static struct act_prob action_prob_vs_tile_full (const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
 Get the actor unit's probability of successfully performing the chosen action on the target tile. More...
 
struct act_prob action_prob_vs_tile (const struct unit *actor_unit, const action_id act_id, const struct tile *target_tile, const struct extra_type *target_extra)
 Get the actor unit's probability of successfully performing the chosen action on the target tile. More...
 
static struct act_prob action_prob_self_full (const struct unit *actor_unit, const struct city *actor_home, const struct tile *actor_tile, const action_id act_id)
 Get the actor unit's probability of successfully performing the chosen action on itself. More...
 
struct act_prob action_prob_self (const struct unit *actor_unit, const action_id act_id)
 Get the actor unit's probability of successfully performing the chosen action on itself. More...
 
struct act_prob action_prob_unit_vs_tgt (const struct action *paction, const struct unit *act_unit, const struct city *tgt_city, const struct unit *tgt_unit, const struct tile *tgt_tile, const struct extra_type *extra_tgt)
 Returns the actor unit's probability of successfully performing the specified action against the action specific target. More...
 
struct act_prob action_speculate_unit_on_city (const action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, const bool omniscient_cheat, const struct city *target)
 Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target city given the specified game state changes. More...
 
struct act_prob action_speculate_unit_on_units (action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target)
 Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target unit stack given the specified game state changes. More...
 
struct act_prob action_speculate_unit_on_tile (action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat, const struct tile *target_tile, const struct extra_type *target_extra)
 Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target tile (and, if specified, extra) given the specified game state changes. More...
 
struct act_prob action_speculate_unit_on_self (action_id act_id, const struct unit *actor, const struct city *actor_home, const struct tile *actor_tile, bool omniscient_cheat)
 Returns a speculation about the actor unit's probability of successfully performing the chosen action on itself given the specified game state changes. More...
 
struct act_prob action_prob_new_impossible ()
 Returns the impossible action probability. More...
 
struct act_prob action_prob_new_certain ()
 Returns the certain action probability. More...
 
struct act_prob action_prob_new_not_relevant ()
 Returns the n/a action probability. More...
 
struct act_prob action_prob_new_not_impl ()
 Returns the "not implemented" action probability. More...
 
struct act_prob action_prob_new_unknown ()
 Returns the "user don't know" action probability. More...
 
bool action_prob_possible (const struct act_prob probability)
 Returns TRUE iff the given action probability belongs to an action that may be possible. More...
 
bool are_action_probabilitys_equal (const struct act_prob *ap1, const struct act_prob *ap2)
 Returns TRUE iff ap1 and ap2 are equal. More...
 
int action_prob_cmp_pessimist (const struct act_prob ap1, const struct act_prob ap2)
 Compare action probabilities. More...
 
double action_prob_to_0_to_1_pessimist (const struct act_prob ap)
 Returns double in the range [0-1] representing the minimum of the given action probability. More...
 
struct act_prob action_prob_fall_back (const struct act_prob *ap1, const struct act_prob *ap2)
 Returns ap1 with ap2 as fall back in cases where ap1 doesn't happen. More...
 
int action_dice_roll_initial_odds (const struct action *paction)
 Returns the initial odds of an action not failing its dice roll. More...
 
int action_dice_roll_odds (const struct player *act_player, const struct unit *act_unit, const struct city *tgt_city, const struct player *tgt_player, const struct action *paction)
 Returns the odds of an action not failing its dice roll. More...
 
bool action_immune_government (struct government *gov, action_id act)
 Will a player with the government gov be immune to the action act? More...
 
static bool is_target_possible (const action_id wanted_action, const struct player *actor_player, const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, const struct tile *target_tile, const struct unit *target_unit, const struct unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist)
 Returns TRUE if the wanted action can be done to the target. More...
 
bool is_action_possible_on_city (action_id act_id, const struct player *actor_player, const struct city *target_city)
 Returns TRUE if the wanted action can be done to the target city. More...
 
bool is_action_possible_on_unit (action_id act_id, const unit *target_unit)
 Checks if there is any hopes that the action is possible against the target unit (by chacking the target_reqs). More...
 
bool action_maybe_possible_actor_unit (const action_id act_id, const struct unit *actor_unit)
 Returns TRUE if the wanted action (as far as the player knows) can be performed right now by the specified actor unit if an approriate target is provided. More...
 
bool action_mp_full_makes_legal (const struct unit *actor, const action_id act_id)
 Returns TRUE if the specified action can't be done now but would have been legal if the unit had full movement. More...
 
struct action_auto_perfaction_auto_perf_slot_number (const int num)
 Returns action auto performer rule slot number num so it can be filled. More...
 
const struct action_auto_perfaction_auto_perf_by_number (const int num)
 Returns action auto performer rule number num. More...
 
bool action_univs_not_blocking (const struct action *paction, struct universal *actor_uni, struct universal *target_uni)
 Is there any action enablers of the given type not blocked by universals? More...
 
void action_list_end (action_id *act_list, int size)
 Terminate an action list of the specified size. More...
 
void action_list_add_all_by_result (action_id *act_list, int *position, enum action_result result)
 Add all actions with the specified result to the specified action list starting at the specified position. More...
 
const char * action_ui_name_ruleset_var_name (int act)
 Return ui_name ruleset variable name for the action. More...
 
const char * action_ui_name_default (int act)
 Return default ui_name for the action. More...
 
const char * action_min_range_ruleset_var_name (int act)
 Return min range ruleset variable name for the action or nullptr if min range can't be set in the ruleset. More...
 
int action_min_range_default (int act)
 Return default min range for the action if it is ruleset settable. More...
 
const char * action_max_range_ruleset_var_name (int act)
 Return max range ruleset variable name for the action or nullptr if max range can't be set in the ruleset. More...
 
int action_max_range_default (int act)
 Return default max range for the action if it is ruleset settable. More...
 
const char * action_target_kind_ruleset_var_name (int act)
 Return target kind ruleset variable name for the action or nullptr if min range can't be set in the ruleset. More...
 
const char * action_actor_consuming_always_ruleset_var_name (action_id act)
 Return actor consuming always ruleset variable name for the action or nullptr if actor consuming always can't be set in the ruleset. More...
 
static bool may_unit_act_vs_city (struct unit *actor, struct city *target, bool accept_all_actions)
 Returns TRUE iff, from the point of view of the owner of the actor unit, it looks like the actor unit may be able to do any action to the target city. More...
 
struct cityaction_tgt_city (struct unit *actor, struct tile *target_tile, bool accept_all_actions)
 Find a city to target for an action on the specified tile. More...
 
static bool may_unit_act_vs_unit (struct unit *actor, struct unit *target, bool accept_all_actions)
 Returns TRUE iff, from the point of view of the owner of the actor unit, it looks like the actor unit may be able to do any action to the target unit. More...
 
struct unitaction_tgt_unit (struct unit *actor, struct tile *target_tile, bool accept_all_actions)
 Find a unit to target for an action at the specified tile. More...
 
struct tileaction_tgt_tile (struct unit *actor, struct tile *target, const struct extra_type *target_extra, bool accept_all_actions)
 Returns the tile iff it, from the point of view of the owner of the actor unit, looks like a target tile. More...
 
static bool may_unit_act_vs_tile_extra (const struct unit *actor, const struct tile *tgt_tile, const struct extra_type *tgt_extra, bool accept_all_actions)
 Returns TRUE iff, from the point of view of the owner of the actor unit, it looks like the actor unit may be able to do any action to the target extra located at the target tile. More...
 
struct extra_typeaction_tgt_tile_extra (const struct unit *actor, const struct tile *target_tile, bool accept_all_actions)
 Find an extra to target for an action at the specified tile. More...
 

Variables

static struct actionactions [MAX_NUM_ACTIONS]
 
struct action_auto_perf auto_perfs [MAX_NUM_ACTION_AUTO_PERFORMERS]
 
static bool actions_initialized = false
 
static struct action_enabler_list * action_enablers_by_action [MAX_NUM_ACTIONS]
 
static struct obligatory_req_vector obligatory_hard_reqs [ACTRES_NONE]
 

Macro Definition Documentation

◆ ACTPROB_VAL_1_PCT

#define ACTPROB_VAL_1_PCT   (ACTPROB_VAL_MAX / 100)

Definition at line 85 of file actions.cpp.

◆ ACTPROB_VAL_MAX

#define ACTPROB_VAL_MAX   200

Definition at line 83 of file actions.cpp.

◆ ACTPROB_VAL_MIN

#define ACTPROB_VAL_MIN   0

Definition at line 81 of file actions.cpp.

◆ ACTPROB_VAL_NA

#define ACTPROB_VAL_NA   253

Definition at line 87 of file actions.cpp.

◆ ACTPROB_VAL_NOT_IMPL

#define ACTPROB_VAL_NOT_IMPL   254

Definition at line 89 of file actions.cpp.

◆ obligatory_req_vector_iterate

#define obligatory_req_vector_iterate (   obreq_vec,
  pobreq 
)     TYPED_VECTOR_ITERATE(struct obligatory_req, obreq_vec, pobreq)

Definition at line 69 of file actions.cpp.

◆ obligatory_req_vector_iterate_end

#define obligatory_req_vector_iterate_end   VECTOR_ITERATE_END

Definition at line 71 of file actions.cpp.

◆ SPECVEC_TAG

#define SPECVEC_TAG   obligatory_req

Definition at line 66 of file actions.cpp.

◆ SPECVEC_TYPE

#define SPECVEC_TYPE   struct obligatory_req

Definition at line 67 of file actions.cpp.

Function Documentation

◆ act_prob_unseen_target()

static struct act_prob act_prob_unseen_target ( action_id  act_id,
const struct unit actor_unit 
)
static

Returns the action probability for when a target is unseen.

Definition at line 4264 of file actions.cpp.

◆ action_actor_consuming_always_ruleset_var_name()

const char* action_actor_consuming_always_ruleset_var_name ( action_id  act)

Return actor consuming always ruleset variable name for the action or nullptr if actor consuming always can't be set in the ruleset.

TODO: make actions generic and put actor consuming always in a field of the action.

Definition at line 6836 of file actions.cpp.

Referenced by load_action_actor_consuming_always(), and save_action_actor_consuming_always().

◆ action_actor_utype_hard_reqs_ok()

bool action_actor_utype_hard_reqs_ok ( enum action_result  result,
const struct unit_type actor_unittype 
)

Returns TRUE if the specified unit type can perform an action with the wanted result given that an action enabler later will enable it.

This is done by checking the action result's hard requirements. Hard requirements must be TRUE before an action can be done. The reason why is usually that code dealing with the action assumes that the requirements are true. A requirement may also end up here if it can't be expressed in a requirement vector or if its absence makes the action pointless.

Parameters
resultthe action result to check the hard reqs for
actor_unittypethe unit type that may be able to act
Returns
TRUE iff the specified unit type can perform the wanted action given that an action enabler later will enable it.

Definition at line 2776 of file actions.cpp.

Referenced by action_enabler_suggest_improvement(), action_not_enabled_reason(), and unit_can_act_cache_set().

◆ action_actor_utype_hard_reqs_ok_full()

static bool action_actor_utype_hard_reqs_ok_full ( enum action_result  result,
const struct unit_type actor_unittype,
bool  ignore_third_party 
)
static

Returns TRUE if the specified unit type can perform an action with the wanted result given that an action enabler later will enable it.

This is done by checking the action result's hard requirements. Hard requirements must be TRUE before an action can be done. The reason why is usually that code dealing with the action assumes that the requirements are true. A requirement may also end up here if it can't be expressed in a requirement vector or if its absence makes the action pointless.

When adding a new hard requirement here: explain why it is a hard requirement in a comment.

Parameters
resultthe action result to check the hard reqs for
actor_unittypethe unit type that may be able to act
ignore_third_partyignore if potential targets etc exists
Returns
TRUE iff the specified unit type can perform the wanted action given that an action enabler later will enable it.

Definition at line 2630 of file actions.cpp.

Referenced by action_actor_utype_hard_reqs_ok().

◆ action_auto_perf_by_number()

const struct action_auto_perf* action_auto_perf_by_number ( const int  num)

Returns action auto performer rule number num.

Used in action_auto_perf_iterate()

WARNING: If the cause of the returned action performer rule is AAPC_COUNT it means that it is unused.

Definition at line 5848 of file actions.cpp.

Referenced by save_action_auto_actions(), save_action_auto_uflag_block(), and save_game_ruleset().

◆ action_auto_perf_slot_number()

struct action_auto_perf* action_auto_perf_slot_number ( const int  num)

Returns action auto performer rule slot number num so it can be filled.

Definition at line 5832 of file actions.cpp.

Referenced by action_auto_perf_by_number(), handle_ruleset_action_auto(), load_ruleset_cities(), load_ruleset_game(), and sanity_check_ruleset_data().

◆ action_by_number()

struct action* action_by_number ( action_id  act_id)

Return the action with the given id.

Returns nullptr if no action with the given id exists.

Definition at line 1149 of file actions.cpp.

Referenced by action_by_rule_name(), action_enabler_suggest_improvement(), action_enabler_suggest_repair_oblig(), action_entry(), action_entry_update(), action_is_blocked_by(), action_is_hostile(), action_list_add_all_by_result(), action_maybe_possible_actor_unit(), action_not_enabled_reason(), action_selection_refresh(), action_target_neg_util(), adv_best_government(), adv_unit_move(), api_find_action(), freeciv::path_finder::path_finder_private::attempt_paradrop(), auto_settlers_speculate_can_act_at(), freeciv::detail::vertex::child_for_action(), city_gold_worth(), go_act_menu::create(), dai_diplomat_city(), dai_evaluate_tile_for_air_attack(), dai_unit_move(), dai_upgrade_units(), dir_opposite(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), execute_orders(), fix_enabler_item::fix_enabler_item(), get_caravan_enter_city_trade_bonus(), handle_city_sabotage_list(), handle_ruleset_action(), handle_unit_action_answer(), handle_unit_action_query(), handle_unit_type_upgrade(), helptext_building(), helptext_government(), helptext_unit(), illegal_action(), key_unit_action_select_tgt(), load_action_actor_consuming_always(), load_action_kind(), load_action_range(), load_action_range_max(), load_action_ui_name(), load_ruleset_game(), may_unit_act_vs_tile_extra(), need_war_player_hlp(), popup_action_selection(), rscompat_enabler_add_obligatory_hard_reqs(), rscompat_old_slow_invasions_3_1(), sanity_check_ruleset_data(), save_action_actor_consuming_always(), save_action_kind(), save_action_max_range(), save_action_range(), save_action_ui_name(), save_game_ruleset(), send_ruleset_actions(), settler_evaluate_improvements(), tai_tile_worker_task_select(), texai_tile_worker_task_select(), unit_activity_complete(), unit_activity_targeted_internal(), unit_can_act_cache_set(), unit_order_list_is_sane(), unit_perform_action(), unit_upgrade_price(), universal_kind_values(), universal_value_initial(), upgrade_unit_order_targets(), and utype_may_do_escape_action().

◆ action_by_rule_name()

struct action* action_by_rule_name ( const char *  name)

Return the action with the given name.

Returns nullptr if no action with the given name exists.

Definition at line 1169 of file actions.cpp.

Referenced by api_find_action_by_name(), tab_enabler::edit_type(), load_ruleset_game(), sg_load_savefile(), and universal_by_number().

◆ action_creates_extra()

bool action_creates_extra ( const struct action paction,
const struct extra_type pextra 
)

Returns TRUE iff the specified action can create the specified extra.

Definition at line 1649 of file actions.cpp.

Referenced by go_act_menu::create(), execute_orders(), helptext_unit(), and unit_order_list_is_sane().

◆ action_dice_roll_initial_odds()

int action_dice_roll_initial_odds ( const struct action paction)

Returns the initial odds of an action not failing its dice roll.

Definition at line 5580 of file actions.cpp.

Referenced by action_dice_roll_odds(), effect_list_sanity_cb(), and helptext_unit().

◆ action_dice_roll_odds()

int action_dice_roll_odds ( const struct player act_player,
const struct unit act_unit,
const struct city tgt_city,
const struct player tgt_player,
const struct action paction 
)

Returns the odds of an action not failing its dice roll.

Definition at line 5657 of file actions.cpp.

Referenced by action_failed_dice_roll().

◆ action_distance_accepted()

bool action_distance_accepted ( const struct action action,
const int  distance 
)

Returns TRUE iff the specified distance between actor and target is within the range acceptable to the specified action.

Definition at line 1314 of file actions.cpp.

◆ action_distance_inside_max()

bool action_distance_inside_max ( const struct action action,
const int  distance 
)

Returns TRUE iff the specified distance between actor and target is sm,aller or equal to the max range accepted by the specified action.

Definition at line 1303 of file actions.cpp.

Referenced by action_distance_accepted(), action_not_enabled_reason(), and sanity_check_ruleset_data().

◆ action_enabled_local()

static enum fc_tristate action_enabled_local ( const action_id  wanted_action,
const struct player actor_player,
const struct city actor_city,
const struct impr_type actor_building,
const struct tile actor_tile,
const struct unit actor_unit,
const struct output_type actor_output,
const struct specialist actor_specialist,
const struct player target_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct output_type target_output,
const struct specialist target_specialist 
)
static

Find out if the action is enabled, may be enabled or isn't enabled given what the player owning the actor knowns.

A player don't always know everything needed to figure out if an action is enabled or not. A server side AI with the same limits on its knowledge as a human player or a client should use this to figure out what is what.

Assumes to be called from the point of view of the actor. Its knowledge is assumed to be given in the parameters.

Returns TRI_YES if the action is enabled, TRI_NO if it isn't and TRI_MAYBE if the player don't know enough to tell.

If meta knowledge is missing TRI_MAYBE will be returned.

Definition at line 4196 of file actions.cpp.

◆ action_enabler_add()

◆ action_enabler_copy()

struct action_enabler* action_enabler_copy ( const struct action_enabler original)

Create a new copy of an existing action enabler.

Definition at line 1839 of file actions.cpp.

Referenced by fix_enabler_item::fix_enabler_item(), rscompat_enabler_add_obligatory_hard_reqs(), rscompat_old_slow_invasions_3_1(), and rscompat_postprocess().

◆ action_enabler_free()

void action_enabler_free ( struct action_enabler enabler)

Free resources allocated for the action enabler.

Definition at line 1827 of file actions.cpp.

Referenced by actions_free(), tab_enabler::add_now(), and fix_enabler_item::~fix_enabler_item().

◆ action_enabler_new()

◆ action_enabler_remove()

bool action_enabler_remove ( struct action_enabler enabler)

Remove an action enabler from the current ruleset.

Returns TRUE on success.

Definition at line 1870 of file actions.cpp.

Referenced by tab_enabler::edit_type(), and rscompat_postprocess().

◆ action_enabler_suggest_improvement()

struct req_vec_problem* action_enabler_suggest_improvement ( const struct action_enabler enabler)

Returns a suggestion to improve the specified action enabler or nullptr if nothing to improve is found to be needed.

It is the responsibility of the caller to free the suggestion when it is done with it. A possible improvement isn't always an error.

Parameters
enablerthe enabler to improve
Returns
a suggestion to improve the specified action enabler

Definition at line 2251 of file actions.cpp.

Referenced by fix_enabler_item::find_next_problem(), and sanity_check_ruleset_data().

◆ action_enabler_suggest_repair()

struct req_vec_problem* action_enabler_suggest_repair ( const struct action_enabler enabler)

Returns a suggestion to fix the specified action enabler or nullptr if no fix is found to be needed.

It is the responsibility of the caller to free the suggestion when it is done with it.

Definition at line 2187 of file actions.cpp.

Referenced by action_enabler_suggest_improvement(), fix_enabler_item::find_next_problem(), rscompat_enabler_add_obligatory_hard_reqs(), and sanity_check_ruleset_data().

◆ action_enabler_suggest_repair_oblig()

struct req_vec_problem* action_enabler_suggest_repair_oblig ( const struct action_enabler enabler)

Returns a suggestion to add an obligatory hard requirement to an action enabler or nullptr if no hard obligatory reqs were missing.

It is the responsibility of the caller to free the suggestion when it is done with it.

Parameters
enablerthe action enabler to suggest a fix for.
Returns
a problem with fix suggestions or nullptr if no obligatory hard requirement problems were detected.

Definition at line 1902 of file actions.cpp.

Referenced by action_enabler_suggest_repair().

◆ action_enabler_vector_by_number()

struct requirement_vector* action_enabler_vector_by_number ( const void *  enabler,
req_vec_num_in_item  number 
)

Returns a writable pointer to the specified requirement vector in the action enabler or nullptr if the action enabler doesn't have a requirement vector with that requirement vector number.

Parameters
enablerthe action enabler that may own the vector.
numberthe item's requirement vector number.
Returns
a pointer to the specified requirement vector.

Definition at line 2325 of file actions.cpp.

Referenced by rscompat_enabler_add_obligatory_hard_reqs(), and fix_enabler_item::vector_getter().

◆ action_enabler_vector_by_number_name()

const char* action_enabler_vector_by_number_name ( req_vec_num_in_item  vec)

Returns the name of the given requirement vector number n in an action enabler or nullptr if enablers don't have a requirement vector with that number.

Parameters
vecthe requirement vector to name
Returns
the requirement vector name or nullptr.

Definition at line 2349 of file actions.cpp.

Referenced by rscompat_enabler_add_obligatory_hard_reqs(), and fix_enabler_item::vector_namer().

◆ action_enabler_vector_number()

req_vec_num_in_item action_enabler_vector_number ( const void *  enabler,
const struct requirement_vector *  vec 
)

Returns the requirement vector number of the specified requirement vector in the specified action enabler.

Parameters
enablerthe action enabler that may own the vector.
vecthe requirement vector to number.
Returns
the requirement vector number the vector has in this enabler.

Definition at line 2302 of file actions.cpp.

Referenced by action_enabler_suggest_repair(), action_enabler_suggest_repair_oblig(), enabler_first_self_contradiction(), and enabler_tile_tgt_local_diplrel_implies_claimed().

◆ action_enablers_for_action()

◆ action_get_act_time()

int action_get_act_time ( const struct action paction,
const struct unit actor_unit,
const struct tile tgt_tile,
const struct extra_type tgt_extra 
)

Returns the unit activity time (work) this action takes (requires) or ACT_TIME_INSTANTANEOUS if the action happens at once.

See update_unit_activity() and tile_activity_time()

Definition at line 1598 of file actions.cpp.

◆ action_get_activity()

enum unit_activity action_get_activity ( const struct action paction)

◆ action_get_actor_kind()

◆ action_get_battle_kind()

enum action_battle_kind action_get_battle_kind ( const struct action pact)

Get the battle kind that can prevent an action.

Definition at line 1169 of file actions.cpp.

Referenced by helptext_unit().

◆ action_get_role()

int action_get_role ( const struct action paction)

Get the unit type role corresponding to the ability to do the specified action.

Definition at line 1544 of file actions.cpp.

◆ action_get_sub_target_kind()

enum action_sub_target_kind action_get_sub_target_kind ( const struct action paction)

Get the sub target kind of an action.

Definition at line 1169 of file actions.cpp.

Referenced by action_sub_target_id_for_action(), go_act_menu::create(), execute_orders(), and helptext_unit().

◆ action_get_target_kind()

◆ action_hard_reqs_actor()

static enum fc_tristate action_hard_reqs_actor ( enum action_result  result,
const struct player actor_player,
const struct city actor_city,
const struct impr_type actor_building,
const struct tile actor_tile,
const struct unit actor_unit,
const struct unit_type actor_unittype,
const struct output_type actor_output,
const struct specialist actor_specialist,
const bool  omniscient,
const struct city homecity 
)
static

Returns TRUE iff the wanted action is possible as far as the actor is concerned given that an action enabler later will enable it.

Will, unlike action_actor_utype_hard_reqs_ok(), check the actor unit's current state.

Can return maybe when not omniscient. Should always return yes or no when omniscient.

Definition at line 2776 of file actions.cpp.

Referenced by action_maybe_possible_actor_unit().

◆ action_has_complex_target()

bool action_has_complex_target ( const struct action paction)

Returns TRUE iff the specified action allows the player to provide details in addition to actor and target.

Returns FALSE if the action doesn't support any additional details.

Definition at line 1262 of file actions.cpp.

Referenced by may_unit_act_vs_tile_extra().

◆ action_has_result()

◆ action_id_exists()

◆ action_id_is_rare_pop_up()

bool action_id_is_rare_pop_up ( action_id  act_id)

Returns TRUE iff a unit's ability to perform this action will pop up the action selection dialog before the player asks for it only in exceptional cases.

An example of an exceptional case is when the player tries to move a unit to a tile it can't move to but can perform this action to.

Definition at line 1290 of file actions.cpp.

Referenced by action_tgt_tile(), may_unit_act_vs_city(), may_unit_act_vs_tile_extra(), and may_unit_act_vs_unit().

◆ action_id_name_translation()

const QString action_id_name_translation ( action_id  act_id)

◆ action_id_rule_name()

◆ action_immune_government()

bool action_immune_government ( struct government gov,
action_id  act 
)

Will a player with the government gov be immune to the action act?

Definition at line 5687 of file actions.cpp.

Referenced by adv_best_government(), and helptext_government().

◆ action_is_blocked_by()

struct action* action_is_blocked_by ( const action_id  act_id,
const struct unit actor_unit,
const struct tile target_tile_arg,
const struct city target_city_arg,
const struct unit target_unit 
)

Returns the action that blocks the specified action or nullptr if the specified action isn't blocked.

An action that can block another blocks when it is forced and possible.

Definition at line 2530 of file actions.cpp.

Referenced by action_not_enabled_reason().

◆ action_list_add_all_by_result()

void action_list_add_all_by_result ( action_id act_list,
int *  position,
enum action_result  result 
)

Add all actions with the specified result to the specified action list starting at the specified position.

Parameters
act_listthe list to add the actions to
positionindex in act_list that is updated as action are added
resultall actions with this result are added.

Definition at line 5898 of file actions.cpp.

Referenced by adv_data_phase_init(), auto_settlers_ruleset_init(), dai_upgrade_units(), and helptext_building().

◆ action_list_end()

void action_list_end ( action_id act_list,
int  size 
)

Terminate an action list of the specified size.

Parameters
act_listthe list to end
sizethe number of elements to include in the list

Definition at line 5881 of file actions.cpp.

Referenced by adv_data_phase_init(), auto_settlers_ruleset_init(), dai_upgrade_units(), and helptext_building().

◆ action_max_range_default()

int action_max_range_default ( int  act)

Return default max range for the action if it is ruleset settable.

Definition at line 6633 of file actions.cpp.

Referenced by load_action_range_max(), and save_action_max_range().

◆ action_max_range_ruleset_var_name()

const char* action_max_range_ruleset_var_name ( int  act)

Return max range ruleset variable name for the action or nullptr if max range can't be set in the ruleset.

TODO: make actions generic and put max_range in a field of the action.

Definition at line 6528 of file actions.cpp.

Referenced by load_action_range(), load_action_range_max(), save_action_max_range(), and save_action_range().

◆ action_maybe_possible_actor_unit()

bool action_maybe_possible_actor_unit ( const action_id  act_id,
const struct unit actor_unit 
)

Returns TRUE if the wanted action (as far as the player knows) can be performed right now by the specified actor unit if an approriate target is provided.

Definition at line 5765 of file actions.cpp.

Referenced by can_unit_paradrop(), and handle_unit_get_actions().

◆ action_min_range_default()

int action_min_range_default ( int  act)

Return default min range for the action if it is ruleset settable.

Definition at line 6430 of file actions.cpp.

Referenced by load_action_range(), and save_action_range().

◆ action_min_range_ruleset_var_name()

const char* action_min_range_ruleset_var_name ( int  act)

Return min range ruleset variable name for the action or nullptr if min range can't be set in the ruleset.

TODO: make actions generic and put min_range in a field of the action.

Definition at line 6334 of file actions.cpp.

Referenced by load_action_range(), and save_action_range().

◆ action_mp_full_makes_legal()

bool action_mp_full_makes_legal ( const struct unit actor,
const action_id  act_id 
)

Returns TRUE if the specified action can't be done now but would have been legal if the unit had full movement.

Definition at line 5817 of file actions.cpp.

Referenced by action_not_enabled_reason(), and execute_orders().

◆ action_name_translation()

◆ action_new()

static struct action* action_new ( action_id  id,
enum action_result  result,
enum action_target_kind  target_kind,
enum action_sub_target_kind  sub_target_kind,
enum act_tgt_compl  tgt_compl,
const int  min_distance,
const int  max_distance,
bool  actor_consuming_always 
)
static

Create a new action.

Definition at line 1063 of file actions.cpp.

Referenced by unit_action_new().

◆ action_number()

int action_number ( const struct action action)

◆ action_prepare_ui_name()

const QString action_prepare_ui_name ( action_id  act_id,
const char *  mnemonic,
const struct act_prob  prob,
const QString &  custom 
)

Get the UI name ready to show the action in the UI.

It is possible to add a client specific mnemonic; it is assumed that if the mnemonic appears in the action name it can be escaped by doubling. Success probability information is interpreted and added to the text. A custom text can be inserted before the probability information.

Definition at line 1412 of file actions.cpp.

Referenced by action_entry(), action_entry_update(), and action_id_name_translation().

◆ action_prob()

static struct act_prob action_prob ( const action_id  wanted_action,
const struct player actor_player,
const struct city actor_city,
const struct impr_type actor_building,
const struct tile actor_tile,
const struct unit actor_unit,
const struct unit_type actor_unittype_p,
const struct output_type actor_output,
const struct specialist actor_specialist,
const struct city actor_home,
const struct player target_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct unit_type target_unittype_p,
const struct output_type target_output,
const struct specialist target_specialist,
const struct extra_type target_extra 
)
static

An action's probability of success.

"Success" indicates that the action achieves its goal, not that the actor survives. For actions that cost money it is assumed that the player has and is willing to spend the money. This is so the player can figure out what his odds are before deciding to get the extra money.

Definition at line 4264 of file actions.cpp.

◆ action_prob_cmp_pessimist()

int action_prob_cmp_pessimist ( const struct act_prob  ap1,
const struct act_prob  ap2 
)

Compare action probabilities.

Prioritize the lowest possible value.

Definition at line 5428 of file actions.cpp.

Referenced by compare_units().

◆ action_prob_explain()

const QString action_prob_explain ( const struct act_prob  prob)

Explain an action probability in a way suitable for a tool tip for the button that starts it.

Returns
an explanation of what an action probability means

Definition at line 1504 of file actions.cpp.

Referenced by act_sel_action_tool_tip().

◆ action_prob_fall_back()

struct act_prob action_prob_fall_back ( const struct act_prob ap1,
const struct act_prob ap2 
)

Returns ap1 with ap2 as fall back in cases where ap1 doesn't happen.

Said in math that is: P(A) + P(A') * P(B)

This is useful to calculate the probability of doing action A or, when A is impossible, falling back to doing action B.

Definition at line 5479 of file actions.cpp.

◆ action_prob_is_signal()

static bool action_prob_is_signal ( const struct act_prob  probability)
inlinestatic

Returns TRUE iff the given action probability represents a special signal value rather than a regular action probability value.

Definition at line 5411 of file actions.cpp.

Referenced by action_prob_cmp_pessimist(), action_prob_explain(), action_prob_fall_back(), and action_prob_to_text().

◆ action_prob_new_certain()

struct act_prob action_prob_new_certain ( )

Returns the certain action probability.

Definition at line 4264 of file actions.cpp.

◆ action_prob_new_impossible()

struct act_prob action_prob_new_impossible ( )

Returns the impossible action probability.

Definition at line 4264 of file actions.cpp.

◆ action_prob_new_not_impl()

struct act_prob action_prob_new_not_impl ( )

Returns the "not implemented" action probability.

Definition at line 4264 of file actions.cpp.

◆ action_prob_new_not_relevant()

struct act_prob action_prob_new_not_relevant ( )

Returns the n/a action probability.

Definition at line 4264 of file actions.cpp.

◆ action_prob_new_unknown()

struct act_prob action_prob_new_unknown ( )

Returns the "user don't know" action probability.

Definition at line 4264 of file actions.cpp.

◆ action_prob_not_impl()

static bool action_prob_not_impl ( const struct act_prob  probability)
inlinestatic

Returns TRUE iff the given action probability represents that support for finding this action probability currently is missing from Freeciv.

Definition at line 5401 of file actions.cpp.

Referenced by action_prob_cmp_pessimist(), action_prob_explain(), action_prob_fall_back(), action_prob_possible(), and action_prob_to_text().

◆ action_prob_not_relevant()

static bool action_prob_not_relevant ( const struct act_prob  probability)
inlinestatic

Returns TRUE iff the given action probability represents the lack of an action probability.

Definition at line 5391 of file actions.cpp.

Referenced by action_prepare_ui_name(), action_prob_cmp_pessimist(), action_prob_fall_back(), and action_prob_to_text().

◆ action_prob_possible()

◆ action_prob_self()

struct act_prob action_prob_self ( const struct unit actor_unit,
const action_id  act_id 
)

Get the actor unit's probability of successfully performing the chosen action on itself.

Definition at line 4264 of file actions.cpp.

Referenced by do_disband_alternative(), execute_orders(), and handle_unit_get_actions().

◆ action_prob_self_full()

static struct act_prob action_prob_self_full ( const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const action_id  act_id 
)
static

Get the actor unit's probability of successfully performing the chosen action on itself.

Definition at line 4264 of file actions.cpp.

◆ action_prob_to_0_to_1_pessimist()

double action_prob_to_0_to_1_pessimist ( const struct act_prob  ap)

Returns double in the range [0-1] representing the minimum of the given action probability.

Definition at line 5479 of file actions.cpp.

Referenced by unit_survive_autoattack().

◆ action_prob_to_text()

static QString action_prob_to_text ( const struct act_prob  prob)
static

Returns a text representation of the action probability prob unless it is a signal.

Returns nullptr if prob is a signal.

Definition at line 1382 of file actions.cpp.

Referenced by action_prepare_ui_name().

◆ action_prob_unit_vs_tgt()

struct act_prob action_prob_unit_vs_tgt ( const struct action paction,
const struct unit act_unit,
const struct city tgt_city,
const struct unit tgt_unit,
const struct tile tgt_tile,
const struct extra_type extra_tgt 
)

Returns the actor unit's probability of successfully performing the specified action against the action specific target.

Parameters
pactionthe action to perform
act_unitthe actor unit
tgt_citythe target for city targeted actions
tgt_unitthe target for unit targeted actions
tgt_tilethe target for tile and unit stack targeted actions
extra_tgtthe target for extra sub targeted actions
Returns
the action probability of performing the action

Definition at line 4264 of file actions.cpp.

Referenced by illegal_action().

◆ action_prob_vs_city()

struct act_prob action_prob_vs_city ( const struct unit actor_unit,
const action_id  act_id,
const struct city target_city 
)

Get the actor unit's probability of successfully performing the chosen action on the target city.

Definition at line 4264 of file actions.cpp.

Referenced by can_unit_change_homecity_to(), dai_diplomat_city(), do_disband_alternative(), execute_orders(), handle_unit_get_actions(), may_unit_act_vs_city(), unit_can_add_or_build_city(), unit_can_airlift_to(), and unit_can_help_build_wonder_here().

◆ action_prob_vs_city_full()

static struct act_prob action_prob_vs_city_full ( const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const action_id  act_id,
const struct city target_city 
)
static

Get the actor unit's probability of successfully performing the chosen action on the target city.

Definition at line 4264 of file actions.cpp.

◆ action_prob_vs_tile()

struct act_prob action_prob_vs_tile ( const struct unit actor_unit,
const action_id  act_id,
const struct tile target_tile,
const struct extra_type target_extra 
)

Get the actor unit's probability of successfully performing the chosen action on the target tile.

Definition at line 4264 of file actions.cpp.

Referenced by action_sub_target_id_for_action(), action_tgt_tile(), do_disband_alternative(), execute_orders(), handle_city_name_suggestion_req(), handle_unit_get_actions(), may_unit_act_vs_tile_extra(), and unit_can_add_or_build_city().

◆ action_prob_vs_tile_full()

static struct act_prob action_prob_vs_tile_full ( const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const action_id  act_id,
const struct tile target_tile,
const struct extra_type target_extra 
)
static

Get the actor unit's probability of successfully performing the chosen action on the target tile.

Definition at line 4264 of file actions.cpp.

◆ action_prob_vs_unit()

struct act_prob action_prob_vs_unit ( const struct unit actor_unit,
const action_id  act_id,
const struct unit target_unit 
)

Get the actor unit's probability of successfully performing the chosen action on the target unit.

Definition at line 4264 of file actions.cpp.

Referenced by can_unit_alight_or_be_unloaded(), dai_diplomat_bribe_nearby(), do_disband_alternative(), execute_orders(), handle_unit_get_actions(), and may_unit_act_vs_unit().

◆ action_prob_vs_unit_full()

static struct act_prob action_prob_vs_unit_full ( const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const action_id  act_id,
const struct unit target_unit 
)
static

Get the actor unit's probability of successfully performing the chosen action on the target unit.

Definition at line 4264 of file actions.cpp.

◆ action_prob_vs_units()

struct act_prob action_prob_vs_units ( const struct unit actor_unit,
const action_id  act_id,
const struct tile target_tile 
)

Get the actor unit's probability of successfully performing the chosen action on all units at the target tile.

Definition at line 4264 of file actions.cpp.

Referenced by action_tgt_tile(), do_disband_alternative(), execute_orders(), and handle_unit_get_actions().

◆ action_prob_vs_units_full()

static struct act_prob action_prob_vs_units_full ( const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const action_id  act_id,
const struct tile target_tile 
)
static

Get the actor unit's probability of successfully performing the chosen action on all units at the target tile.

Definition at line 4264 of file actions.cpp.

◆ action_removes_extra()

bool action_removes_extra ( const struct action paction,
const struct extra_type pextra 
)

Returns TRUE iff the specified action can remove the specified extra.

Definition at line 1732 of file actions.cpp.

Referenced by go_act_menu::create(), execute_orders(), helptext_unit(), and unit_order_list_is_sane().

◆ action_requires_details()

bool action_requires_details ( const struct action paction)

Returns TRUE iff the specified action REQUIRES the player to provide details in addition to actor and target.

Returns FALSE if the action doesn't support any additional details or if they can be set by Freeciv it self.

Definition at line 1275 of file actions.cpp.

◆ action_rule_name()

◆ action_speculate_unit_on_city()

struct act_prob action_speculate_unit_on_city ( const action_id  act_id,
const struct unit actor,
const struct city actor_home,
const struct tile actor_tile,
const bool  omniscient_cheat,
const struct city target 
)

Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target city given the specified game state changes.

Definition at line 4264 of file actions.cpp.

Referenced by auto_settlers_speculate_can_act_at(), and get_discounted_reward().

◆ action_speculate_unit_on_self()

struct act_prob action_speculate_unit_on_self ( action_id  act_id,
const struct unit actor,
const struct city actor_home,
const struct tile actor_tile,
bool  omniscient_cheat 
)

Returns a speculation about the actor unit's probability of successfully performing the chosen action on itself given the specified game state changes.

Definition at line 4264 of file actions.cpp.

Referenced by auto_settlers_speculate_can_act_at().

◆ action_speculate_unit_on_tile()

struct act_prob action_speculate_unit_on_tile ( action_id  act_id,
const struct unit actor,
const struct city actor_home,
const struct tile actor_tile,
bool  omniscient_cheat,
const struct tile target_tile,
const struct extra_type target_extra 
)

Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target tile (and, if specified, extra) given the specified game state changes.

Definition at line 4264 of file actions.cpp.

Referenced by auto_settlers_speculate_can_act_at(), settler_evaluate_improvements(), tai_tile_worker_task_select(), and texai_tile_worker_task_select().

◆ action_speculate_unit_on_units()

struct act_prob action_speculate_unit_on_units ( action_id  act_id,
const struct unit actor,
const struct city actor_home,
const struct tile actor_tile,
bool  omniscient_cheat,
const struct tile target 
)

Returns a speculation about the actor unit's probability of successfully performing the chosen action on the target unit stack given the specified game state changes.

Definition at line 4264 of file actions.cpp.

Referenced by auto_settlers_speculate_can_act_at().

◆ action_target_kind_ruleset_var_name()

const char* action_target_kind_ruleset_var_name ( int  act)

Return target kind ruleset variable name for the action or nullptr if min range can't be set in the ruleset.

TODO: make actions generic and put target_kind in a field of the action.

Definition at line 6736 of file actions.cpp.

Referenced by load_action_kind(), and save_action_kind().

◆ action_tgt_city()

struct city* action_tgt_city ( struct unit actor,
struct tile target_tile,
bool  accept_all_actions 
)

Find a city to target for an action on the specified tile.

Returns nullptr if no proper target is found.

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 6983 of file actions.cpp.

Referenced by freeciv::path_finder::path_finder_private::attempt_action_move(), handle_unit_get_actions(), unit_move(), and unit_move_handling().

◆ action_tgt_tile()

struct tile* action_tgt_tile ( struct unit actor,
struct tile target,
const struct extra_type target_extra,
bool  accept_all_actions 
)

Returns the tile iff it, from the point of view of the owner of the actor unit, looks like a target tile.

Returns nullptr if the player knows that the actor unit can't do any action (that specifies its target as a tile) to the tile.

If the owner of the actor unit doesn't have the knowledge needed to know for sure if the unit can act the tile will be returned.

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 7078 of file actions.cpp.

Referenced by freeciv::path_finder::path_finder_private::attempt_action_move(), and unit_move_handling().

◆ action_tgt_tile_extra()

struct extra_type* action_tgt_tile_extra ( const struct unit actor,
const struct tile target_tile,
bool  accept_all_actions 
)

Find an extra to target for an action at the specified tile.

Returns the first extra found that the actor may act against at the tile or nullptr if no proper target is found. (Note that some actions requires the absence of an extra since they result in its creation while other requires its presence.)

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 7191 of file actions.cpp.

Referenced by freeciv::path_finder::path_finder_private::attempt_action_move(), handle_unit_get_actions(), and unit_move_handling().

◆ action_tgt_unit()

struct unit* action_tgt_unit ( struct unit actor,
struct tile target_tile,
bool  accept_all_actions 
)

Find a unit to target for an action at the specified tile.

Returns the first unit found at the tile that the actor may act against or nullptr if no proper target is found.

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 7050 of file actions.cpp.

Referenced by freeciv::path_finder::path_finder_private::attempt_action_move(), execute_orders(), handle_unit_get_actions(), and unit_move_handling().

◆ action_ui_name_default()

const char* action_ui_name_default ( int  act)

Return default ui_name for the action.

Definition at line 6087 of file actions.cpp.

Referenced by load_action_ui_name(), and save_action_ui_name().

◆ action_ui_name_ruleset_var_name()

const char* action_ui_name_ruleset_var_name ( int  act)

Return ui_name ruleset variable name for the action.

TODO: make actions generic and put ui_name in a field of the action.

Definition at line 5919 of file actions.cpp.

Referenced by load_ruleset_game(), and save_game_ruleset().

◆ action_univs_not_blocking()

bool action_univs_not_blocking ( const struct action paction,
struct universal actor_uni,
struct universal target_uni 
)

Is there any action enablers of the given type not blocked by universals?

Definition at line 5856 of file actions.cpp.

◆ action_would_be_blocked_by()

bool action_would_be_blocked_by ( const struct action blocked,
const struct action blocker 
)

Returns TRUE iff blocked will be illegal if blocker is legal.

Definition at line 1326 of file actions.cpp.

Referenced by autoadjust_ruleset_data().

◆ actions_are_ready()

bool actions_are_ready ( )

Returns TRUE iff the actions are initialized.

Doesn't care about action enablers.

Definition at line 1037 of file actions.cpp.

Referenced by action_prepare_ui_name(), and go_act_menu::update().

◆ actions_free()

void actions_free ( )

Free the actions and the action enablers.

Definition at line 994 of file actions.cpp.

Referenced by game_ruleset_free().

◆ actions_init()

void actions_init ( )

Initialize the actions and the action enablers.

Definition at line 934 of file actions.cpp.

Referenced by game_ruleset_init().

◆ actions_rs_pre_san_gen()

void actions_rs_pre_san_gen ( )

Generate action related data based on the currently loaded ruleset.

Done before ruleset sanity checking and ruleset compatibility post processing.

Definition at line 984 of file actions.cpp.

Referenced by handle_rulesets_ready(), and load_rulesetdir().

◆ ae_contra_close()

static void ae_contra_close ( struct ae_contra_or contra)
static

Tell an ae_contra_or that one of its users is done with it.

Parameters
contrathe ae_contra_or the user is done with.

Definition at line 171 of file actions.cpp.

Referenced by actions_free().

◆ ap_dipl_battle_win()

static struct act_prob ap_dipl_battle_win ( const struct unit pattacker,
const struct unit pdefender 
)
static

The action probability that pattacker will win a diplomatic battle.

It is assumed that pattacker and pdefender have different owners and that the defender can defend in a diplomatic battle.

See diplomat_success_vs_defender() in server/diplomats.c

Definition at line 4264 of file actions.cpp.

◆ ap_diplomat_battle()

static struct act_prob ap_diplomat_battle ( const struct unit pattacker,
const struct unit pvictim,
const struct tile tgt_tile 
)
static

The action probability that pattacker will win a diplomatic battle.

See diplomat_infiltrate_tile() in server/diplomats.c

Definition at line 4264 of file actions.cpp.

◆ are_action_probabilitys_equal()

bool are_action_probabilitys_equal ( const struct act_prob ap1,
const struct act_prob ap2 
)

Returns TRUE iff ap1 and ap2 are equal.

Definition at line 5419 of file actions.cpp.

◆ blocked_find_target_city()

static const struct city* blocked_find_target_city ( const action_id  act_id,
const struct unit actor_unit,
const struct tile target_tile,
const struct city target_city_arg,
const struct unit target_unit 
)
static

Returns the target city for actions that may block the specified action.

This is needed because some actions can be blocked by an action with a different target kind. The target city argument could therefore be missing.

Example: The ATK_SELF action ACTION_DISBAND_UNIT can be blocked by the ATK_CITY action ACTION_RECYCLE_UNIT.

Definition at line 2482 of file actions.cpp.

Referenced by action_is_blocked_by().

◆ blocked_find_target_tile()

static const struct tile* blocked_find_target_tile ( const action_id  act_id,
const struct unit actor_unit,
const struct tile target_tile_arg,
const struct city target_city,
const struct unit target_unit 
)
static

Returns the target tile for actions that may block the specified action.

This is needed because some actions can be blocked by an action with a different target kind. The target tile could therefore be missing.

Example: The ATK_SELF action ACTION_DISBAND_UNIT can be blocked by the ATK_CITY action ACTION_RECYCLE_UNIT.

Definition at line 2434 of file actions.cpp.

Referenced by action_is_blocked_by().

◆ enabler_first_clarification()

static struct req_vec_problem* enabler_first_clarification ( const struct action_enabler enabler)
static

Returns the first action enabler specific clarification possibility in the specified enabler or nullptr if no enabler specific contradiction is found.

Parameters
enablerthe enabler to look at
Returns
the first problem and maybe a suggested fix

Definition at line 2232 of file actions.cpp.

Referenced by action_enabler_suggest_improvement().

◆ enabler_first_self_contradiction()

static struct req_vec_problem* enabler_first_self_contradiction ( const struct action_enabler enabler)
static

Returns the first action enabler specific contradiction in the specified enabler or nullptr if no enabler specific contradiction is found.

Parameters
enablerthe enabler to look at
Returns
the first problem and maybe a suggested fix

Definition at line 2120 of file actions.cpp.

Referenced by action_enabler_suggest_repair().

◆ enabler_tile_tgt_local_diplrel_implies_claimed()

static struct req_vec_problem* enabler_tile_tgt_local_diplrel_implies_claimed ( const struct action_enabler enabler)
static

Detects a local DiplRel requirement in a tile targeted action without an explicit claimed requirement in the target reqs.

Parameters
enablerthe enabler to look at
Returns
the problem or nullptr if no problem was found

Definition at line 2048 of file actions.cpp.

Referenced by action_enabler_suggest_repair().

◆ FC_STATIC_ASSERT()

FC_STATIC_ASSERT ( MAP_DISTANCE_MAX<=  ACTION_DISTANCE_LAST_NON_SIGNAL,
action_range_can_not_cover_the_whole_map   
)

◆ hard_code_actions()

static void hard_code_actions ( )
static

Hard code the actions.

Definition at line 607 of file actions.cpp.

Referenced by actions_init().

◆ hard_code_oblig_hard_reqs()

static void hard_code_oblig_hard_reqs ( )
static

Hard code the obligatory hard requirements that don't depend on the rest of the ruleset.

They are sorted by requirement to make it easy to read, modify and explain them.

Definition at line 269 of file actions.cpp.

Referenced by actions_init().

◆ hard_code_oblig_hard_reqs_ruleset()

static void hard_code_oblig_hard_reqs_ruleset ( )
static

Hard code the obligatory hard requirements that needs access to the ruleset before they can be generated.

Definition at line 587 of file actions.cpp.

Referenced by actions_rs_pre_san_gen().

◆ is_action_enabled()

static bool is_action_enabled ( const action_id  wanted_action,
const struct player actor_player,
const struct city actor_city,
const struct impr_type actor_building,
const struct tile actor_tile,
const struct unit actor_unit,
const struct unit_type actor_unittype,
const struct output_type actor_output,
const struct specialist actor_specialist,
const struct player target_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct unit_type target_unittype,
const struct output_type target_output,
const struct specialist target_specialist,
const struct extra_type target_extra,
const struct city actor_home 
)
static

Returns TRUE if the wanted action is enabled.

Note that the action may disable it self because of hard requirements even if an action enabler returns TRUE.

Definition at line 3842 of file actions.cpp.

Referenced by is_action_enabled_unit_on_city_full(), is_action_enabled_unit_on_self_full(), is_action_enabled_unit_on_tile_full(), is_action_enabled_unit_on_unit_full(), and is_action_enabled_unit_on_units_full().

◆ is_action_enabled_unit_on_city()

bool is_action_enabled_unit_on_city ( const action_id  wanted_action,
const struct unit actor_unit,
const struct city target_city 
)

Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 3948 of file actions.cpp.

Referenced by action_auto_perf_unit_do(), action_is_blocked_by(), dai_caravan_goto(), dai_manage_caravan(), dai_unit_attack(), handle_unit_action_query(), handle_unit_type_upgrade(), occupy_move(), unit_can_airlift_to(), and unit_do_disband_trad().

◆ is_action_enabled_unit_on_city_full()

static bool is_action_enabled_unit_on_city_full ( const action_id  wanted_action,
const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const struct city target_city 
)
static

Returns TRUE if actor_unit can do wanted_action to target_city as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 3898 of file actions.cpp.

Referenced by is_action_enabled_unit_on_city().

◆ is_action_enabled_unit_on_self()

bool is_action_enabled_unit_on_self ( const action_id  wanted_action,
const struct unit actor_unit 
)

Returns TRUE if actor_unit can do wanted_action to itself as far as action enablers are concerned.

See note in is_action_enabled() for why the action still may be disabled.

Definition at line 4196 of file actions.cpp.

Referenced by action_auto_perf_unit_do(), action_is_blocked_by(), can_unit_do_activity_targeted_at(), and unit_do_disband_trad().

◆ is_action_enabled_unit_on_self_full()

static bool is_action_enabled_unit_on_self_full ( const action_id  wanted_action,
const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile 
)
static

Returns TRUE if actor_unit can do wanted_action to itself as far as action enablers are concerned.

See note in is_action_enabled() for why the action still may be disabled.

Definition at line 4153 of file actions.cpp.

Referenced by action_enabled_local().

◆ is_action_enabled_unit_on_tile()

bool is_action_enabled_unit_on_tile ( const action_id  wanted_action,
const struct unit actor_unit,
const struct tile target_tile,
const struct extra_type target_extra 
)

Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 4136 of file actions.cpp.

Referenced by action_auto_perf_unit_do(), action_is_blocked_by(), adv_unit_move(), freeciv::path_finder::path_finder_private::attempt_paradrop(), freeciv::path_finder::path_finder_private::attempt_unload(), can_unit_do_activity_targeted_at(), dai_unit_attack(), dai_unit_move(), diplomat_bribe(), and occupy_move().

◆ is_action_enabled_unit_on_tile_full()

static bool is_action_enabled_unit_on_tile_full ( const action_id  wanted_action,
const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const struct tile target_tile,
const struct extra_type target_extra 
)
static

Returns TRUE if actor_unit can do wanted_action to the target_tile as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 4093 of file actions.cpp.

Referenced by is_action_enabled_unit_on_tile().

◆ is_action_enabled_unit_on_unit()

bool is_action_enabled_unit_on_unit ( const action_id  wanted_action,
const struct unit actor_unit,
const struct unit target_unit 
)

◆ is_action_enabled_unit_on_unit_full()

static bool is_action_enabled_unit_on_unit_full ( const action_id  wanted_action,
const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const struct unit target_unit 
)
static

Returns TRUE if actor_unit can do wanted_action to target_unit as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 3963 of file actions.cpp.

Referenced by is_action_enabled_unit_on_unit().

◆ is_action_enabled_unit_on_units()

bool is_action_enabled_unit_on_units ( const action_id  wanted_action,
const struct unit actor_unit,
const struct tile target_tile 
)

Returns TRUE if actor_unit can do wanted_action to all units on the target_tile as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 4078 of file actions.cpp.

Referenced by action_auto_perf_unit_do(), action_is_blocked_by(), and dai_unit_attack().

◆ is_action_enabled_unit_on_units_full()

static bool is_action_enabled_unit_on_units_full ( const action_id  wanted_action,
const struct unit actor_unit,
const struct city actor_home,
const struct tile actor_tile,
const struct tile target_tile 
)
static

Returns TRUE if actor_unit can do wanted_action to all units on the target_tile as far as action enablers are concerned.

See note in is_action_enabled for why the action may still be disabled.

Definition at line 4022 of file actions.cpp.

Referenced by is_action_enabled_unit_on_units().

◆ is_action_possible()

static enum fc_tristate is_action_possible ( const action_id  wanted_action,
const struct player actor_player,
const struct city actor_city,
const struct impr_type actor_building,
const struct tile actor_tile,
const struct unit actor_unit,
const struct unit_type actor_unittype,
const struct output_type actor_output,
const struct specialist actor_specialist,
const struct player target_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct unit_type target_unittype,
const struct output_type target_output,
const struct specialist target_specialist,
const struct extra_type target_extra,
const bool  omniscient,
const struct city homecity 
)
static

Returns if the wanted action is possible given that an action enabler later will enable it.

Can return maybe when not omniscient. Should always return yes or no when omniscient.

This is done by checking the action's hard requirements. Hard requirements must be fulfilled before an action can be done. The reason why is usually that code dealing with the action assumes that the requirements are true. A requirement may also end up here if it can't be expressed in a requirement vector or if its absence makes the action pointless.

When adding a new hard requirement here: explain why it is a hard requirement in a comment. remember that this is called from action_prob(). Should information the player don't have access to be used in a test it must check if the evaluation can see the thing being tested.

Definition at line 2776 of file actions.cpp.

Referenced by is_action_enabled().

◆ is_action_possible_on_city()

bool is_action_possible_on_city ( action_id  act_id,
const struct player actor_player,
const struct city target_city 
)

Returns TRUE if the wanted action can be done to the target city.

Definition at line 5734 of file actions.cpp.

Referenced by adjust_improvement_wants_by_effects(), dai_choose_diplomat_offensive(), find_city_to_diplomat(), and impr_protects_vs_actions().

◆ is_action_possible_on_unit()

bool is_action_possible_on_unit ( action_id  act_id,
const unit target_unit 
)

Checks if there is any hopes that the action is possible against the target unit (by chacking the target_reqs).

Definition at line 5752 of file actions.cpp.

Referenced by popup_info_text().

◆ is_effect_val_known()

static bool is_effect_val_known ( enum effect_type  effect_type,
const struct player pow_player,
const struct player target_player,
const struct player other_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct output_type target_output,
const struct specialist target_specialist 
)
static

Find out if the effect value is known.

The knowledge of the actor is assumed to be given in the parameters.

If meta knowledge is missing TRI_MAYBE will be returned.

Definition at line 4264 of file actions.cpp.

◆ is_enabler_active()

static bool is_enabler_active ( const struct action_enabler enabler,
const struct player actor_player,
const struct city actor_city,
const struct impr_type actor_building,
const struct tile actor_tile,
const struct unit actor_unit,
const struct unit_type actor_unittype,
const struct output_type actor_output,
const struct specialist actor_specialist,
const struct player target_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct unit_type target_unittype,
const struct output_type target_output,
const struct specialist target_specialist 
)
static

Return TRUE iff the action enabler is active.

Definition at line 3813 of file actions.cpp.

Referenced by is_action_enabled().

◆ is_target_possible()

static bool is_target_possible ( const action_id  wanted_action,
const struct player actor_player,
const struct player target_player,
const struct city target_city,
const struct impr_type target_building,
const struct tile target_tile,
const struct unit target_unit,
const struct unit_type target_unittype,
const struct output_type target_output,
const struct specialist target_specialist 
)
static

Returns TRUE if the wanted action can be done to the target.

Definition at line 5708 of file actions.cpp.

Referenced by is_action_possible_on_city(), and is_action_possible_on_unit().

◆ may_unit_act_vs_city()

static bool may_unit_act_vs_city ( struct unit actor,
struct city target,
bool  accept_all_actions 
)
static

Returns TRUE iff, from the point of view of the owner of the actor unit, it looks like the actor unit may be able to do any action to the target city.

If the owner of the actor unit doesn't have the knowledge needed to know for sure if the unit can act TRUE will be returned.

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 6942 of file actions.cpp.

Referenced by action_tgt_city().

◆ may_unit_act_vs_tile_extra()

static bool may_unit_act_vs_tile_extra ( const struct unit actor,
const struct tile tgt_tile,
const struct extra_type tgt_extra,
bool  accept_all_actions 
)
static

Returns TRUE iff, from the point of view of the owner of the actor unit, it looks like the actor unit may be able to do any action to the target extra located at the target tile.

If the owner of the actor unit doesn't have the knowledge needed to know for sure if the unit can act TRUE will be returned.

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 7142 of file actions.cpp.

◆ may_unit_act_vs_unit()

static bool may_unit_act_vs_unit ( struct unit actor,
struct unit target,
bool  accept_all_actions 
)
static

Returns TRUE iff, from the point of view of the owner of the actor unit, it looks like the actor unit may be able to do any action to the target unit.

If the owner of the actor unit doesn't have the knowledge needed to know for sure if the unit can act TRUE will be returned.

If the only action(s) that can be performed against a target has the rare_pop_up property the target will only be considered valid if the accept_all_actions argument is TRUE.

Definition at line 7008 of file actions.cpp.

Referenced by action_tgt_unit().

◆ oblig_hard_req_reg()

static void oblig_hard_req_reg ( struct ae_contra_or contras,
const char *  error_message,
  ... 
)
static

Register an obligatory hard requirement for the specified action results.

Parameters
contrasif one alternative here doesn't contradict the enabler it is accepted.
error_messageerror message if an enabler contradicts all contras. Followed by a list of action results that should be unable to contradict all specified contradictions.

Definition at line 228 of file actions.cpp.

Referenced by hard_code_oblig_hard_reqs().

◆ oblig_hard_req_register()

static void oblig_hard_req_register ( const struct requirement contradiction,
bool  is_target,
const char *  error_message,
  ... 
)
static

Register an obligatory hard requirement for the action results it applies to.

The vararg parameter is a list of action ids it applies to terminated by ACTION_NONE.

Definition at line 247 of file actions.cpp.

Referenced by hard_code_oblig_hard_reqs(), and hard_code_oblig_hard_reqs_ruleset().

◆ plr_knows_tile()

static bool plr_knows_tile ( const struct player plr,
const struct tile ttile 
)
static

Returns TRUE iff the specified player knows (has seen) the specified tile.

Definition at line 2367 of file actions.cpp.

◆ plr_sees_tile()

static bool plr_sees_tile ( const struct player plr,
const struct tile ttile 
)
static

Returns TRUE iff the specified player can see the specified tile.

Definition at line 2376 of file actions.cpp.

◆ req_contradiction_or()

static struct ae_contra_or* req_contradiction_or ( int  alternatives,
  ... 
)
static

Returns a new array of alternative action enabler contradictions.

Only one has to not contradict the enabler for it to be seen as fulfilled.

Parameters
alternativesthe number of action enabler contradictions followed by the enabler contradictions specified as alternating contradicting requirement and a bool that is TRUE if the requirement contradicts the enabler's target requirement vector and FALSE if it contradicts the enabler's actor vector.
Returns
a new array of alternative action enabler contradictions.

Definition at line 143 of file actions.cpp.

Referenced by hard_code_oblig_hard_reqs(), and oblig_hard_req_register().

◆ req_vec_first_contradiction_in_vec()

static struct requirement* req_vec_first_contradiction_in_vec ( const struct requirement req,
const struct requirement_vector *  vec 
)
static

Returns the first requirement in the specified requirement vector that contradicts the specified requirement or nullptr if no contradiction was detected.

Parameters
reqthe requirement that may contradict the vector
vecthe requirement vector to look in
Returns
the first local DiplRel requirement.

Definition at line 2023 of file actions.cpp.

Referenced by enabler_first_self_contradiction(), and enabler_tile_tgt_local_diplrel_implies_claimed().

◆ req_vec_first_local_diplrel()

static struct requirement* req_vec_first_local_diplrel ( const struct requirement_vector *  vec)
static

Returns the first local DiplRel requirement in the specified requirement vector or nullptr if it doesn't have a local DiplRel requirement.

Parameters
vecthe requirement vector to look in
Returns
the first local DiplRel requirement.

Definition at line 2001 of file actions.cpp.

Referenced by enabler_first_self_contradiction(), and enabler_tile_tgt_local_diplrel_implies_claimed().

◆ tech_can_be_stolen()

static enum fc_tristate tech_can_be_stolen ( const struct player actor_player,
const struct player target_player 
)
static

Does the target has any techs the actor don't?

Definition at line 4264 of file actions.cpp.

◆ tgt_city_local_building()

static const struct impr_type* tgt_city_local_building ( const struct city target_city)
static

Returns the local building type of a city target.

target_city can't be nullptr

Definition at line 2387 of file actions.cpp.

Referenced by is_action_enabled_unit_on_city_full().

◆ tgt_city_local_utype()

static const struct unit_type* tgt_city_local_utype ( const struct city target_city)
static

Returns the local unit type of a city target.

target_city can't be nullptr

Definition at line 2410 of file actions.cpp.

Referenced by is_action_enabled_unit_on_city_full().

◆ unit_action_new()

static struct action * unit_action_new ( action_id  id,
enum action_result  result,
enum action_target_kind  target_kind,
enum action_sub_target_kind  sub_target_kind,
enum act_tgt_compl  tgt_compl,
bool  rare_pop_up,
bool  unitwaittime_controlled,
enum moves_actor_kind  moves_actor,
const int  min_distance,
const int  max_distance,
bool  actor_consuming_always 
)
static

Create a new action performed by a unit actor.

Definition at line 1114 of file actions.cpp.

Referenced by hard_code_actions().

◆ voblig_hard_req_reg()

static void voblig_hard_req_reg ( struct ae_contra_or contras,
const char *  error_message,
va_list  args 
)
static

Register an obligatory hard requirement for the specified action results.

Parameters
contrasif one alternative here doesn't contradict the enabler it is accepted.
error_messageerror message if an enabler contradicts all contras.
argslist of action results that should be unable to contradict all specified contradictions.

Definition at line 190 of file actions.cpp.

Referenced by oblig_hard_req_reg(), and oblig_hard_req_register().

Variable Documentation

◆ action_enablers_by_action

struct action_enabler_list* action_enablers_by_action[MAX_NUM_ACTIONS]
static

Definition at line 96 of file actions.cpp.

Referenced by action_enablers_for_action(), actions_free(), and actions_init().

◆ actions

◆ actions_initialized

bool actions_initialized = false
static

Definition at line 93 of file actions.cpp.

Referenced by actions_are_ready(), actions_free(), and actions_init().

◆ auto_perfs

◆ obligatory_hard_reqs

struct obligatory_req_vector obligatory_hard_reqs[ACTRES_NONE]
static