Freeciv-3.2
Loading...
Searching...
No Matches
Data Structures | Macros | Typedefs | Functions | Variables
requirements.c File Reference
#include <stdarg.h>
#include "astring.h"
#include "fcintl.h"
#include "log.h"
#include "support.h"
#include "achievements.h"
#include "calendar.h"
#include "citizens.h"
#include "counters.h"
#include "culture.h"
#include "game.h"
#include "government.h"
#include "improvement.h"
#include "movement.h"
#include "nation.h"
#include "player.h"
#include "map.h"
#include "research.h"
#include "road.h"
#include "server_settings.h"
#include "specialist.h"
#include "style.h"
#include "victory.h"
#include "requirements.h"

Go to the source code of this file.

Data Structures

struct  req_def
 

Macros

#define REQUC_LOCAL   unchanging_local
 
#define REQUC_PRESENT   unchanging_present
 
#define REQUC_WORLD   unchanging_world
 
#define REQUC_NALLY   unchanging_noally
 
#define REQUC_CITYTILE   unchanging_citytile
 
#define REQUC_CITYSTATUS   unchanging_citystatus
 
#define REQUC_IMPR   unchanging_building
 
#define EXTRACT_INFO(req)
 
#define IS_REQ_ACTIVE_VARIANT_ASSERT(_kind)
 

Typedefs

typedef enum req_item_found(* universal_found) (const struct requirement *, const struct universal *)
 
typedef enum fc_tristate(* is_req_active_cb) (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 

Functions

static enum fc_tristate tri_req_present (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static bool are_tiles_in_range (const struct tile *tile1, const struct tile *tile2, enum req_range range)
 
static enum req_unchanging_status unchanging_local (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
static enum req_unchanging_status unchanging_present (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
static enum req_unchanging_status unchanging_world (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
static enum req_unchanging_status unchanging_noally (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
static enum req_unchanging_status unchanging_citytile (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
static enum req_unchanging_status unchanging_citystatus (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
static enum req_unchanging_status unchanging_building (const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
 
struct universal universal_by_rule_name (const char *kind, const char *value)
 
static bool activity_is_valid_in_requirement (enum unit_activity act)
 
bool universal_is_legal_in_requirement (const struct universal *univ)
 
void universal_value_from_str (struct universal *source, const char *value)
 
struct universal universal_by_number (const enum universals_n kind, const int value)
 
void universal_copy (struct universal *dst, const struct universal *src)
 
void universal_extraction (const struct universal *source, int *kind, int *value)
 
int universal_number (const struct universal *source)
 
const struct req_contextreq_context_empty (void)
 
const charreq_to_fstring (const struct requirement *req, struct astring *astr)
 
struct requirement req_from_str (const char *type, const char *range, bool survives, bool present, bool quiet, const char *value)
 
struct requirement req_from_values (int type, int range, bool survives, bool present, bool quiet, int value)
 
void req_get_values (const struct requirement *req, 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)
 
static bool are_requirements_opposites (const struct requirement *req1, const struct requirement *req2)
 
static bool impr_contra_genus (const struct requirement *impr_req, const struct requirement *genus_req)
 
static bool impr_contra_flag (const struct requirement *impr_req, const struct requirement *flag_req)
 
static bool nation_contra_group (const struct requirement *nation_req, const struct requirement *group_req)
 
static bool city_center_contra (const struct requirement *cc_req, const struct requirement *ct_req)
 
static bool present_implies_not_present (const struct requirement *req1, const struct requirement *req2)
 
bool req_implies_req (const struct requirement *req1, const struct requirement *req2)
 
bool are_requirements_contradictions (const struct requirement *req1, const struct requirement *req2)
 
bool does_req_contradicts_reqs (const struct requirement *req, const struct requirement_vector *vec)
 
static bool players_in_same_range (const struct player *pplayer1, const struct player *pplayer2, enum req_range range)
 
static enum fc_tristate is_none_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static int num_world_buildings_total (const struct impr_type *building)
 
static int num_world_buildings (const struct impr_type *building)
 
static bool player_has_ever_built (const struct player *pplayer, const struct impr_type *building)
 
static int num_player_buildings (const struct player *pplayer, const struct impr_type *building)
 
static int num_continent_buildings (const struct player *pplayer, int continent, const struct impr_type *building)
 
static int num_city_buildings (const struct city *pcity, const struct impr_type *building)
 
static enum fc_tristate is_building_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_buildinggenus_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_buildingflag_in_city (const struct city *pcity, enum impr_flag_id flag)
 
static enum fc_tristate is_buildingflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_plr_flag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_plr_state_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_tech_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_techflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minculture_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minforeignpct_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_maxunitsontile_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_extra_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_good_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_action_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_outputtype_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_specialist_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_terrain_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_terrainclass_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_terrainflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_roadflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_extraflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_terrainalter_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_gov_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_style_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_mintechs_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_ai_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_nation_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_nationgroup_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_nationality_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_originalowner_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_diplrel_in_range (const struct player *target_player, const struct player *other_player, enum req_range range, int diplrel)
 
static enum fc_tristate is_diplrel_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_diplrel_tile_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_diplrel_tile_o_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_diplrel_unitany_in_range (const struct tile *target_tile, const struct player *other_player, enum req_range range, int diplrel)
 
static enum fc_tristate is_diplrel_unitany_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_diplrel_unitany_o_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_unittype_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_unitflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_unitclass_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_unitclassflag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_unitstate_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_activity_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minveteran_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minmovefrags_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minhitpoints_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_age_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_form_age_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static bool is_city_in_tile (const struct tile *ptile, const struct city *pcity)
 
static enum fc_tristate is_citytile_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_citystatus_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minsize_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_counter_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_achievement_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_latitude_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_minyear_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_mincalfrag_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_topology_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_wrap_req_active (const struct civ_map *nmap, const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
static enum fc_tristate is_serversetting_req_active (const struct civ_map *nmap, 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)
 
enum fc_tristate tri_req_active (const struct req_context *context, const struct player *other_player, const struct requirement *req)
 
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)
 
bool are_reqs_active_ranges (const enum req_range min_range, const enum req_range max_range, 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_vectorreq_vec_by_number (const void *parent_item, req_vec_num_in_item number)
 
const charreq_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_problemreq_vec_problem_new_transl (int num_suggested_solutions, const char *description, const char *description_translated)
 
struct req_vec_problemreq_vec_problem_new (int num_suggested_solutions, const char *descr,...)
 
void req_vec_problem_free (struct req_vec_problem *issue)
 
struct req_vec_problemreq_vec_get_first_contradiction (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
 
struct req_vec_problemreq_vec_suggest_repair (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
 
struct req_vec_problemreq_vec_get_first_missing_univ (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
 
struct req_vec_problemreq_vec_get_first_redundant_req (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
 
struct req_vec_problemreq_vec_suggest_improvement (const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
 
bool are_universals_equal (const struct universal *psource1, const struct universal *psource2)
 
const charuniversal_rule_name (const struct universal *psource)
 
const charuniversal_name_translation (const struct universal *psource, char *buf, size_t bufsz)
 
const charuniversal_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_mentioned_by_requirements (const struct requirement_vector *reqs, const struct universal *psource)
 
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)
 
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)
 
static enum req_item_found nation_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found government_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found improvement_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found unit_class_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found unit_type_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found unit_activity_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found terrain_type_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found city_tile_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found extra_type_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found action_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found diplrel_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found output_type_found (const struct requirement *preq, const struct universal *source)
 
static enum req_item_found ustate_found (const struct requirement *preq, const struct universal *source)
 
void universal_found_functions_init (void)
 
int requirement_kind_ereq (const int value, const enum req_range range, const bool present, const int max_value)
 

Variables

static universal_found universal_found_function [VUT_COUNT] = {NULL}
 
static struct req_def req_definitions [VUT_COUNT]
 

Macro Definition Documentation

◆ EXTRACT_INFO

#define EXTRACT_INFO (   req)
Value:
if (req->present) { \
if (req->source.kind == VUT_MINLATITUDE) { \
/* present MinLatitude */ \
minimum = MAX(minimum, req->source.value.latitude); \
} else { \
/* present MaxLatitude */ \
maximum = MIN(maximum, req->source.value.latitude); \
} \
} else { \
covered_range = MAX(covered_range, req->range); \
if (req->source.kind == VUT_MINLATITUDE) { \
/* negated MinLatitude */ \
maximum = MIN(maximum, req->source.value.latitude - 1); \
} else { \
/* negated MaxLatitude */ \
minimum = MAX(minimum, req->source.value.latitude + 1); \
} \
}
char * incite_cost
Definition comments.c:75
#define MIN(x, y)
Definition shared.h:55
#define MAX(x, y)
Definition shared.h:54

◆ IS_REQ_ACTIVE_VARIANT_ASSERT

#define IS_REQ_ACTIVE_VARIANT_ASSERT (   _kind)
Value:
{ \
fc_assert_ret_val(req->source.kind == _kind, TRI_MAYBE); \
}
@ TRI_MAYBE
Definition shared.h:46

Definition at line 1938 of file requirements.c.

◆ REQUC_CITYSTATUS

#define REQUC_CITYSTATUS   unchanging_citystatus

Definition at line 183 of file requirements.c.

◆ REQUC_CITYTILE

#define REQUC_CITYTILE   unchanging_citytile

Definition at line 162 of file requirements.c.

◆ REQUC_IMPR

#define REQUC_IMPR   unchanging_building

Definition at line 223 of file requirements.c.

◆ REQUC_LOCAL

#define REQUC_LOCAL   unchanging_local

Definition at line 84 of file requirements.c.

◆ REQUC_NALLY

#define REQUC_NALLY   unchanging_noally

Definition at line 139 of file requirements.c.

◆ REQUC_PRESENT

#define REQUC_PRESENT   unchanging_present

Definition at line 100 of file requirements.c.

◆ REQUC_WORLD

#define REQUC_WORLD   unchanging_world

Definition at line 115 of file requirements.c.

Typedef Documentation

◆ is_req_active_cb

Definition at line 55 of file requirements.c.

◆ universal_found

Definition at line 1 of file requirements.c.

Function Documentation

◆ action_found()

static enum req_item_found action_found ( const struct requirement preq,
const struct universal source 
)
static

Find if an action fulfills a requirement

Definition at line 7570 of file requirements.c.

Referenced by universal_found_functions_init().

◆ activity_is_valid_in_requirement()

static bool activity_is_valid_in_requirement ( enum unit_activity  act)
static

Returns TRUE iff the specified activity can appear in an "Activity" requirement.

Definition at line 257 of file requirements.c.

Referenced by universal_is_legal_in_requirement(), and universal_value_from_str().

◆ are_reqs_active()

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 5523 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_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_bv(), sg_special_set_dbv(), unit_can_displace_hut(), unit_can_enter_hut(), and unit_enter_hut().

◆ are_reqs_active_ranges()

bool are_reqs_active_ranges ( const enum req_range  min_range,
const enum req_range  max_range,
const struct req_context context,
const struct player other_player,
const struct requirement_vector reqs,
const enum req_problem_type  prob_type 
)

Like are_reqs_active() but checks only requirements that have one of the ranges between min_range and max_range.

Definition at line 5541 of file requirements.c.

Referenced by can_city_build_unit_direct().

◆ are_requirements_contradictions()

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 1676 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().

◆ are_requirements_equal()

bool are_requirements_equal ( const struct requirement req1,
const struct requirement req2 
)

◆ are_requirements_opposites()

static bool are_requirements_opposites ( const struct requirement req1,
const struct requirement req2 
)
static

Returns TRUE if req1 and req2 directly negate each other.

Definition at line 1470 of file requirements.c.

Referenced by are_requirements_contradictions().

◆ are_tiles_in_range()

static bool are_tiles_in_range ( const struct tile tile1,
const struct tile tile2,
enum req_range  range 
)
inlinestatic

Returns TRUE if tiles are in given requirements range with each other

Definition at line 1878 of file requirements.c.

Referenced by unchanging_citytile().

◆ are_universals_equal()

bool are_universals_equal ( const struct universal psource1,
const struct universal psource2 
)

◆ city_center_contra()

static bool city_center_contra ( const struct requirement cc_req,
const struct requirement ct_req 
)
static

Returns TRUE if the specified city center or continent requirement contradicts the other city tile requirement.

Definition at line 1575 of file requirements.c.

Referenced by are_requirements_contradictions().

◆ city_tile_found()

static enum req_item_found city_tile_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a tile state fulfills a requirement

Definition at line 7523 of file requirements.c.

Referenced by universal_found_functions_init().

◆ default_tester_cb()

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 5690 of file requirements.c.

◆ diplrel_found()

static enum req_item_found diplrel_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a diplrel fulfills a requirement

Definition at line 7586 of file requirements.c.

Referenced by universal_found_functions_init().

◆ does_req_contradicts_reqs()

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 1859 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().

◆ extra_type_found()

static enum req_item_found extra_type_found ( const struct requirement preq,
const struct universal source 
)
static

Find if an extra type fulfills a requirement

Definition at line 7544 of file requirements.c.

Referenced by universal_found_functions_init().

◆ government_found()

static enum req_item_found government_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a government fulfills a requirement

Definition at line 7372 of file requirements.c.

Referenced by universal_found_functions_init().

◆ impr_contra_flag()

static bool impr_contra_flag ( const struct requirement impr_req,
const struct requirement flag_req 
)
static

Returns TRUE if the specified building requirement contradicts the specified building flag requirement.

Definition at line 1516 of file requirements.c.

Referenced by are_requirements_contradictions().

◆ impr_contra_genus()

static bool impr_contra_genus ( const struct requirement impr_req,
const struct requirement genus_req 
)
static

Returns TRUE if the specified building requirement contradicts the specified building genus requirement.

Definition at line 1483 of file requirements.c.

Referenced by are_requirements_contradictions().

◆ improvement_found()

static enum req_item_found improvement_found ( const struct requirement preq,
const struct universal source 
)
static

Find if an improvement fulfills a requirement

Definition at line 7388 of file requirements.c.

Referenced by universal_found_functions_init().

◆ is_achievement_req_active()

static enum fc_tristate is_achievement_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an achievement requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an achievement requirement

Definition at line 5134 of file requirements.c.

◆ is_action_req_active()

static enum fc_tristate is_action_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an action requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an action requirement

Definition at line 2892 of file requirements.c.

◆ is_activity_req_active()

static enum fc_tristate is_activity_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an activity requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an activity requirement

Definition at line 4218 of file requirements.c.

◆ is_age_req_active()

static enum fc_tristate is_age_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an age requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an age requirement

Definition at line 4341 of file requirements.c.

◆ is_ai_req_active()

static enum fc_tristate is_ai_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an AI level requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an AI level requirement

Definition at line 3587 of file requirements.c.

◆ is_building_req_active()

static enum fc_tristate is_building_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a building requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a building requirement

Definition at line 2065 of file requirements.c.

◆ is_buildingflag_in_city()

static enum fc_tristate is_buildingflag_in_city ( const struct city pcity,
enum impr_flag_id  flag 
)
static

Is building flag present in a given city?

Definition at line 2247 of file requirements.c.

Referenced by is_buildingflag_req_active().

◆ is_buildingflag_req_active()

static enum fc_tristate is_buildingflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a building flag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a building flag requirement

Definition at line 2276 of file requirements.c.

◆ is_buildinggenus_req_active()

static enum fc_tristate is_buildinggenus_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a building genus requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a building genus requirement

Definition at line 2231 of file requirements.c.

◆ is_city_in_tile()

static bool is_city_in_tile ( const struct tile ptile,
const struct city pcity 
)
static

Is center of given city in tile. If city is NULL, any city will do.

Definition at line 4415 of file requirements.c.

Referenced by is_citytile_req_active().

◆ is_citystatus_req_active()

static enum fc_tristate is_citystatus_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a city status requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a city status requirement

Definition at line 4821 of file requirements.c.

◆ is_citytile_req_active()

static enum fc_tristate is_citytile_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a citytile requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a citytile requirement

Definition at line 4433 of file requirements.c.

◆ is_counter_req_active()

static enum fc_tristate is_counter_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a counter requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a counter requirement

Definition at line 5106 of file requirements.c.

◆ is_diplrel_in_range()

static enum fc_tristate is_diplrel_in_range ( const struct player target_player,
const struct player other_player,
enum req_range  range,
int  diplrel 
)
static

Is the diplomatic state within range of the target?

Definition at line 3848 of file requirements.c.

Referenced by is_diplrel_req_active(), is_diplrel_tile_o_req_active(), is_diplrel_tile_req_active(), and is_diplrel_unitany_in_range().

◆ is_diplrel_req_active()

static enum fc_tristate is_diplrel_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a diplomatic relationship (diplrel) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a diplrel requirement

Definition at line 3901 of file requirements.c.

◆ is_diplrel_tile_o_req_active()

static enum fc_tristate is_diplrel_tile_o_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a tile owner / other player diplomatic relationship (diplrel_tile_o) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a diplrel_tile_o requirement

Definition at line 3945 of file requirements.c.

◆ is_diplrel_tile_req_active()

static enum fc_tristate is_diplrel_tile_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a tile owner diplomatic relationship (diplrel_tile) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a diplrel_tile requirement

Definition at line 3921 of file requirements.c.

◆ is_diplrel_unitany_in_range()

static enum fc_tristate is_diplrel_unitany_in_range ( const struct tile target_tile,
const struct player other_player,
enum req_range  range,
int  diplrel 
)
static

Is the diplomatic state within range of any unit at the target tile?

Definition at line 3963 of file requirements.c.

Referenced by is_diplrel_unitany_o_req_active(), and is_diplrel_unitany_req_active().

◆ is_diplrel_unitany_o_req_active()

static enum fc_tristate is_diplrel_unitany_o_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an any-unit-owner / other player diplomatic relationship (diplrel_unitany_o) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a diplrel_unitany_o requirement

Definition at line 4016 of file requirements.c.

◆ is_diplrel_unitany_req_active()

static enum fc_tristate is_diplrel_unitany_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an any-unit-owner diplomatic relationship (diplrel_unitany) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a diplrel_unitany requirement

Definition at line 3994 of file requirements.c.

◆ is_extra_req_active()

static enum fc_tristate is_extra_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an extra requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an extra requirement

Definition at line 2747 of file requirements.c.

◆ is_extraflag_req_active()

static enum fc_tristate is_extraflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an extra flag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an extraflag requirement

Definition at line 3363 of file requirements.c.

◆ is_form_age_req_active()

static enum fc_tristate is_form_age_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a form age requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a form age requirement

Definition at line 4389 of file requirements.c.

◆ is_good_req_active()

static enum fc_tristate is_good_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a goods requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a goods requirement

Definition at line 2845 of file requirements.c.

◆ is_gov_req_active()

static enum fc_tristate is_gov_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a government (gov) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a gov requirement

Definition at line 3506 of file requirements.c.

◆ is_latitude_req_active()

static enum fc_tristate is_latitude_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum or maximum latitude requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minlatitude or maxlatitude requirement

Definition at line 5180 of file requirements.c.

◆ is_maxunitsontile_req_active()

static enum fc_tristate is_maxunitsontile_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a maximum units on tile requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a maxunitsontile requirement

Definition at line 2678 of file requirements.c.

◆ is_mincalfrag_req_active()

static enum fc_tristate is_mincalfrag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum calendar fragment requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a mincalfrag requirement

Definition at line 5288 of file requirements.c.

◆ is_minculture_req_active()

static enum fc_tristate is_minculture_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum culture requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minculture requirement

Definition at line 2533 of file requirements.c.

◆ is_minforeignpct_req_active()

static enum fc_tristate is_minforeignpct_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum foreign population requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minforeignpct requirement

Definition at line 2607 of file requirements.c.

◆ is_minhitpoints_req_active()

static enum fc_tristate is_minhitpoints_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum hitpoints requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minhitpoints requirement

Definition at line 4318 of file requirements.c.

◆ is_minmovefrags_req_active()

static enum fc_tristate is_minmovefrags_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum movement fragments (minmovefrags) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minmovefrags requirement

Definition at line 4294 of file requirements.c.

◆ is_minsize_req_active()

static enum fc_tristate is_minsize_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum size requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minsize requirement

Definition at line 5064 of file requirements.c.

◆ is_mintechs_req_active()

static enum fc_tristate is_mintechs_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum technologies requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a mintechs requirement

Definition at line 3552 of file requirements.c.

◆ is_minveteran_req_active()

static enum fc_tristate is_minveteran_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum veteran level (minveteran) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minveteran requirement

Definition at line 4270 of file requirements.c.

◆ is_minyear_req_active()

static enum fc_tristate is_minyear_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a minimum year requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a minyear requirement

Definition at line 5270 of file requirements.c.

◆ is_nation_req_active()

static enum fc_tristate is_nation_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a nation requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a nation requirement

Definition at line 3611 of file requirements.c.

◆ is_nationality_req_active()

static enum fc_tristate is_nationality_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a nationality requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a nationality requirement

Definition at line 3730 of file requirements.c.

◆ is_nationgroup_req_active()

static enum fc_tristate is_nationgroup_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a nation group requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a nation group requirement

Definition at line 3673 of file requirements.c.

◆ is_none_req_active()

static enum fc_tristate is_none_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Included for completeness. Determine whether a trivial (none) requirement is satisfied in a given context (it always is), ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a none requirement

Definition at line 1953 of file requirements.c.

◆ is_originalowner_req_active()

static enum fc_tristate is_originalowner_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an original owner requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an original owner requirement

Definition at line 3805 of file requirements.c.

◆ is_outputtype_req_active()

static enum fc_tristate is_outputtype_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether an output type requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be an output type requirement

Definition at line 2913 of file requirements.c.

◆ is_plr_flag_req_active()

static enum fc_tristate is_plr_flag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a player flag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a building flag requirement

Definition at line 2323 of file requirements.c.

◆ is_plr_state_req_active()

static enum fc_tristate is_plr_state_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a player state requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a building flag requirement

Definition at line 2364 of file requirements.c.

◆ is_req_active()

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 5434 of file requirements.c.

Referenced by adjust_improvement_wants_by_effects(), adjust_wants_for_reqs(), adv_units_ruleset_init(), are_reqs_active(), are_reqs_active_ranges(), 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().

◆ is_req_in_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 5843 of file requirements.c.

Referenced by tgt_citytile_act_cache_set(), and unit_state_action_cache_set().

◆ is_req_preventing()

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 5814 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().

◆ is_req_unchanging()

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 5766 of file requirements.c.

Referenced by is_req_preventing(), and sanity_check_ruleset_data().

◆ is_roadflag_req_active()

static enum fc_tristate is_roadflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a road flag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a roadflag requirement

Definition at line 3259 of file requirements.c.

◆ is_serversetting_req_active()

static enum fc_tristate is_serversetting_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a server setting requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a server setting requirement

Definition at line 5346 of file requirements.c.

◆ is_specialist_req_active()

static enum fc_tristate is_specialist_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a specialist requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a specialist requirement

Definition at line 2933 of file requirements.c.

◆ is_style_req_active()

static enum fc_tristate is_style_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a style requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a style requirement

Definition at line 3529 of file requirements.c.

◆ is_tech_req_active()

static enum fc_tristate is_tech_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a tech requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a tech requirement

Definition at line 2404 of file requirements.c.

◆ is_techflag_req_active()

static enum fc_tristate is_techflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a tech flag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a techflag requirement

Definition at line 2469 of file requirements.c.

◆ is_terrain_req_active()

static enum fc_tristate is_terrain_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a terrain type requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a terrain requirement

Definition at line 2953 of file requirements.c.

◆ is_terrainalter_req_active()

static enum fc_tristate is_terrainalter_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a terrain-alteration-possible (terrainalter) requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a terrainalter requirement

Definition at line 3460 of file requirements.c.

◆ is_terrainclass_req_active()

static enum fc_tristate is_terrainclass_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a terrain class requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a terrain class requirement

Definition at line 3050 of file requirements.c.

◆ is_terrainflag_req_active()

static enum fc_tristate is_terrainflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a terrain flag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a terrain flag requirement

Definition at line 3152 of file requirements.c.

◆ is_topology_req_active()

static enum fc_tristate is_topology_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a topology requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a topology requirement

Definition at line 5307 of file requirements.c.

◆ is_unitclass_req_active()

static enum fc_tristate is_unitclass_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a unitclass requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a unitclass requirement

Definition at line 4094 of file requirements.c.

◆ is_unitclassflag_req_active()

static enum fc_tristate is_unitclassflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a unitclassflag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a unitclassflag requirement

Definition at line 4124 of file requirements.c.

◆ is_unitflag_req_active()

static enum fc_tristate is_unitflag_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a unitflag requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a unitflag requirement

Definition at line 4065 of file requirements.c.

◆ is_unitstate_req_active()

static enum fc_tristate is_unitstate_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a unitstate requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a unitstate requirement

Definition at line 4153 of file requirements.c.

◆ is_unittype_req_active()

static enum fc_tristate is_unittype_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a unittype requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a unittype requirement

Definition at line 4036 of file requirements.c.

◆ is_wrap_req_active()

static enum fc_tristate is_wrap_req_active ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Determine whether a wrap requirement is satisfied in a given context, ignoring parts of the requirement that can be handled uniformly for all requirement types.

context and req must not be null, and req must be a wrap requirement

Definition at line 5326 of file requirements.c.

◆ nation_contra_group()

static bool nation_contra_group ( const struct requirement nation_req,
const struct requirement group_req 
)
static

Returns TRUE if the specified nation requirement contradicts the specified nation group requirement.

Definition at line 1549 of file requirements.c.

Referenced by are_requirements_contradictions().

◆ nation_found()

static enum req_item_found nation_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a nation fulfills a requirement

Definition at line 7349 of file requirements.c.

Referenced by universal_found_functions_init().

◆ num_city_buildings()

static int num_city_buildings ( const struct city pcity,
const struct impr_type building 
)
static

Returns the number of buildings of a certain type in a city.

Definition at line 2051 of file requirements.c.

Referenced by is_building_req_active().

◆ num_continent_buildings()

static int num_continent_buildings ( const struct player pplayer,
int  continent,
const struct impr_type building 
)
static

Returns the number of buildings of a certain type on a continent.

Definition at line 2031 of file requirements.c.

Referenced by is_building_req_active().

◆ num_player_buildings()

static int num_player_buildings ( const struct player pplayer,
const struct impr_type building 
)
static

Returns the number of buildings of a certain type owned by plr.

Definition at line 2017 of file requirements.c.

Referenced by is_building_req_active().

◆ num_world_buildings()

static int num_world_buildings ( const struct impr_type building)
static

Returns the number of buildings of a certain type in the world.

Definition at line 1981 of file requirements.c.

Referenced by is_building_req_active().

◆ num_world_buildings_total()

static int num_world_buildings_total ( const struct impr_type building)
static

Returns the number of total world buildings (this includes buildings that have been destroyed).

Definition at line 1967 of file requirements.c.

Referenced by is_building_req_active().

◆ output_type_found()

static enum req_item_found output_type_found ( const struct requirement preq,
const struct universal source 
)
static

Find if an output type fulfills a requirement

Definition at line 7635 of file requirements.c.

Referenced by universal_found_functions_init().

◆ player_has_ever_built()

static bool player_has_ever_built ( const struct player pplayer,
const struct impr_type building 
)
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 2002 of file requirements.c.

Referenced by is_building_req_active().

◆ players_in_same_range()

static bool players_in_same_range ( const struct player pplayer1,
const struct player pplayer2,
enum req_range  range 
)
inlinestatic

◆ present_implies_not_present()

static bool present_implies_not_present ( const struct requirement req1,
const struct requirement req2 
)
static

Returns TRUE if req1 and req2 contradicts each other because a present requirement implies the presence of a !present requirement according to the knowledge about implications in universal_found_function.

Definition at line 1618 of file requirements.c.

Referenced by are_requirements_contradictions().

◆ req_context_empty()

const struct req_context * req_context_empty ( void  )

Returns a pointer to a statically-allocated, empty requirement context.

Definition at line 1005 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().

◆ req_copy()

void req_copy ( struct requirement dst,
const struct requirement src 
)

Fill in copy of the requirement.

Definition at line 1445 of file requirements.c.

Referenced by can_player_build_unit_direct(), req_implies_req(), and unchanging_noally().

◆ req_from_str()

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 1042 of file requirements.c.

Referenced by effect_edit::add_now(), effect_list_compat_cb(), load_ruleset_cities(), lookup_req_list(), rscompat_action_enabler_adjust_3_2(), rscompat_extra_adjust_3_2(), rscompat_postprocess(), and rscompat_terrain_extra_rmtime_3_2().

◆ req_from_values()

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 1411 of file requirements.c.

Referenced by req_edit::add_now(), dio_get_requirement_raw(), hard_code_oblig_hard_reqs(), hard_code_oblig_hard_reqs_ruleset(), load_action_auto_uflag_block(), load_action_post_success_force(), load_ruleset_units(), and send_ruleset_techs().

◆ req_get_values()

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 1430 of file requirements.c.

Referenced by dio_put_requirement_raw().

◆ req_implies_req()

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 1659 of file requirements.c.

Referenced by default_tester_cb().

◆ req_is_impossible_to_fulfill()

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.

Parameters
reqthe requirement to check the possibility of.
Returns
TRUE iff the requirement never can be fulfilled.

Definition at line 5963 of file requirements.c.

Referenced by req_vec_is_impossible_to_fulfill().

◆ req_to_fstring()

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 1020 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().

◆ req_vec_by_number()

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.

Parameters
parent_itemthe item that should have the requirement vector.
numberthe item's requirement vector number.
Returns
a pointer to the specified requirement vector.

Definition at line 6015 of file requirements.c.

Referenced by purge_duplicate_req_vec(), and purge_unused_req_vec().

◆ req_vec_change_apply()

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.

Parameters
modificationthe requirement vector change
gettera 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_itemthe item to apply the change to.
Returns
if the specified modification was successfully applied

Definition at line 6104 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().

◆ req_vec_change_translation()

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.

Parameters
changethe requirement vector change
namera function that returns a description of the vector to change for the item the vector belongs to.
Returns
the specified requirement vector change

Definition at line 6031 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().

◆ req_vec_get_first_contradiction()

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.

Parameters
vecthe requirement vector to look in.
get_numfunction that returns the requirement vector's number in the parent item.
parent_itemthe item that owns the vector.
Returns
the first self contradiction found.

Definition at line 6221 of file requirements.c.

Referenced by req_vec_suggest_repair().

◆ req_vec_get_first_missing_univ()

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.

Parameters
vecthe requirement vector to look in.
get_numfunction that returns the requirement vector's number in the parent item.
parent_itemthe item that owns the vector.
Returns
the first missing universal found.

Definition at line 6307 of file requirements.c.

Referenced by purge_unused_req_vec(), and req_vec_suggest_improvement().

◆ req_vec_get_first_redundant_req()

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.

Parameters
vecthe requirement vector to look in.
get_numfunction that returns the requirement vector's number in the parent item.
parent_itemthe item that owns the vector.
Returns
the first redundant requirement found.

Definition at line 6392 of file requirements.c.

Referenced by purge_duplicate_req_vec(), and req_vec_suggest_improvement().

◆ req_vec_is_impossible_to_fulfill()

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.

Parameters
reqsthe requirement vector to check the possibility of.
Returns
TRUE iff the requirement vector never can be fulfilled.

Definition at line 5976 of file requirements.c.

Referenced by action_enabler_utype_possible_actor(), ruleset_purge_unused_effects(), and ruleset_purge_unused_enablers().

◆ req_vec_problem_free()

void req_vec_problem_free ( struct req_vec_problem issue)

De-allocates resources associated with the given requirement vector problem.

Parameters
issuethe no longer needed problem.

Definition at line 6201 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().

◆ req_vec_problem_new()

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.

Parameters
num_suggested_solutionsthe number of suggested solutions.
descrthe description of the problem as a format string
Returns
the new requirement vector problem.

Definition at line 6176 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().

◆ req_vec_problem_new_transl()

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.

Parameters
num_suggested_solutionsthe number of suggested solutions.
descriptionthe description of the problem.
description_translatedthe translated description of the problem.
Returns
the new requirement vector problem.

Definition at line 6142 of file requirements.c.

Referenced by req_vec_problem_new().

◆ req_vec_suggest_improvement()

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.

Parameters
vecthe requirement vector to look in.
get_numfunction that returns the requirement vector's number in the parent item.
parent_itemthe item that owns the vector.
Returns
the first improvement suggestion found.

Definition at line 6458 of file requirements.c.

Referenced by action_enabler_suggest_improvement().

◆ req_vec_suggest_repair()

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.

Parameters
vecthe requirement vector to look in.
get_numfunction that returns the requirement vector's number in the parent item.
parent_itemthe item that owns the vector.
Returns
the first error found.

Definition at line 6286 of file requirements.c.

Referenced by action_enabler_suggest_repair(), req_vec_suggest_improvement(), and sanity_check_req_vec().

◆ req_vec_vector_number()

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.

Parameters
parent_itemthe item that may own the vector.
vecthe requirement vector to number.
Returns
the requirement vector number the vector has in the parent item.

Definition at line 5996 of file requirements.c.

Referenced by purge_duplicate_req_vec(), purge_unused_req_vec(), and sanity_check_req_vec().

◆ req_vec_wants_type()

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.

Parameters
reqsthe requirement vector to look in
kindthe requirement type to look for

Definition at line 5861 of file requirements.c.

Referenced by city_production_caravan_shields_init().

◆ requirement_kind_ereq()

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 7718 of file requirements.c.

◆ terrain_type_found()

static enum req_item_found terrain_type_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a terrain type fulfills a requirement

Definition at line 7496 of file requirements.c.

Referenced by universal_found_functions_init().

◆ tri_req_active()

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 5490 of file requirements.c.

Referenced by default_tester_cb(), tactical_req_cb(), and tri_req_active_turns().

◆ 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 5566 of file requirements.c.

Referenced by tactical_req_cb().

◆ tri_req_present()

static enum fc_tristate tri_req_present ( const struct civ_map nmap,
const struct req_context context,
const struct player other_player,
const struct requirement req 
)
static

Applies the standard evaluation of req in context, ignoring req->present.

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 5461 of file requirements.c.

Referenced by is_req_active(), tri_req_active(), unchanging_building(), unchanging_noally(), and unchanging_present().

◆ tri_reqs_cb_active()

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 5719 of file requirements.c.

Referenced by action_may_happen_unit_on_city().

◆ unchanging_building()

static enum req_unchanging_status unchanging_building ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

Special Building case handler. Sometimes building is just a constant parameter, and sometimes it subjects to wonder building rules. Also, there is obsoletion...

Definition at line 191 of file requirements.c.

◆ unchanging_citystatus()

static enum req_unchanging_status unchanging_citystatus ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

Special CityStatus case handler. Changes easily save for owner.

Definition at line 168 of file requirements.c.

◆ unchanging_citytile()

static enum req_unchanging_status unchanging_citytile ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

Special CityTile case handler

Definition at line 145 of file requirements.c.

◆ unchanging_local()

static enum req_unchanging_status unchanging_local ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

Never changes in local range Mostly it's about requirements evaluated from constants and persistent ruleset objects passed in the context.

Definition at line 77 of file requirements.c.

◆ unchanging_noally()

static enum req_unchanging_status unchanging_noally ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

Unchanging except if provided by an ally and not the player themself Alliances may break, team members may be destroyed or reassigned

Definition at line 122 of file requirements.c.

Referenced by is_req_unchanging().

◆ unchanging_present()

static enum req_unchanging_status unchanging_present ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

If not present, may appear; but once becomes present, never goes absent

Definition at line 90 of file requirements.c.

Referenced by is_req_unchanging(), and unchanging_world().

◆ unchanging_world()

static enum req_unchanging_status unchanging_world ( const struct civ_map nmap,
enum req_unchanging_status  def,
const struct req_context context,
const struct requirement req 
)
static

Equals ..._present(), but never changes in World range

Definition at line 106 of file requirements.c.

◆ unit_activity_found()

static enum req_item_found unit_activity_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a unit activity fulfills a requirement

Definition at line 7477 of file requirements.c.

Referenced by universal_found_functions_init().

◆ unit_class_found()

static enum req_item_found unit_class_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a unit class fulfills a requirement

Definition at line 7426 of file requirements.c.

Referenced by universal_found_functions_init().

◆ unit_type_found()

static enum req_item_found unit_type_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a unit type fulfills a requirement

Definition at line 7449 of file requirements.c.

Referenced by universal_found_functions_init().

◆ universal_build_shield_cost()

int universal_build_shield_cost ( const struct city pcity,
const struct universal target 
)

Return the number of shields it takes to build this universal.

Definition at line 7141 of file requirements.c.

Referenced by city_production_build_shield_cost(), city_turns_to_build(), get_city_dialog_production_full(), and get_production_name().

◆ universal_by_number()

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 624 of file requirements.c.

Referenced by dio_get_worklist_raw(), handle_city_change(), handle_city_info(), and req_from_values().

◆ universal_by_rule_name()

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 238 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().

◆ universal_copy()

void universal_copy ( struct universal dst,
const struct universal src 
)

Fill in copy of universal

Definition at line 856 of file requirements.c.

Referenced by req_copy().

◆ universal_extraction()

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 866 of file requirements.c.

Referenced by get_req_source_effects(), req_get_values(), help_widget::set_topic_building(), and universal_value_cb().

◆ universal_found_functions_init()

void universal_found_functions_init ( void  )

Initialise universal_found_function array.

Definition at line 7688 of file requirements.c.

Referenced by game_init().

◆ universal_fulfills_requirement()

enum req_item_found universal_fulfills_requirement ( const struct requirement preq,
const struct universal source 
)

◆ universal_fulfills_requirements()

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 7294 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().

◆ universal_is_legal_in_requirement()

bool universal_is_legal_in_requirement ( const struct universal univ)

Returns TRUE iff the specified universal legally can appear in a requirement.

Definition at line 269 of file requirements.c.

Referenced by universal_kind_values().

◆ universal_is_mentioned_by_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 7181 of file requirements.c.

Referenced by effect_list_fill_cb(), effect_list_universal_needed_cb(), and is_universal_needed().

◆ universal_is_relevant_to_requirement()

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 7331 of file requirements.c.

Referenced by helptext_building().

◆ universal_name_translation()

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 6776 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_improvements(), popup_impr_info(), req_edit::refresh_item(), req_text_insert(), and help_widget::set_topic_building().

◆ universal_never_there()

bool universal_never_there ( const struct universal source)

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.

Parameters
sourcethe universal to check the absence of.
Returns
TRUE iff the universal never will appear.

Definition at line 5880 of file requirements.c.

Referenced by ae_suggest_repair_if_no_oblig(), req_is_impossible_to_fulfill(), and req_vec_get_first_missing_univ().

◆ universal_number()

int universal_number ( const struct universal source)

Return the universal number of the constituent.

Definition at line 876 of file requirements.c.

Referenced by city_change_production(), clipboard_send_production_packet(), dio_put_worklist_raw(), package_city(), and universal_extraction().

◆ universal_replace_in_req_vec()

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 7161 of file requirements.c.

◆ universal_rule_name()

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 6617 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(), sg_save_player_cities(), and worklist_save().

◆ universal_type_rule_name()

const char * universal_type_rule_name ( const struct universal psource)

◆ universal_value_from_str()

void universal_value_from_str ( struct universal source,
const char value 
)

Parse requirement value strings into a universal structure.

Definition at line 282 of file requirements.c.

Referenced by req_edit::univ_value_edit(), req_edit::univ_value_enum_menu(), and universal_by_rule_name().

◆ universals_mean_unfulfilled()

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.

Parameters
reqsthe requirement vector that never should be fulfilled
unisthe universals that are present
n_unisthe number of universals in unis
Returns
if the universals blocks fulfillment of the req vector

Definition at line 7203 of file requirements.c.

Referenced by effect_cumulative_max(), and effect_universals_value_never_below().

◆ universals_say_everything()

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.

Parameters
reqsthe requirement vector certainty is wanted about
unisthe universals that are present
n_unisthe number of universals in unis
Returns
TRUE iff the specified universals is everything required to find out whether the specified requirement vector is fulfilled or not

Definition at line 7236 of file requirements.c.

Referenced by effect_universals_value_never_below().

◆ ustate_found()

static enum req_item_found ustate_found ( const struct requirement preq,
const struct universal source 
)
static

Find if a unit state property fulfills a requirement.

Definition at line 7651 of file requirements.c.

Referenced by universal_found_functions_init().

Variable Documentation

◆ req_definitions

struct req_def req_definitions[VUT_COUNT]
static

Definition at line 5358 of file requirements.c.

Referenced by is_req_preventing(), is_req_unchanging(), and tri_req_present().

◆ universal_found_function

universal_found universal_found_function[VUT_COUNT] = {NULL}
static