Freeciv-3.1
|
#include "astring.h"
#include "fc_types.h"
#include "map_types.h"
#include "specenum_gen.h"
#include "specvec.h"
Go to the source code of this file.
Data Structures | |
struct | requirement |
struct | req_context |
struct | req_vec_change |
struct | req_vec_problem |
Macros | |
#define | SPECENUM_NAME req_range |
#define | SPECENUM_VALUE0 REQ_RANGE_LOCAL |
#define | SPECENUM_VALUE0NAME "Local" |
#define | SPECENUM_VALUE1 REQ_RANGE_CADJACENT |
#define | SPECENUM_VALUE1NAME "CAdjacent" |
#define | SPECENUM_VALUE2 REQ_RANGE_ADJACENT |
#define | SPECENUM_VALUE2NAME "Adjacent" |
#define | SPECENUM_VALUE3 REQ_RANGE_CITY |
#define | SPECENUM_VALUE3NAME "City" |
#define | SPECENUM_VALUE4 REQ_RANGE_TRADE_ROUTE |
#define | SPECENUM_VALUE4NAME "Traderoute" |
#define | SPECENUM_VALUE5 REQ_RANGE_CONTINENT |
#define | SPECENUM_VALUE5NAME "Continent" |
#define | SPECENUM_VALUE6 REQ_RANGE_PLAYER |
#define | SPECENUM_VALUE6NAME "Player" |
#define | SPECENUM_VALUE7 REQ_RANGE_TEAM |
#define | SPECENUM_VALUE7NAME "Team" |
#define | SPECENUM_VALUE8 REQ_RANGE_ALLIANCE |
#define | SPECENUM_VALUE8NAME "Alliance" |
#define | SPECENUM_VALUE9 REQ_RANGE_WORLD |
#define | SPECENUM_VALUE9NAME "World" |
#define | SPECENUM_COUNT REQ_RANGE_COUNT /* Keep this last */ |
#define | REQ_RANGE_MAX (REQ_RANGE_COUNT - 1) /* REQ_RANGE_WORLD */ |
#define | req_range_iterate(_range_) |
#define | req_range_iterate_end |
#define | SPECVEC_TAG requirement |
#define | SPECVEC_TYPE struct requirement |
#define | requirement_vector_iterate(req_vec, preq) TYPED_VECTOR_ITERATE(struct requirement, req_vec, preq) |
#define | requirement_vector_iterate_end VECTOR_ITERATE_END |
#define | SPECENUM_NAME req_vec_change_operation |
#define | SPECENUM_VALUE0 RVCO_REMOVE |
#define | SPECENUM_VALUE0NAME N_("Remove") |
#define | SPECENUM_VALUE1 RVCO_APPEND |
#define | SPECENUM_VALUE1NAME N_("Append") |
#define | SPECENUM_COUNT RVCO_NOOP |
#define | universal_is_mentioned_by_requirement(preq, psource) are_universals_equal(&preq->source, psource) |
#define | universals_iterate(_univ_) |
#define | universals_iterate_end |
#define | requirement_fulfilled_by_government(_gov_, _rqs_) |
#define | requirement_fulfilled_by_nation(_nat_, _rqs_) |
#define | requirement_fulfilled_by_improvement(_imp_, _rqs_) |
#define | requirement_fulfilled_by_terrain(_ter_, _rqs_) |
#define | requirement_fulfilled_by_unit_class(_uc_, _rqs_) |
#define | requirement_fulfilled_by_unit_type(_ut_, _rqs_) |
#define | requirement_fulfilled_by_extra(_ex_, _rqs_) |
#define | requirement_fulfilled_by_output_type(_o_, _rqs_) |
#define | requirement_fulfilled_by_action(_act_, _rqs_) |
#define | requirement_needs_improvement(_imp_, _rqs_) |
#define | requirement_diplrel_ereq(_id_, _range_, _present_) requirement_kind_ereq(_id_, _range_, _present_, DRO_LAST) |
Typedefs | |
typedef enum req_unchanging_status(* | req_unchanging_cond_cb) (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req) |
typedef enum fc_tristate(* | req_tester_cb) (const struct req_context *context, const struct player *other_player, const struct requirement *req, void *data, int n_data) |
typedef signed char | req_vec_num_in_item |
req_vec_num_in_item a requirement vectors number in an item. | |
typedef req_vec_num_in_item(* | requirement_vector_number) (const void *parent_item, const struct requirement_vector *vec) |
typedef struct requirement_vector *(* | requirement_vector_by_number) (const void *parent_item, req_vec_num_in_item number) |
typedef const char *(* | requirement_vector_namer) (req_vec_num_in_item number) |
Enumerations | |
enum | req_unchanging_status { REQUCH_NO = 0 , REQUCH_CTRL , REQUCH_ACT , REQUCH_SCRIPTS , REQUCH_HACK , REQUCH_YES } |
enum | req_item_found { ITF_NO , ITF_YES , ITF_NOT_APPLICABLE } |
Functions | |
const struct req_context * | req_context_empty (void) |
struct requirement | req_from_str (const char *type, const char *range, bool survives, bool present, bool quiet, const char *value) |
const char * | req_to_fstring (const struct requirement *req, struct astring *astr) |
void | req_get_values (const struct requirement *req, int *type, int *range, bool *survives, bool *present, bool *quiet, int *value) |
struct requirement | req_from_values (int type, int range, bool survives, bool present, bool quiet, int value) |
void | req_copy (struct requirement *dst, const struct requirement *src) |
bool | are_requirements_equal (const struct requirement *req1, const struct requirement *req2) |
bool | are_requirements_contradictions (const struct requirement *req1, const struct requirement *req2) |
bool | req_implies_req (const struct requirement *req1, const struct requirement *req2) |
bool | does_req_contradicts_reqs (const struct requirement *req, const struct requirement_vector *vec) |
enum fc_tristate | tri_req_active (const struct req_context *context, const struct player *other_player, const struct requirement *req) |
bool | is_req_active (const struct req_context *context, const struct player *other_player, const struct requirement *req, const enum req_problem_type prob_type) |
bool | are_reqs_active (const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, const enum req_problem_type prob_type) |
enum fc_tristate | tri_req_active_turns (int pass, int period, const struct req_context *context, const struct player *other_player, const struct requirement *req) |
enum fc_tristate | default_tester_cb (const struct req_context *context, const struct player *other_player, const struct requirement *req, void *data, int n_data) |
enum fc_tristate | tri_reqs_cb_active (const struct req_context *context, const struct player *other_player, const struct requirement_vector *reqs, struct requirement_vector *maybe_reqs, req_tester_cb tester, void *data, int n_data) |
enum req_unchanging_status | is_req_unchanging (const struct req_context *context, const struct requirement *req) |
enum req_unchanging_status | is_req_preventing (const struct req_context *context, const struct player *other_player, const struct requirement *req, enum req_problem_type prob_type) |
bool | is_req_in_vec (const struct requirement *req, const struct requirement_vector *vec) |
bool | req_vec_wants_type (const struct requirement_vector *reqs, enum universals_n kind) |
bool | universal_never_there (const struct universal *source) |
bool | req_is_impossible_to_fulfill (const struct requirement *req) |
bool | req_vec_is_impossible_to_fulfill (const struct requirement_vector *reqs) |
req_vec_num_in_item | req_vec_vector_number (const void *parent_item, const struct requirement_vector *vec) |
struct requirement_vector * | req_vec_by_number (const void *parent_item, req_vec_num_in_item number) |
const char * | req_vec_change_translation (const struct req_vec_change *change, const requirement_vector_namer namer) |
bool | req_vec_change_apply (const struct req_vec_change *modification, requirement_vector_by_number getter, const void *parent_item) |
struct req_vec_problem * | req_vec_problem_new (int num_suggested_solutions, const char *description,...) |
struct req_vec_problem * | req_vec_problem_new_transl (int num_suggested_solutions, const char *description, const char *description_translated) |
void | req_vec_problem_free (struct req_vec_problem *issue) |
struct req_vec_problem * | req_vec_get_first_contradiction (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item) |
struct req_vec_problem * | req_vec_suggest_repair (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item) |
struct req_vec_problem * | req_vec_get_first_missing_univ (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item) |
struct req_vec_problem * | req_vec_get_first_redundant_req (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item) |
struct req_vec_problem * | req_vec_suggest_improvement (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item) |
int | universal_number (const struct universal *source) |
struct universal | universal_by_number (const enum universals_n kind, const int value) |
struct universal | universal_by_rule_name (const char *kind, const char *value) |
void | universal_value_from_str (struct universal *source, const char *value) |
void | universal_copy (struct universal *dst, const struct universal *src) |
void | universal_extraction (const struct universal *source, int *kind, int *value) |
bool | are_universals_equal (const struct universal *psource1, const struct universal *psource2) |
const char * | universal_rule_name (const struct universal *psource) |
const char * | universal_name_translation (const struct universal *psource, char *buf, size_t bufsz) |
const char * | universal_type_rule_name (const struct universal *psource) |
int | universal_build_shield_cost (const struct city *pcity, const struct universal *target) |
bool | universal_replace_in_req_vec (struct requirement_vector *reqs, const struct universal *to_replace, const struct universal *replacement) |
bool | universal_is_legal_in_requirement (const struct universal *univ) |
bool | universal_is_mentioned_by_requirements (const struct requirement_vector *reqs, const struct universal *psource) |
void | universal_found_functions_init (void) |
enum req_item_found | universal_fulfills_requirement (const struct requirement *preq, const struct universal *source) |
bool | universal_fulfills_requirements (bool check_necessary, const struct requirement_vector *reqs, const struct universal *source) |
bool | universal_is_relevant_to_requirement (const struct requirement *req, const struct universal *source) |
bool | universals_mean_unfulfilled (struct requirement_vector *reqs, struct universal *unis, size_t n_unis) |
bool | universals_say_everything (struct requirement_vector *reqs, struct universal *unis, size_t n_unis) |
int | requirement_kind_ereq (const int value, const enum req_range range, const bool present, const int max_value) |
#define req_range_iterate | ( | _range_ | ) |
Definition at line 64 of file requirements.h.
#define req_range_iterate_end |
Definition at line 70 of file requirements.h.
#define REQ_RANGE_MAX (REQ_RANGE_COUNT - 1) /* REQ_RANGE_WORLD */ |
Definition at line 61 of file requirements.h.
#define requirement_diplrel_ereq | ( | _id_, | |
_range_, | |||
_present_ | |||
) | requirement_kind_ereq(_id_, _range_, _present_, DRO_LAST) |
Definition at line 441 of file requirements.h.
#define requirement_fulfilled_by_action | ( | _act_, | |
_rqs_ | |||
) |
Definition at line 427 of file requirements.h.
#define requirement_fulfilled_by_extra | ( | _ex_, | |
_rqs_ | |||
) |
Definition at line 421 of file requirements.h.
#define requirement_fulfilled_by_government | ( | _gov_, | |
_rqs_ | |||
) |
Definition at line 401 of file requirements.h.
#define requirement_fulfilled_by_improvement | ( | _imp_, | |
_rqs_ | |||
) |
Definition at line 407 of file requirements.h.
#define requirement_fulfilled_by_nation | ( | _nat_, | |
_rqs_ | |||
) |
Definition at line 404 of file requirements.h.
#define requirement_fulfilled_by_output_type | ( | _o_, | |
_rqs_ | |||
) |
Definition at line 424 of file requirements.h.
#define requirement_fulfilled_by_terrain | ( | _ter_, | |
_rqs_ | |||
) |
Definition at line 411 of file requirements.h.
#define requirement_fulfilled_by_unit_class | ( | _uc_, | |
_rqs_ | |||
) |
Definition at line 415 of file requirements.h.
#define requirement_fulfilled_by_unit_type | ( | _ut_, | |
_rqs_ | |||
) |
Definition at line 418 of file requirements.h.
#define requirement_needs_improvement | ( | _imp_, | |
_rqs_ | |||
) |
Definition at line 431 of file requirements.h.
#define requirement_vector_iterate | ( | req_vec, | |
preq | |||
) | TYPED_VECTOR_ITERATE(struct requirement, req_vec, preq) |
Definition at line 91 of file requirements.h.
#define requirement_vector_iterate_end VECTOR_ITERATE_END |
Definition at line 93 of file requirements.h.
#define SPECENUM_COUNT REQ_RANGE_COUNT /* Keep this last */ |
Definition at line 60 of file requirements.h.
#define SPECENUM_COUNT RVCO_NOOP |
Definition at line 60 of file requirements.h.
#define SPECENUM_NAME req_range |
Definition at line 38 of file requirements.h.
#define SPECENUM_NAME req_vec_change_operation |
Definition at line 38 of file requirements.h.
#define SPECENUM_VALUE0 REQ_RANGE_LOCAL |
Definition at line 39 of file requirements.h.
#define SPECENUM_VALUE0 RVCO_REMOVE |
Definition at line 39 of file requirements.h.
#define SPECENUM_VALUE0NAME "Local" |
Definition at line 40 of file requirements.h.
#define SPECENUM_VALUE0NAME N_("Remove") |
Definition at line 40 of file requirements.h.
#define SPECENUM_VALUE1 REQ_RANGE_CADJACENT |
Definition at line 41 of file requirements.h.
#define SPECENUM_VALUE1 RVCO_APPEND |
Definition at line 41 of file requirements.h.
#define SPECENUM_VALUE1NAME "CAdjacent" |
Definition at line 42 of file requirements.h.
#define SPECENUM_VALUE1NAME N_("Append") |
Definition at line 42 of file requirements.h.
#define SPECENUM_VALUE2 REQ_RANGE_ADJACENT |
Definition at line 43 of file requirements.h.
#define SPECENUM_VALUE2NAME "Adjacent" |
Definition at line 44 of file requirements.h.
#define SPECENUM_VALUE3 REQ_RANGE_CITY |
Definition at line 45 of file requirements.h.
#define SPECENUM_VALUE3NAME "City" |
Definition at line 46 of file requirements.h.
#define SPECENUM_VALUE4 REQ_RANGE_TRADE_ROUTE |
Definition at line 47 of file requirements.h.
#define SPECENUM_VALUE4NAME "Traderoute" |
Definition at line 49 of file requirements.h.
#define SPECENUM_VALUE5 REQ_RANGE_CONTINENT |
Definition at line 50 of file requirements.h.
#define SPECENUM_VALUE5NAME "Continent" |
Definition at line 51 of file requirements.h.
#define SPECENUM_VALUE6 REQ_RANGE_PLAYER |
Definition at line 52 of file requirements.h.
#define SPECENUM_VALUE6NAME "Player" |
Definition at line 53 of file requirements.h.
#define SPECENUM_VALUE7 REQ_RANGE_TEAM |
Definition at line 54 of file requirements.h.
#define SPECENUM_VALUE7NAME "Team" |
Definition at line 55 of file requirements.h.
#define SPECENUM_VALUE8 REQ_RANGE_ALLIANCE |
Definition at line 56 of file requirements.h.
#define SPECENUM_VALUE8NAME "Alliance" |
Definition at line 57 of file requirements.h.
#define SPECENUM_VALUE9 REQ_RANGE_WORLD |
Definition at line 58 of file requirements.h.
#define SPECENUM_VALUE9NAME "World" |
Definition at line 59 of file requirements.h.
#define SPECVEC_TAG requirement |
Definition at line 88 of file requirements.h.
#define SPECVEC_TYPE struct requirement |
Definition at line 89 of file requirements.h.
#define universal_is_mentioned_by_requirement | ( | preq, | |
psource | |||
) | are_universals_equal(&preq->source, psource) |
Definition at line 363 of file requirements.h.
#define universals_iterate | ( | _univ_ | ) |
Definition at line 388 of file requirements.h.
#define universals_iterate_end |
Definition at line 393 of file requirements.h.
typedef enum fc_tristate(* req_tester_cb) (const struct req_context *context, const struct player *other_player, const struct requirement *req, void *data, int n_data) |
Definition at line 177 of file requirements.h.
typedef enum req_unchanging_status(* req_unchanging_cond_cb) (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req) |
Definition at line 1 of file requirements.h.
typedef signed char req_vec_num_in_item |
req_vec_num_in_item a requirement vectors number in an item.
A ruleset item can have more than one requirement vector. This numbers them. Allows applying a change suggested based on one ruleset item to another ruleset item of the same kind - say to a copy.
Definition at line 229 of file requirements.h.
typedef struct requirement_vector *(* requirement_vector_by_number) (const void *parent_item, req_vec_num_in_item number) |
Returns a writable pointer to the specified requirement vector in the specified parent item or NULL if the parent item doesn't have a requirement vector with that requirement vector number.
parent_item | the item that should have the requirement vector. |
number | the item's requirement vector number. |
Definition at line 239 of file requirements.h.
typedef const char *(* requirement_vector_namer) (req_vec_num_in_item number) |
Returns the name of the specified requirement vector number in the parent item or NULL if parent items of the kind this function is for don't have a requirement vector with that number.
number | the requirement vector to name |
Definition at line 262 of file requirements.h.
typedef req_vec_num_in_item(* requirement_vector_number) (const void *parent_item, const struct requirement_vector *vec) |
Returns the requirement vector number of the specified requirement vector in the specified parent item or -1 if the vector doesn't belong to the parent item.
parent_item | the item that may own the vector. |
vec | the requirement vector to number. |
Definition at line 239 of file requirements.h.
enum req_item_found |
Enumerator | |
---|---|
ITF_NO | |
ITF_YES | |
ITF_NOT_APPLICABLE |
Definition at line 370 of file requirements.h.
Enumerator | |
---|---|
REQUCH_NO | |
REQUCH_CTRL | |
REQUCH_ACT | |
REQUCH_SCRIPTS | |
REQUCH_HACK | |
REQUCH_YES |
Definition at line 113 of file requirements.h.
bool are_reqs_active | ( | const struct req_context * | context, |
const struct player * | other_player, | ||
const struct requirement_vector * | reqs, | ||
const enum req_problem_type | prob_type | ||
) |
Checks the requirement(s) to see if they are active on the given target.
context gives the target (or targets) to evaluate against
reqs gives the requirement vector. The function returns TRUE only if all requirements are active.
context may be NULL. This is equivalent to passing an empty context.
Make sure you give all aspects of the target when calling this function: for instance if you have TARGET_CITY pass the city's owner as the target player as well as the city itself as the target city.
Definition at line 4361 of file requirements.c.
Referenced by action_auto_perf_unit_sel(), add_clause(), are_road_reqs_fulfilled(), can_build_base(), can_build_extra(), can_change_to_government(), can_city_build_improvement_direct(), can_city_build_unit_direct(), can_disaster_happen(), can_extra_appear(), can_extra_disappear(), can_remove_extra(), can_unit_do_connect(), city_can_use_specialist(), city_style(), get_target_bonus_effects(), get_tile_infrastructure_set(), get_tile_value(), goods_can_be_provided(), handle_diplomacy_accept_treaty_req(), is_enabler_active(), is_native_tile_to_extra(), is_native_tile_to_road(), is_target_possible(), multiplier_can_be_changed(), player_can_build_base(), player_can_build_extra(), player_can_remove_extra(), player_music_style(), sg_special_set(), unit_can_displace_hut(), unit_can_enter_hut(), and unit_enter_hut().
bool are_requirements_contradictions | ( | const struct requirement * | req1, |
const struct requirement * | req2 | ||
) |
Returns TRUE if req1 and req2 contradicts each other.
TODO: If information about what entity each requirement type will be evaluated against is passed it will become possible to detect stuff like that an unclaimed tile contradicts all DiplRel requirements against it.
Definition at line 1438 of file requirements.c.
Referenced by default_tester_cb(), does_req_contradicts_reqs(), req_implies_req(), req_vec_first_contradiction_in_vec(), and req_vec_get_first_contradiction().
bool are_requirements_equal | ( | const struct requirement * | req1, |
const struct requirement * | req2 | ||
) |
Returns TRUE if req1 and req2 are equal. Does not care if one is quiet and the other not.
Definition at line 1296 of file requirements.c.
Referenced by req_edit::incoming_req_vec_change(), is_req_in_vec(), purge_duplicate_req_vec(), req_vec_change_apply(), req_vec_get_first_redundant_req(), send_packet_ruleset_action_auto_100(), send_packet_ruleset_action_enabler_100(), send_packet_ruleset_building_100(), send_packet_ruleset_city_100(), send_packet_ruleset_clause_100(), send_packet_ruleset_disaster_100(), send_packet_ruleset_effect_100(), send_packet_ruleset_extra_100(), send_packet_ruleset_goods_100(), send_packet_ruleset_government_100(), send_packet_ruleset_multiplier_100(), send_packet_ruleset_music_100(), send_packet_ruleset_road_100(), send_packet_ruleset_specialist_100(), send_packet_ruleset_tech_100(), and send_packet_ruleset_unit_100().
Return TRUE iff the two sources are equivalent. Note this isn't the same as an == or memcmp check.
Definition at line 5278 of file requirements.c.
Referenced by add_target_to_production(), add_target_to_worklist(), are_requirements_equal(), are_requirements_opposites(), are_worklists_equal(), change_build_target(), city_building_impr_or_unit(), city_dialog_update_building(), city_set_queue(), city_worklist_commit(), client_change_all(), clipboard_send_production_packet(), handle_city_change(), handle_city_info(), insert_allows_single(), ok_worklist_editor_callback(), and ruledit_gui::open_effect_edit().
enum fc_tristate default_tester_cb | ( | const struct req_context * | context, |
const struct player * | other_player, | ||
const struct requirement * | req, | ||
void * | data, | ||
int | n_data | ||
) |
A tester callback for tri_reqs_cb_active() that uses the default requirement calculation except for requirements in data[n_data] array and ones implied by them or contradicting them
Definition at line 4495 of file requirements.c.
bool does_req_contradicts_reqs | ( | const struct requirement * | req, |
const struct requirement_vector * | vec | ||
) |
Returns TRUE if the given requirement contradicts the given requirement vector.
Definition at line 1539 of file requirements.c.
Referenced by ae_suggest_repair_if_no_oblig(), city_production_caravan_shields_init(), local_dipl_rel_action_cache_set(), local_dipl_rel_tile_other_tgt_action_cache_set(), and utype_may_act_tgt_city_tile().
bool is_req_active | ( | const struct req_context * | context, |
const struct player * | other_player, | ||
const struct requirement * | req, | ||
const enum req_problem_type | prob_type | ||
) |
Checks the requirement to see if it is active on the given target.
context gives the target (or targets) to evaluate against req gives the requirement itself
context may be NULL. This is equivalent to passing an empty context.
Make sure you give all aspects of the target when calling this function: for instance if you have TARGET_CITY pass the city's owner as the target player as well as the city itself as the target city.
Definition at line 4268 of file requirements.c.
Referenced by adjust_improvement_wants_by_effects(), adjust_wants_for_reqs(), adv_units_ruleset_init(), are_reqs_active(), can_player_build_improvement_direct(), can_player_build_unit_direct(), city_landlocked_sell_coastal_improvements(), dai_cant_help_req(), dai_find_source_building(), dai_gov_value(), dai_tech_effect_values(), dai_wants_defender_against(), get_potential_improvement_bonus(), improvement_obsolete(), is_effect_prevented(), is_req_preventing(), mke_eval_req(), utype_needs_improvement(), and worklist_item_postpone_req_vec().
bool is_req_in_vec | ( | const struct requirement * | req, |
const struct requirement_vector * | vec | ||
) |
Returns TRUE iff the requirement vector vec contains the requirement req.
Definition at line 4649 of file requirements.c.
Referenced by rscompat_postprocess(), tgt_citytile_act_cache_set(), and unit_state_action_cache_set().
enum req_unchanging_status is_req_preventing | ( | const struct req_context * | context, |
const struct player * | other_player, | ||
const struct requirement * | req, | ||
enum req_problem_type | prob_type | ||
) |
Returns whether this requirement is unfulfilled and probably won't be ever
Definition at line 4619 of file requirements.c.
Referenced by can_city_build_improvement_later(), can_player_build_improvement_later(), dai_cant_help_req(), reqs_may_activate(), and tactical_req_cb().
enum req_unchanging_status is_req_unchanging | ( | const struct req_context * | context, |
const struct requirement * | req | ||
) |
Gives a suggestion may req ever evaluate to another value with given context. (The other player is not supplied since it has no value for changeability of any requirement for now.)
Note this isn't absolute. Result other than REQUCH_NO here just means that the requirement probably can't change its value afterwards.
Definition at line 4571 of file requirements.c.
Referenced by is_req_preventing(), and sanity_check_ruleset_data().
const struct req_context * req_context_empty | ( | void | ) |
Returns a pointer to a statically-allocated, empty requirement context.
Definition at line 901 of file requirements.c.
Referenced by action_enabled_local(), action_hard_reqs_actor(), action_prob(), get_effect_expected_value(), get_target_bonus_effects(), is_action_possible(), is_req_knowable(), and tri_req_present().
void req_copy | ( | struct requirement * | dst, |
const struct requirement * | src | ||
) |
Fill in copy of the requirement.
Definition at line 1283 of file requirements.c.
Referenced by req_implies_req().
struct requirement req_from_str | ( | const char * | type, |
const char * | range, | ||
bool | survives, | ||
bool | present, | ||
bool | quiet, | ||
const char * | value | ||
) |
Parse a requirement type and value string into a requirement structure. Returns the invalid element for enum universal_n on error. Passing in a NULL type is considered VUT_NONE (not an error).
Pass this some values like "Building", "Factory".
Definition at line 938 of file requirements.c.
Referenced by effect_edit::add_now(), effect_list_compat_cb(), load_ruleset_cities(), lookup_req_list(), paratroopers_mr_sub_to_effect(), rscompat_old_slow_invasions_3_1(), rscompat_postprocess(), slow_invasion_effects(), and slow_invasion_enablers().
struct requirement req_from_values | ( | int | type, |
int | range, | ||
bool | survives, | ||
bool | present, | ||
bool | quiet, | ||
int | value | ||
) |
Set the values of a req from serializable integers. This is the opposite of req_get_values.
Definition at line 1249 of file requirements.c.
Referenced by req_edit::add_now(), dio_get_requirement_raw(), effect_to_enabler(), hard_code_oblig_hard_reqs(), hard_code_oblig_hard_reqs_ruleset(), load_action_auto_uflag_block(), load_action_post_success_force(), load_ruleset_units(), rscompat_auto_attack_3_1(), rscompat_old_slow_invasions_3_1(), rscompat_postprocess(), rscompat_req_vec_adjust_3_1(), send_ruleset_techs(), slow_invasion_effects(), and slow_invasion_enablers().
void req_get_values | ( | const struct requirement * | req, |
int * | type, | ||
int * | range, | ||
bool * | survives, | ||
bool * | present, | ||
bool * | quiet, | ||
int * | value | ||
) |
Return the value of a req as a serializable integer. This is the opposite of req_set_value.
Definition at line 1268 of file requirements.c.
Referenced by dio_put_requirement_raw().
bool req_implies_req | ( | const struct requirement * | req1, |
const struct requirement * | req2 | ||
) |
Returns TRUE if req2 is always fulfilled when req1 is (i.e. req1 => req2)
Definition at line 1421 of file requirements.c.
Referenced by default_tester_cb().
bool req_is_impossible_to_fulfill | ( | const struct requirement * | req | ) |
Returns TRUE iff the specified requirement is known to be impossible to fulfill. Note that this function may return FALSE even when it is impossible to fulfill a requirement if it can't detect it.
req | the requirement to check the possibility of. |
Definition at line 4756 of file requirements.c.
Referenced by req_vec_is_impossible_to_fulfill().
const char * req_to_fstring | ( | const struct requirement * | req, |
struct astring * | astr | ||
) |
Returns the given requirement as a formatted string ready for printing. Does not care about the 'quiet' property.
astring does not need to be initialized before the call, but caller needs to call astr_free() for it once the returned string is no longer needed.
Definition at line 916 of file requirements.c.
Referenced by effect_list_sanity_cb(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), req_vec_change_translation(), req_vec_get_first_contradiction(), req_vec_get_first_missing_univ(), req_vec_get_first_redundant_req(), sanity_check_ruleset_data(), and save_action_auto_uflag_block().
struct requirement_vector * req_vec_by_number | ( | const void * | parent_item, |
req_vec_num_in_item | number | ||
) |
Returns a writable pointer to the specified requirement vector in the specified requirement vector or NULL if the parent item doesn't have a requirement vector with that requirement vector number.
parent_item | the item that should have the requirement vector. |
number | the item's requirement vector number. |
Definition at line 4808 of file requirements.c.
Referenced by purge_duplicate_req_vec(), and purge_unused_req_vec().
bool req_vec_change_apply | ( | const struct req_vec_change * | modification, |
requirement_vector_by_number | getter, | ||
const void * | parent_item | ||
) |
Returns TRUE iff the specified requirement vector modification was successfully applied to the specified target requirement vector.
modification | the requirement vector change |
getter | a function that returns a pointer to the requirement vector the change should be applied to given a ruleset item and the vectors number in the item. |
parent_item | the item to apply the change to. |
Definition at line 4897 of file requirements.c.
Referenced by req_vec_fix::apply_solution(), purge_duplicate_req_vec(), purge_unused_req_vec(), and rscompat_enabler_add_obligatory_hard_reqs().
const char * req_vec_change_translation | ( | const struct req_vec_change * | change, |
const requirement_vector_namer | namer | ||
) |
Returns the specified requirement vector change as a translated string ready for use in the user interface. N.B.: The returned string is static, so every call to this function overwrites the previous.
change | the requirement vector change |
namer | a function that returns a description of the vector to change for the item the vector belongs to. |
Definition at line 4824 of file requirements.c.
Referenced by req_vec_fix::apply_solution(), req_vec_fix_problem::req_vec_fix_problem(), and rscompat_enabler_add_obligatory_hard_reqs().
struct req_vec_problem * req_vec_get_first_contradiction | ( | const struct requirement_vector * | vec, |
requirement_vector_number | get_num, | ||
const void * | parent_item | ||
) |
Returns the first self contradiction found in the specified requirement vector with suggested solutions or NULL if no contradiction was found. It is the responsibility of the caller to free the suggestion when it is done with it.
vec | the requirement vector to look in. |
get_num | function that returns the requirement vector's number in the parent item. |
parent_item | the item that owns the vector. |
Definition at line 5014 of file requirements.c.
Referenced by req_vec_suggest_repair().
struct req_vec_problem * req_vec_get_first_missing_univ | ( | const struct requirement_vector * | vec, |
requirement_vector_number | get_num, | ||
const void * | parent_item | ||
) |
Returns the first universal known to always be absent in the specified requirement vector with suggested solutions or NULL if no missing universals were found. It is the responsibility of the caller to free the suggestion when it is done with it.
vec | the requirement vector to look in. |
get_num | function that returns the requirement vector's number in the parent item. |
parent_item | the item that owns the vector. |
Definition at line 5100 of file requirements.c.
Referenced by purge_unused_req_vec(), and req_vec_suggest_improvement().
struct req_vec_problem * req_vec_get_first_redundant_req | ( | const struct requirement_vector * | vec, |
requirement_vector_number | get_num, | ||
const void * | parent_item | ||
) |
Returns the first redundant requirement in the specified requirement vector with suggested solutions or NULL if no redundant requirements were found. It is the responsibility of the caller to free the suggestion when it is done with it.
vec | the requirement vector to look in. |
get_num | function that returns the requirement vector's number in the parent item. |
parent_item | the item that owns the vector. |
Definition at line 5185 of file requirements.c.
Referenced by purge_duplicate_req_vec(), and req_vec_suggest_improvement().
bool req_vec_is_impossible_to_fulfill | ( | const struct requirement_vector * | reqs | ) |
Returns TRUE iff the specified requirement vector is known to be impossible to fulfill. Note that this function may return FALSE even when it is impossible to fulfill a requirement if it can't detect it.
reqs | the requirement vector to check the possibility of. |
Definition at line 4769 of file requirements.c.
Referenced by action_enabler_utype_possible_actor(), ruleset_purge_unused_effects(), and ruleset_purge_unused_enablers().
void req_vec_problem_free | ( | struct req_vec_problem * | issue | ) |
De-allocates resources associated with the given requirement vector problem.
issue | the no longer needed problem. |
Definition at line 4994 of file requirements.c.
Referenced by enabler_problem_level(), purge_duplicate_req_vec(), purge_unused_req_vec(), req_vec_fix::refresh(), req_vec_get_first_missing_univ(), rscompat_enabler_add_obligatory_hard_reqs(), sanity_check_req_vec(), sanity_check_ruleset_data(), and req_vec_fix::~req_vec_fix().
struct req_vec_problem * req_vec_problem_new | ( | int | num_suggested_solutions, |
const char * | descr, | ||
... | |||
) |
Returns a new requirement vector problem with the specified number of suggested solutions and the specified description. The suggestions are added by the caller.
num_suggested_solutions | the number of suggested solutions. |
descr | the description of the problem as a format string |
Definition at line 4969 of file requirements.c.
Referenced by action_enabler_suggest_improvement(), ae_suggest_repair_if_no_oblig(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), req_vec_get_first_contradiction(), req_vec_get_first_missing_univ(), and req_vec_get_first_redundant_req().
struct req_vec_problem * req_vec_problem_new_transl | ( | int | num_suggested_solutions, |
const char * | description, | ||
const char * | description_translated | ||
) |
Returns a new requirement vector problem with the specified number of suggested solutions and the specified description. The suggestions are added by the caller.
num_suggested_solutions | the number of suggested solutions. |
description | the description of the problem. |
description_translated | the translated description of the problem. |
Definition at line 4935 of file requirements.c.
Referenced by req_vec_problem_new().
struct req_vec_problem * req_vec_suggest_improvement | ( | const struct requirement_vector * | vec, |
requirement_vector_number | get_num, | ||
const void * | parent_item | ||
) |
Returns a suggestion to improve the specified requirement vector or NULL if nothing to improve is found. 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.
vec | the requirement vector to look in. |
get_num | function that returns the requirement vector's number in the parent item. |
parent_item | the item that owns the vector. |
Definition at line 5251 of file requirements.c.
Referenced by action_enabler_suggest_improvement().
struct req_vec_problem * req_vec_suggest_repair | ( | const struct requirement_vector * | vec, |
requirement_vector_number | get_num, | ||
const void * | parent_item | ||
) |
Returns a suggestion to fix the specified requirement vector or NULL 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.
vec | the requirement vector to look in. |
get_num | function that returns the requirement vector's number in the parent item. |
parent_item | the item that owns the vector. |
Definition at line 5079 of file requirements.c.
Referenced by action_enabler_suggest_repair(), req_vec_suggest_improvement(), and sanity_check_req_vec().
req_vec_num_in_item req_vec_vector_number | ( | const void * | parent_item, |
const struct requirement_vector * | vec | ||
) |
Returns the requirement vector number of the specified requirement vector in the specified requirement vector.
parent_item | the item that may own the vector. |
vec | the requirement vector to number. |
Definition at line 4789 of file requirements.c.
Referenced by purge_duplicate_req_vec(), purge_unused_req_vec(), and sanity_check_req_vec().
bool req_vec_wants_type | ( | const struct requirement_vector * | reqs, |
enum universals_n | kind | ||
) |
Returns TRUE iff the specified requirement vector has a positive requirement of the specified requirement type.
reqs | the requirement vector to look in |
kind | the requirement type to look for |
Definition at line 4667 of file requirements.c.
Referenced by city_production_caravan_shields_init().
int requirement_kind_ereq | ( | const int | value, |
const enum req_range | range, | ||
const bool | present, | ||
const int | max_value | ||
) |
Returns (the position of) the given requirement's enumerator in the enumeration of all possible requirements of its requirement kind.
Note: Since this isn't used for any requirement type that supports surviving requirements those aren't supported. Add support if a user appears.
Definition at line 6388 of file requirements.c.
enum fc_tristate tri_req_active | ( | const struct req_context * | context, |
const struct player * | other_player, | ||
const struct requirement * | req | ||
) |
Evaluates req in context with other_player to fc_tristate.
context may be NULL. This is equivalent to passing an empty context.
Fields of context that are NULL are considered unspecified and will produce TRI_MAYBE if req needs them to evaluate.
Definition at line 4328 of file requirements.c.
Referenced by default_tester_cb(), tactical_req_cb(), and tri_req_active_turns().
enum fc_tristate tri_req_active_turns | ( | int | pass, |
int | period, | ||
const struct req_context * | context, | ||
const struct player * | other_player, | ||
const struct requirement * | req | ||
) |
For requirements changing with time, will they be active for the target after pass in period turns if nothing else changes? Since year and calfrag changing is effect dependent, the result may appear not precise. (Does not consider research progress etc.)
Definition at line 4381 of file requirements.c.
Referenced by tactical_req_cb().
enum fc_tristate tri_reqs_cb_active | ( | const struct req_context * | context, |
const struct player * | other_player, | ||
const struct requirement_vector * | reqs, | ||
struct requirement_vector * | maybe_reqs, | ||
req_tester_cb | tester, | ||
void * | data, | ||
int | n_data | ||
) |
Test requirements in reqs with tester according to (data, n_data) and give the resulting tristate. If maybe_reqs is not NULL, copies requirements that are evaluated to TRI_MAYBE into it (stops as soon as one evaluates to TRI_NO).
Definition at line 4524 of file requirements.c.
Referenced by action_may_happen_unit_on_city().
Return the number of shields it takes to build this universal.
Definition at line 5819 of file requirements.c.
Referenced by city_production_build_shield_cost(), city_turns_to_build(), get_city_dialog_production_full(), and get_production_name().
struct universal universal_by_number | ( | const enum universals_n | kind, |
const int | value | ||
) |
Combine values into a universal structure. This is for serialization and is the opposite of universal_extraction(). FIXME: ensure that every caller checks error return!
Definition at line 567 of file requirements.c.
Referenced by dio_get_worklist_raw(), effect_list_compat_cb(), handle_city_change(), handle_city_info(), and req_from_values().
struct universal universal_by_rule_name | ( | const char * | kind, |
const char * | value | ||
) |
Parse requirement type (kind) and value strings into a universal structure. Passing in a NULL type is considered VUT_NONE (not an error).
Pass this some values like "Building", "Factory". FIXME: ensure that every caller checks error return!
Definition at line 231 of file requirements.c.
Referenced by global_worklists_build(), req_from_str(), sg_load_player_city(), sg_load_player_city(), worklist_load(), and worklist_load().
void universal_extraction | ( | const struct universal * | source, |
int * | kind, | ||
int * | value | ||
) |
Extract universal structure into its components for serialization; the opposite of universal_by_number().
Definition at line 780 of file requirements.c.
Referenced by get_req_source_effects(), req_get_values(), help_widget::set_topic_building(), and universal_value_cb().
void universal_found_functions_init | ( | void | ) |
Initialise universal_found_function array.
Definition at line 6359 of file requirements.c.
Referenced by game_init().
enum req_item_found universal_fulfills_requirement | ( | const struct requirement * | preq, |
const struct universal * | source | ||
) |
Will the universal 'source' fulfill this requirement?
Definition at line 5950 of file requirements.c.
Referenced by effect_value_from_universals(), present_implies_not_present(), universal_is_relevant_to_requirement(), and universals_say_everything().
bool universal_fulfills_requirements | ( | bool | check_necessary, |
const struct requirement_vector * | reqs, | ||
const struct universal * | source | ||
) |
Will the universal 'source' fulfill the requirements in the list? If 'check_necessary' is FALSE: are there no requirements that 'source' would actively prevent the fulfilment of? If 'check_necessary' is TRUE: does 'source' help the requirements to be fulfilled? (NB 'source' might not be the only source of its type that would be sufficient; for instance, if 'source' is a specific terrain type, we can return TRUE even if the requirement is only for something vague like a TerrainClass.)
Definition at line 5971 of file requirements.c.
Referenced by action_enabler_utype_possible_actor(), action_univs_not_blocking(), help_widget::add_extras_of_act_for_terrain(), effect_cumulative_min(), helptext_building(), and universals_mean_unfulfilled().
Returns TRUE iff the specified universal legally can appear in a requirement.
Definition at line 263 of file requirements.c.
Referenced by universal_kind_values().
bool universal_is_mentioned_by_requirements | ( | const struct requirement_vector * | reqs, |
const struct universal * | psource | ||
) |
Returns TRUE iff the universal 'psource' is directly mentioned by any of the requirements in 'reqs'.
Definition at line 5858 of file requirements.c.
Referenced by effect_handle_split_universal(), effect_list_fill_cb(), effect_list_universal_needed_cb(), and is_universal_needed().
bool universal_is_relevant_to_requirement | ( | const struct requirement * | req, |
const struct universal * | source | ||
) |
Returns TRUE iff the specified universal is relevant to fulfilling the specified requirement.
Definition at line 6008 of file requirements.c.
Referenced by helptext_building().
const char * universal_name_translation | ( | const struct universal * | psource, |
char * | buf, | ||
size_t | bufsz | ||
) |
Make user-friendly text for the source. The text is put into a user buffer which is also returned. This should be short, as it's used in lists like "Aqueduct+Size 8" when explaining a calculated value. It just needs to be enough to remind the player of rules they already know, not a complete explanation (use insert_requirement() for that).
Definition at line 5529 of file requirements.c.
Referenced by apply_disaster(), city_production_name_translation(), clipboard_copy_production(), diplomat_sabotage(), do_unit_strike_city_production(), get_city_dialog_production_full(), get_city_dialog_production_row(), get_city_mapview_production(), get_effect_req_text(), help_update_improvement(), help_update_wonder(), insert_allows_single(), manual_command(), popup_impr_info(), req_edit::refresh_item(), req_text_insert(), and help_widget::set_topic_building().
Returns TRUE iff the specified universal is known to never be there. Note that this function may return FALSE even when it is impossible for the universal to appear in the game if that can't be detected.
source | the universal to check the absence of. |
Definition at line 4685 of file requirements.c.
Referenced by ae_suggest_repair_if_no_oblig(), req_is_impossible_to_fulfill(), and req_vec_get_first_missing_univ().
int universal_number | ( | const struct universal * | source | ) |
Return the universal number of the constituent.
Definition at line 790 of file requirements.c.
Referenced by city_change_production(), clipboard_send_production_packet(), dio_put_worklist_raw(), package_city(), and universal_extraction().
bool universal_replace_in_req_vec | ( | struct requirement_vector * | reqs, |
const struct universal * | to_replace, | ||
const struct universal * | replacement | ||
) |
Replaces all instances of the universal to_replace with replacement in the requirement vector reqs and returns TRUE iff any requirements were replaced.
Definition at line 5838 of file requirements.c.
Referenced by effect_handle_split_universal().
const char * universal_rule_name | ( | const struct universal * | psource | ) |
Return the (untranslated) rule name of the universal. You don't have to free the return pointer.
Definition at line 5392 of file requirements.c.
Referenced by effect_edit::add_now(), define_orig_production_values(), effect_list_sanity_cb(), global_worklist_save(), global_worklists_unbuild(), req_to_fstring(), req_vec_get_first_missing_univ(), save_reqs_vector(), save_units_ruleset(), sg_save_player_cities(), and worklist_save().
const char * universal_type_rule_name | ( | const struct universal * | psource | ) |
Return untranslated name of the universal source name.
Definition at line 5811 of file requirements.c.
Referenced by effect_edit::add_now(), global_worklist_save(), global_worklists_unbuild(), req_to_fstring(), sanity_check_req_set(), sg_save_player_cities(), universal_fulfills_requirement(), universal_fulfills_requirements(), and worklist_save().
void universal_value_from_str | ( | struct universal * | source, |
const char * | value | ||
) |
Parse requirement value strings into a universal structure.
Definition at line 276 of file requirements.c.
Referenced by req_edit::univ_value_edit(), req_edit::univ_value_enum_menu(), and universal_by_rule_name().
bool universals_mean_unfulfilled | ( | struct requirement_vector * | reqs, |
struct universal * | unis, | ||
size_t | n_unis | ||
) |
Returns TRUE iff the presence of any of the specified universals is enough to guarantee that the specified requirement vector never will be fulfilled.
reqs | the requirement vector that never should be fulfilled |
unis | the universals that are present |
n_unis | the number of universals in unis |
Definition at line 5880 of file requirements.c.
Referenced by effect_cumulative_max(), and effect_universals_value_never_below().
bool universals_say_everything | ( | struct requirement_vector * | reqs, |
struct universal * | unis, | ||
size_t | n_unis | ||
) |
Returns TRUE iff the presence of the specified universals is enough to know if the specified requirement vector is fulfilled. This means that the requirement vector can't check anything it can't find in the listed universals. Note that TRUE is returned both when the requirement vector is known to be fulfilled and when it is known to be unfulfilled.
reqs | the requirement vector certainty is wanted about |
unis | the universals that are present |
n_unis | the number of universals in unis |
Definition at line 5913 of file requirements.c.
Referenced by effect_universals_value_never_below().