![]() |
Freeciv21
Develop your civilization from humble roots to a global empire
|
#include "fcintl.h"#include "log.h"#include "support.h"#include "achievements.h"#include "calendar.h"#include "citizens.h"#include "culture.h"#include "game.h"#include "government.h"#include "improvement.h"#include "map.h"#include "movement.h"#include "nation.h"#include "player.h"#include "research.h"#include "road.h"#include "server_settings.h"#include "specialist.h"#include "style.h"#include "requirements.h"
Include dependency graph for requirements.cpp:Go to the source code of this file.
Typedefs | |
| typedef enum req_item_found(* | universal_found) (const struct requirement *, const struct universal *) |
| Container for req_item_found functions. More... | |
Functions | |
| struct universal | universal_by_rule_name (const char *kind, const char *value) |
| Parse requirement type (kind) and value strings into a universal structure. More... | |
| void | universal_value_from_str (struct universal *source, const char *value) |
| Parse requirement value strings into a universal structure. More... | |
| struct universal | universal_by_number (const enum universals_n kind, const int value) |
| Combine values into a universal structure. More... | |
| 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(). More... | |
| int | universal_number (const struct universal *source) |
| Return the universal number of the constituent. More... | |
| QString | req_to_fstring (const struct requirement *req) |
| Returns the given requirement as a formatted string ready for printing. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| bool | are_requirements_equal (const struct requirement *req1, const struct requirement *req2) |
| Returns TRUE if req1 and req2 are equal. More... | |
| static bool | are_requirements_opposites (const struct requirement *req1, const struct requirement *req2) |
| Returns TRUE if req1 and req2 directly negate each other. More... | |
| static bool | impr_contra_genus (const struct requirement *impr_req, const struct requirement *genus_req) |
| Returns TRUE if the specified building requirement contradicts the specified building genus requirement. More... | |
| static bool | nation_contra_group (const struct requirement *nation_req, const struct requirement *group_req) |
| Returns TRUE if the specified nation requirement contradicts the specified nation group requirement. More... | |
| bool | are_requirements_contradictions (const struct requirement *req1, const struct requirement *req2) |
| Returns TRUE if req1 and req2 contradicts each other. More... | |
| 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. More... | |
| static bool | players_in_same_range (const struct player *pplayer1, const struct player *pplayer2, enum req_range range) |
| Returns TRUE if players are in the same requirements range. More... | |
| static int | num_world_buildings_total (const struct impr_type *building) |
| Returns the number of total world buildings (this includes buildings that have been destroyed). More... | |
| static int | num_world_buildings (const struct impr_type *building) |
| Returns the number of buildings of a certain type in the world. More... | |
| static bool | player_has_ever_built (const struct player *pplayer, const struct impr_type *building) |
| Returns whether a building of a certain type has ever been built by pplayer, even if it has subsequently been destroyed. More... | |
| static int | num_player_buildings (const struct player *pplayer, const struct impr_type *building) |
| Returns the number of buildings of a certain type owned by plr. More... | |
| static int | num_continent_buildings (const struct player *pplayer, int continent, const struct impr_type *building) |
| Returns the number of buildings of a certain type on a continent. More... | |
| static int | num_city_buildings (const struct city *pcity, const struct impr_type *building) |
| Returns the number of buildings of a certain type in a city. More... | |
| static enum fc_tristate | is_building_in_range (const struct player *target_player, const struct city *target_city, const struct impr_type *target_building, enum req_range range, bool survives, const struct impr_type *source) |
| Are there any source buildings within range of the target that are not obsolete? More... | |
| static enum fc_tristate | is_tech_in_range (const struct player *target_player, enum req_range range, bool survives, Tech_type_id tech) |
| Is there a source tech within range of the target? More... | |
| static enum fc_tristate | is_techflag_in_range (const struct player *target_player, enum req_range range, enum tech_flag_id techflag) |
| Is there a tech with the given flag within range of the target? More... | |
| static enum fc_tristate | is_minculture_in_range (const struct city *target_city, const struct player *target_player, enum req_range range, int minculture) |
| Is city or player with at least minculture culture in range? More... | |
| static enum fc_tristate | is_minforeignpct_in_range (const struct city *target_city, enum req_range range, int min_foreign_pct) |
| Is city with at least min_foreign_pct foreigners in range? More... | |
| static enum fc_tristate | is_tile_units_in_range (const struct tile *target_tile, enum req_range range, int max_units) |
| Is there a tile with max X units within range of the target? More... | |
| static enum fc_tristate | is_extra_type_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, struct extra_type *pextra) |
| Is there a source extra type within range of the target? More... | |
| static enum fc_tristate | is_goods_type_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, struct goods_type *pgood) |
| Is there a source goods type within range of the target? More... | |
| static enum fc_tristate | is_terrain_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, const struct terrain *pterrain) |
| Is there a source tile within range of the target? More... | |
| static enum fc_tristate | is_terrain_class_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum terrain_class pclass) |
| Is there a source terrain class within range of the target? More... | |
| static enum fc_tristate | is_terrainflag_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum terrain_flag_id terrflag) |
| Is there a terrain with the given flag within range of the target? More... | |
| static enum fc_tristate | is_baseflag_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum base_flag_id baseflag) |
| Is there a base with the given flag within range of the target? More... | |
| static enum fc_tristate | is_roadflag_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum road_flag_id roadflag) |
| Is there a road with the given flag within range of the target? More... | |
| static enum fc_tristate | is_extraflag_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, bool survives, enum extra_flag_id extraflag) |
| Is there an extra with the given flag within range of the target? More... | |
| static enum fc_tristate | is_terrain_alter_possible_in_range (const struct tile *target_tile, enum req_range range, bool survives, enum terrain_alteration alteration) |
| Is there a terrain which can support the specified infrastructure within range of the target? More... | |
| static enum fc_tristate | is_nation_in_range (const struct player *target_player, enum req_range range, bool survives, const struct nation_type *nation) |
| Is there a nation within range of the target? More... | |
| static enum fc_tristate | is_nation_group_in_range (const struct player *target_player, enum req_range range, bool survives, const struct nation_group *ngroup) |
| Is there a nation group within range of the target? More... | |
| static enum fc_tristate | is_nationality_in_range (const struct city *target_city, enum req_range range, const struct nation_type *nationality) |
| Is there a nationality within range of the target? More... | |
| static enum fc_tristate | is_diplrel_in_range (const struct player *target_player, const struct player *other_player, enum req_range range, int diplrel) |
| Is the diplomatic state within range of the target? More... | |
| static enum fc_tristate | is_unittype_in_range (const struct unit_type *target_unittype, enum req_range range, bool survives, const struct unit_type *punittype) |
| Is there a unit of the given type within range of the target? More... | |
| static enum fc_tristate | is_unitflag_in_range (const struct unit_type *target_unittype, enum req_range range, bool survives, enum unit_type_flag_id unitflag) |
| Is there a unit with the given flag within range of the target? More... | |
| static enum fc_tristate | is_unitclass_in_range (const struct unit_type *target_unittype, enum req_range range, bool survives, struct unit_class *pclass) |
| Is there a unit with the given flag within range of the target? More... | |
| static enum fc_tristate | is_unitclassflag_in_range (const struct unit_type *target_unittype, enum req_range range, bool survives, enum unit_class_flag_id ucflag) |
| Is there a unit with the given flag within range of the target? More... | |
| static enum fc_tristate | is_unit_state (const struct unit *target_unit, enum req_range range, bool survives, enum ustate_prop uprop) |
| Is the given property of the unit state true? More... | |
| static bool | is_city_in_tile (const struct tile *ptile, const struct city *pcity) |
| Is center of given city in tile. More... | |
| static enum fc_tristate | is_citytile_in_range (const struct tile *target_tile, const struct city *target_city, enum req_range range, enum citytile_type citytile) |
| Is center of given city in range. More... | |
| static enum fc_tristate | is_citystatus_in_range (const struct city *target_city, enum req_range range, enum citystatus_type citystatus) |
| Is city with specific status in range. More... | |
| static enum fc_tristate | is_achievement_in_range (const struct player *target_player, enum req_range range, const struct achievement *achievement) |
| Has achievement been claimed by someone in range. More... | |
| bool | is_req_active (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 unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement *req, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel) |
| Checks the requirement to see if it is active on the given target. More... | |
| bool | are_reqs_active (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 unit_type *target_unittype, const struct output_type *target_output, const struct specialist *target_specialist, const struct action *target_action, const struct requirement_vector *reqs, const enum req_problem_type prob_type, const enum vision_layer vision_layer, const enum national_intelligence nintel) |
| Checks the requirement(s) to see if they are active on the given target. More... | |
| bool | is_req_unchanging (const struct requirement *req) |
| Return TRUE if this is an "unchanging" requirement. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| 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. More... | |
| void | req_vec_problem_free (struct req_vec_problem *issue) |
| De-allocates resources associated with the given requirement vector problem. More... | |
| 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 nullptr if no contradiction was found. More... | |
| bool | are_universals_equal (const struct universal *psource1, const struct universal *psource2) |
| Return TRUE iff the two sources are equivalent. More... | |
| const char * | universal_rule_name (const struct universal *psource) |
| Return the (untranslated) rule name of the universal. More... | |
| const char * | universal_name_translation (const struct universal *psource, char *buf, size_t bufsz) |
| Make user-friendly text for the source. More... | |
| const char * | universal_type_rule_name (const struct universal *psource) |
| Return untranslated name of the universal source name. More... | |
| int | universal_build_shield_cost (const struct city *pcity, const struct universal *target) |
| Return the number of shields it takes to build this universal. More... | |
| 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. More... | |
| 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'. More... | |
| enum req_item_found | universal_fulfills_requirement (const struct requirement *preq, const struct universal *source) |
| Will the universal 'source' fulfill this requirement? More... | |
| 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.) More... | |
| bool | sv_universal_fulfills_requirements (bool check_necessary, const struct requirement_vector *reqs, const struct universal source) |
| Version of universal_fulfills_requirements that takes the universal by value. More... | |
| 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. More... | |
| static enum req_item_found | nation_found (const struct requirement *preq, const struct universal *source) |
| Find if a nation fulfills a requirement. More... | |
| static enum req_item_found | government_found (const struct requirement *preq, const struct universal *source) |
| Find if a government fulfills a requirement. More... | |
| static enum req_item_found | improvement_found (const struct requirement *preq, const struct universal *source) |
| Find if an improvement fulfills a requirement. More... | |
| static enum req_item_found | unit_class_found (const struct requirement *preq, const struct universal *source) |
| Find if a unit class fulfills a requirement. More... | |
| static enum req_item_found | unit_type_found (const struct requirement *preq, const struct universal *source) |
| Find if a unit type fulfills a requirement. More... | |
| static enum req_item_found | unit_activity_found (const struct requirement *preq, const struct universal *source) |
| Find if a unit activity fulfills a requirement. More... | |
| static enum req_item_found | terrain_type_found (const struct requirement *preq, const struct universal *source) |
| Find if a terrain type fulfills a requirement. More... | |
| static enum req_item_found | city_tile_found (const struct requirement *preq, const struct universal *source) |
| Find if a tile state fulfills a requirement. More... | |
| static enum req_item_found | extra_type_found (const struct requirement *preq, const struct universal *source) |
| Find if an extra type fulfills a requirement. More... | |
| static enum req_item_found | action_found (const struct requirement *preq, const struct universal *source) |
| Find if an action fulfills a requirement. More... | |
| static enum req_item_found | diplrel_found (const struct requirement *preq, const struct universal *source) |
| Find if a diplrel fulfills a requirement. More... | |
| static enum req_item_found | output_type_found (const struct requirement *preq, const struct universal *source) |
| Find if an output type fulfills a requirement. More... | |
| void | universal_found_functions_init () |
| Initialise universal_found_function array. More... | |
| 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. More... | |
Variables | |
| static universal_found | universal_found_function [VUT_COUNT] = {nullptr} |
| typedef enum req_item_found(* universal_found) (const struct requirement *, const struct universal *) |
Container for req_item_found functions.
Definition at line 1 of file requirements.cpp.
|
static |
Find if an action fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
| bool are_reqs_active | ( | 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 unit_type * | target_unittype, | ||
| const struct output_type * | target_output, | ||
| const struct specialist * | target_specialist, | ||
| const struct action * | target_action, | ||
| const struct requirement_vector * | reqs, | ||
| const enum req_problem_type | prob_type, | ||
| const enum vision_layer vision_layer vision_layer | , | ||
| const enum national_intelligence | nintel | ||
| ) |
Checks the requirement(s) to see if they are active on the given target.
target gives the type of the target (player,city,building,tile) give the exact target
reqs gives the requirement vector. The function returns TRUE only if all requirements are active.
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 3500 of file requirements.cpp.
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_target_possible(), multiplier_can_be_changed(), player_can_build_extra(), player_can_remove_extra(), player_music_style(), research_invention_set(), 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 1215 of file requirements.cpp.
Referenced by does_req_contradicts_reqs(), 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 1131 of file requirements.cpp.
Referenced by req_edit::incoming_rec_vec_change(), is_req_in_vec(), and req_vec_change_apply().
|
static |
Returns TRUE if req1 and req2 directly negate each other.
Definition at line 1142 of file requirements.cpp.
Referenced by are_requirements_contradictions().
Return TRUE iff the two sources are equivalent.
Note this isn't the same as an == or memcmp check.
Definition at line 3887 of file requirements.cpp.
Referenced by are_requirements_equal(), are_requirements_opposites(), are_worklists_equal(), change_build_target(), city_set_queue(), clipboard_send_production_packet(), handle_city_change(), handle_city_info(), insert_allows_single(), and ruledit_gui::open_effect_edit().
|
static |
Find if a tile state fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Find if a diplrel fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
| 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 1307 of file requirements.cpp.
Referenced by action_enabler_suggest_repair_oblig(), city_production_caravan_shields_init(), local_dipl_rel_action_cache_set(), and utype_may_act_tgt_city_tile().
|
static |
Find if an extra type fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Find if a government fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Returns TRUE if the specified building requirement contradicts the specified building genus requirement.
Definition at line 1154 of file requirements.cpp.
Referenced by are_requirements_contradictions().
|
static |
Find if an improvement fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Has achievement been claimed by someone in range.
Definition at line 2899 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a base with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Are there any source buildings within range of the target that are not obsolete?
The target gives the type of the target. The exact target is a player, city, or building specified by the target_xxx arguments.
The range gives the range of the requirement.
"Survives" specifies whether the requirement allows destroyed sources. If set then all source buildings ever built are counted; if not then only living buildings are counted.
source gives the building type of the source in question.
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
Is center of given city in tile.
If city is nullptr, any city will do.
Definition at line 2899 of file requirements.cpp.
|
static |
Is city with specific status in range.
If city is nullptr, any city will do.
Definition at line 2899 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is center of given city in range.
If city is nullptr, any city will do.
Definition at line 2899 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is the diplomatic state within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a source extra type within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there an extra with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a source goods type within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is city or player with at least minculture culture in range?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is city with at least min_foreign_pct foreigners in range?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a nation group within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a nation within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a nationality within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
| bool is_req_active | ( | 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 unit_type * | target_unittype, | ||
| const struct output_type * | target_output, | ||
| const struct specialist * | target_specialist, | ||
| const struct action * | target_action, | ||
| const struct requirement * | req, | ||
| const enum req_problem_type | prob_type, | ||
| const enum vision_layer vision_layer vision_layer | , | ||
| const enum national_intelligence | nintel | ||
| ) |
Checks the requirement to see if it is active on the given target.
target gives the type of the target (player,city,building,tile) give the exact target req gives the requirement itself
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 3111 of file requirements.cpp.
Referenced by adjust_improvement_wants_by_effects(), adjust_wants_for_reqs(), adv_units_ruleset_init(), are_reqs_active(), can_city_build_improvement_later(), can_player_build_improvement_direct(), can_player_build_improvement_later(), can_player_build_unit_direct(), city_landlocked_sell_coastal_improvements(), dai_find_source_building(), dai_gov_value(), dai_tech_effect_values(), dai_wants_defender_against(), get_potential_improvement_bonus(), improvement_obsolete(), is_effect_prevented(), reqs_may_activate(), 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 3611 of file requirements.cpp.
Referenced by tgt_citytile_act_cache_set(), and unit_state_action_cache_set().
| bool is_req_unchanging | ( | const struct requirement * | req | ) |
Return TRUE if this is an "unchanging" requirement.
This means that if a target can't meet the requirement now, it probably won't ever be able to do so later. This can be used to do requirement filtering when checking if a target may "eventually" become available.
Note this isn't absolute. Returning TRUE here just means that the requirement probably can't be met. In some cases (particularly terrains) it may be wrong.
Definition at line 3539 of file requirements.cpp.
Referenced by can_city_build_improvement_later(), can_player_build_improvement_later(), reqs_may_activate(), and sanity_check_ruleset_data().
|
static |
Is there a road with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a source tech within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a tech with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a terrain which can support the specified infrastructure within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a source terrain class within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a source tile within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a terrain with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a tile with max X units within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is the given property of the unit state true?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a unit with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a unit with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a unit with the given flag within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Is there a unit of the given type within range of the target?
Definition at line 1445 of file requirements.cpp.
Referenced by is_req_active().
|
static |
Returns TRUE if the specified nation requirement contradicts the specified nation group requirement.
Definition at line 1186 of file requirements.cpp.
Referenced by are_requirements_contradictions().
|
static |
Find if a nation fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Returns the number of buildings of a certain type in a city.
Definition at line 1445 of file requirements.cpp.
|
static |
Returns the number of buildings of a certain type on a continent.
Definition at line 1425 of file requirements.cpp.
|
static |
Returns the number of buildings of a certain type owned by plr.
Definition at line 1411 of file requirements.cpp.
|
static |
Returns the number of buildings of a certain type in the world.
Definition at line 1375 of file requirements.cpp.
|
static |
Returns the number of total world buildings (this includes buildings that have been destroyed).
Definition at line 1359 of file requirements.cpp.
|
static |
Find if an output type fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Returns whether a building of a certain type has ever been built by pplayer, even if it has subsequently been destroyed.
Note: the implementation of this is no different in principle from num_world_buildings_total(), but the semantics are different because unlike a great wonder, a small wonder could be destroyed and rebuilt many times, requiring return of values >1, but there's no record kept to support that. Fortunately, the only current caller doesn't need the exact number.
Definition at line 1396 of file requirements.cpp.
|
inlinestatic |
Returns TRUE if players are in the same requirements range.
Definition at line 1328 of file requirements.cpp.
| 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 nullptr type is considered VUT_NONE (not an error).
Pass this some values like "Building", "Factory".
Definition at line 804 of file requirements.cpp.
Referenced by effect_list_compat_cb(), load_ruleset_cities(), lookup_req_list(), rscompat_old_slow_invasions_3_1(), rscompat_optional_capabilities(), rscompat_postprocess(), and rscompat_vision_effect_cb().
| 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 804 of file requirements.cpp.
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_ruleset_units(), rscompat_auto_attack_3_1(), rscompat_migrate_eft_nation_intelligence(), rscompat_old_slow_invasions_3_1(), rscompat_postprocess(), and send_ruleset_techs().
| 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 1117 of file requirements.cpp.
Referenced by dio_put_requirement_raw().
| QString req_to_fstring | ( | const struct requirement * | req | ) |
Returns the given requirement as a formatted string ready for printing.
Does not care about the 'quiet' property.
Definition at line 804 of file requirements.cpp.
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(), sanity_check_ruleset_data(), and save_action_auto_uflag_block().
| 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 3741 of file requirements.cpp.
Referenced by req_vec_fix::apply_solution(), 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 3673 of file requirements.cpp.
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 nullptr 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 3833 of file requirements.cpp.
Referenced by action_enabler_suggest_repair(), and sanity_check_req_vec().
| 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 3813 of file requirements.cpp.
Referenced by req_vec_fix::refresh(), rscompat_enabler_add_obligatory_hard_reqs(), sanity_check_req_vec(), 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. The description
| num_suggested_solutions | the number of suggested solutions. |
| descr | the description of the problem as a format string |
Definition at line 3779 of file requirements.cpp.
Referenced by action_enabler_suggest_improvement(), action_enabler_suggest_repair_oblig(), enabler_first_self_contradiction(), enabler_tile_tgt_local_diplrel_implies_claimed(), and req_vec_get_first_contradiction().
| 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 3652 of file requirements.cpp.
Referenced by 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 3631 of file requirements.cpp.
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 4932 of file requirements.cpp.
| bool sv_universal_fulfills_requirements | ( | bool | check_necessary, |
| const struct requirement_vector * | reqs, | ||
| const struct universal | source | ||
| ) |
Version of universal_fulfills_requirements that takes the universal by value.
Definition at line 4572 of file requirements.cpp.
|
static |
Find if a terrain type fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Find if a unit activity fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Find if a unit class fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
|
static |
Find if a unit type fulfills a requirement.
Definition at line 4583 of file requirements.cpp.
Referenced by universal_found_functions_init().
Return the number of shields it takes to build this universal.
Definition at line 4455 of file requirements.cpp.
Referenced by city_production_build_shield_cost(), city_turns_to_build(), and polished_citybar_painter::paint().
| 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 70 of file requirements.cpp.
Referenced by dio_get_worklist_raw(), effect_list_compat_cb(), handle_city_change(), and handle_city_info().
| 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 nullptr 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 41 of file requirements.cpp.
Referenced by global_worklists_build(), sg_load_player_city(), 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 681 of file requirements.cpp.
Referenced by get_req_source_effects(), req_get_values(), help_widget::set_topic_building(), and universal_value_cb().
| void universal_found_functions_init | ( | ) |
Initialise universal_found_function array.
Definition at line 4908 of file requirements.cpp.
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 4496 of file requirements.cpp.
Referenced by action_found(), and effect_value_from_universals().
| 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 4534 of file requirements.cpp.
Referenced by action_univs_not_blocking(), help_widget::add_extras_of_act_for_terrain(), effect_cumulative_max(), effect_cumulative_min(), helptext_building(), and sv_universal_fulfills_requirements().
| 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 4496 of file requirements.cpp.
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 4583 of file requirements.cpp.
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 4145 of file requirements.cpp.
Referenced by apply_disaster(), city_production_name_translation(), clipboard_copy_production(), diplomat_sabotage(), do_unit_strike_city_production(), city_widget::gen_production_labels(), get_city_mapview_production(), get_effect_req_text(), insert_allows_single(), manual_command(), req_edit::refresh(), req_text_insert(), and help_widget::set_topic_building().
| int universal_number | ( | const struct universal * | source | ) |
Return the universal number of the constituent.
Definition at line 691 of file requirements.cpp.
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 4474 of file requirements.cpp.
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 4003 of file requirements.cpp.
Referenced by define_orig_production_values(), effect_list_sanity_cb(), global_worklist_save(), global_worklists_unbuild(), req_from_str(), 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 4447 of file requirements.cpp.
Referenced by global_worklist_save(), global_worklists_unbuild(), req_from_str(), sanity_check_req_set(), sg_save_player_cities(), 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 70 of file requirements.cpp.
Referenced by req_edit::univ_value_edit(), and req_edit::univ_value_enum_menu().
|
static |
Definition at line 41 of file requirements.cpp.
Referenced by universal_found_functions_init(), and universal_fulfills_requirements().