14#ifndef FC__REQUIREMENTS_H
15#define FC__REQUIREMENTS_H
37#define SPECENUM_NAME req_range
38#define SPECENUM_VALUE0 REQ_RANGE_LOCAL
39#define SPECENUM_VALUE0NAME "Local"
40#define SPECENUM_VALUE1 REQ_RANGE_TILE
41#define SPECENUM_VALUE1NAME "Tile"
42#define SPECENUM_VALUE2 REQ_RANGE_CADJACENT
43#define SPECENUM_VALUE2NAME "CAdjacent"
44#define SPECENUM_VALUE3 REQ_RANGE_ADJACENT
45#define SPECENUM_VALUE3NAME "Adjacent"
46#define SPECENUM_VALUE4 REQ_RANGE_CITY
47#define SPECENUM_VALUE4NAME "City"
48#define SPECENUM_VALUE5 REQ_RANGE_TRADE_ROUTE
50#define SPECENUM_VALUE5NAME "Traderoute"
51#define SPECENUM_VALUE6 REQ_RANGE_CONTINENT
52#define SPECENUM_VALUE6NAME "Continent"
53#define SPECENUM_VALUE7 REQ_RANGE_PLAYER
54#define SPECENUM_VALUE7NAME "Player"
55#define SPECENUM_VALUE8 REQ_RANGE_TEAM
56#define SPECENUM_VALUE8NAME "Team"
57#define SPECENUM_VALUE9 REQ_RANGE_ALLIANCE
58#define SPECENUM_VALUE9NAME "Alliance"
59#define SPECENUM_VALUE10 REQ_RANGE_WORLD
60#define SPECENUM_VALUE10NAME "World"
61#define SPECENUM_COUNT REQ_RANGE_COUNT
62#define REQ_RANGE_MAX (REQ_RANGE_COUNT - 1)
65#define req_range_iterate(_range_) \
67 enum req_range _range_; \
68 for (_range_ = REQ_RANGE_LOCAL ; _range_ < REQ_RANGE_COUNT ; \
69 _range_ = (enum req_range)(_range_ + 1)) {
71#define req_range_iterate_end \
89#define SPECVEC_TAG requirement
90#define SPECVEC_TYPE struct requirement
92#define requirement_vector_iterate(req_vec, preq) \
93 TYPED_VECTOR_ITERATE(struct requirement, req_vec, preq)
94#define requirement_vector_iterate_end VECTOR_ITERATE_END
260(*requirement_vector_by_number)(
const void *
parent_item,
280#define SPECENUM_NAME req_vec_change_operation
281#define SPECENUM_VALUE0 RVCO_REMOVE
282#define SPECENUM_VALUE0NAME N_("Remove")
283#define SPECENUM_VALUE1 RVCO_APPEND
284#define SPECENUM_VALUE1NAME N_("Append")
285#define SPECENUM_COUNT RVCO_NOOP
371#define universal_is_mentioned_by_requirement(preq, psource) \
372 are_universals_equal(&preq->source, psource)
396#define universals_iterate(_univ_) \
398 enum universals_n _univ_; \
399 for (_univ_ = VUT_NONE; _univ_ < VUT_COUNT; _univ_ = (enum universals_n)(_univ_ + 1)) {
401#define universals_iterate_end \
409#define requirement_fulfilled_by_government(_gov_, _rqs_) \
410 universal_fulfills_requirements(FALSE, (_rqs_), \
411 &(struct universal){.kind = VUT_GOVERNMENT, .value = {.govern = (_gov_)}})
412#define requirement_fulfilled_by_nation(_nat_, _rqs_) \
413 universal_fulfills_requirements(FALSE, (_rqs_), \
414 &(struct universal){.kind = VUT_NATION, .value = {.nation = (_nat_)}})
415#define requirement_fulfilled_by_improvement(_imp_, _rqs_) \
416 universal_fulfills_requirements(FALSE, (_rqs_), \
417 &(struct universal){.kind = VUT_IMPROVEMENT, \
418 .value = {.building = (_imp_)}})
419#define requirement_fulfilled_by_terrain(_ter_, _rqs_) \
420 universal_fulfills_requirements(FALSE, (_rqs_), \
421 &(struct universal){.kind = VUT_TERRAIN, \
422 .value = {.terrain = (_ter_)}})
423#define requirement_fulfilled_by_unit_class(_uc_, _rqs_) \
424 universal_fulfills_requirements(FALSE, (_rqs_), \
425 &(struct universal){.kind = VUT_UCLASS, .value = {.uclass = (_uc_)}})
426#define requirement_fulfilled_by_unit_type(_ut_, _rqs_) \
427 universal_fulfills_requirements(FALSE, (_rqs_), \
428 &(struct universal){.kind = VUT_UTYPE, .value = {.utype = (_ut_)}})
429#define requirement_fulfilled_by_extra(_ex_, _rqs_) \
430 universal_fulfills_requirements(FALSE, (_rqs_), \
431 &(struct universal){.kind = VUT_EXTRA, .value = {.extra = (_ex_)}})
432#define requirement_fulfilled_by_output_type(_o_, _rqs_) \
433 universal_fulfills_requirements(FALSE, (_rqs_), \
434 &(struct universal){.kind = VUT_OTYPE, .value = {.outputtype = (_o_)}})
435#define requirement_fulfilled_by_action(_act_, _rqs_) \
436 universal_fulfills_requirements(FALSE, (_rqs_), \
437 &(struct universal){.kind = VUT_ACTION, .value = {.action = (_act_)}})
439#define requirement_needs_improvement(_imp_, _rqs_) \
440 universal_fulfills_requirements(TRUE, (_rqs_), \
441 &(struct universal){.kind = VUT_IMPROVEMENT, \
442 .value = {.building = (_imp_)}})
447 const int max_value);
449#define requirement_diplrel_ereq(_id_, _range_, _present_) \
450 requirement_kind_ereq(_id_, _range_, _present_, DRO_LAST)
struct unit struct city struct unit struct tile struct extra_type const struct act_prob *act_probs int actor_unit_id struct unit struct unit int const struct action *paction struct unit struct city * pcity
static GtkWidget * source
bool universal_never_there(const struct universal *source)
struct req_vec_problem * req_vec_problem_new(int num_suggested_solutions, const char *description,...)
bool universal_is_relevant_to_requirement(const struct requirement *req, const struct universal *source)
bool is_req_in_vec(const struct requirement *req, const struct requirement_vector *vec)
int universal_build_shield_cost(const struct city *pcity, const struct universal *target)
struct req_vec_problem * req_vec_get_first_contradiction(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
enum fc_tristate(* req_tester_cb)(const struct req_context *context, const struct req_context *other_context, const struct requirement *req, void *data, int n_data)
const struct req_context * req_context_empty(void)
signed char req_vec_num_in_item
req_vec_num_in_item a requirement vectors number in an item.
void universal_extraction(const struct universal *source, int *kind, int *value)
req_vec_num_in_item(* requirement_vector_number)(const void *parent_item, const struct requirement_vector *vec)
const char * req_to_fstring(const struct requirement *req, struct astring *astr)
const char *(* requirement_vector_namer)(req_vec_num_in_item number)
req_vec_num_in_item req_vec_vector_number(const void *parent_item, const struct requirement_vector *vec)
enum fc_tristate tri_req_active(const struct req_context *context, const struct req_context *other_context, const struct requirement *req)
struct requirement_vector * req_vec_by_number(const void *parent_item, req_vec_num_in_item number)
bool universal_fulfills_requirements(bool check_necessary, const struct requirement_vector *reqs, const struct universal *source)
enum fc_tristate tri_reqs_cb_active(const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, struct requirement_vector *maybe_reqs, req_tester_cb tester, void *data, int n_data)
bool req_vec_change_apply(const struct req_vec_change *modification, requirement_vector_by_number getter, const void *parent_item)
void universal_copy(struct universal *dst, const struct universal *src)
enum req_unchanging_status(* req_unchanging_cond_cb)(const struct civ_map *nmap, enum req_unchanging_status def, const struct req_context *context, const struct requirement *req)
bool are_requirements_equal(const struct requirement *req1, const struct requirement *req2)
const char * req_vec_change_translation(const struct req_vec_change *change, const requirement_vector_namer namer)
struct requirement req_from_str(const char *type, const char *range, bool survives, bool present, bool quiet, const char *value)
struct req_vec_problem * req_vec_suggest_repair(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
void universal_value_from_str(struct universal *source, const char *value)
void req_get_values(const struct requirement *req, int *type, int *range, bool *survives, bool *present, bool *quiet, int *value)
struct requirement req_from_values(int type, int range, bool survives, bool present, bool quiet, int value)
const char * universal_rule_name(const struct universal *psource)
bool universal_replace_in_req_vec(struct requirement_vector *reqs, const struct universal *to_replace, const struct universal *replacement)
bool are_requirements_contradictions(const struct requirement *req1, const struct requirement *req2)
bool is_req_active(const struct req_context *context, const struct req_context *other_context, const struct requirement *req, const enum req_problem_type prob_type)
bool universal_is_legal_in_requirement(const struct universal *univ)
enum fc_tristate default_tester_cb(const struct req_context *context, const struct req_context *other_context, const struct requirement *req, void *data, int n_data)
int requirement_kind_ereq(const int value, const enum req_range range, const bool present, const int max_value)
void req_vec_problem_free(struct req_vec_problem *issue)
bool are_reqs_active(const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
struct req_vec_problem * req_vec_get_first_missing_univ(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
enum req_unchanging_status is_req_preventing(const struct req_context *context, const struct req_context *other_context, const struct requirement *req, enum req_problem_type prob_type)
struct universal universal_by_number(const enum universals_n kind, const int value)
enum req_item_found universal_fulfills_requirement(const struct requirement *preq, const struct universal *source)
bool are_reqs_active_ranges(const enum req_range min_range, const enum req_range max_range, const struct req_context *context, const struct req_context *other_context, const struct requirement_vector *reqs, const enum req_problem_type prob_type)
bool req_vec_wants_type(const struct requirement_vector *reqs, enum universals_n kind)
struct requirement_vector *(* requirement_vector_by_number)(const void *parent_item, req_vec_num_in_item number)
struct req_vec_problem * req_vec_get_first_redundant_req(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
bool does_req_contradicts_reqs(const struct requirement *req, const struct requirement_vector *vec)
bool are_universals_equal(const struct universal *psource1, const struct universal *psource2)
struct req_vec_problem * req_vec_problem_new_transl(int num_suggested_solutions, const char *description, const char *description_translated)
enum fc_tristate tri_req_active_turns(int pass, int period, const struct req_context *context, const struct req_context *other_context, const struct requirement *req)
bool universals_say_everything(struct requirement_vector *reqs, struct universal *unis, size_t n_unis)
const char * universal_type_rule_name(const struct universal *psource)
void universal_found_functions_init(void)
int universal_number(const struct universal *source)
bool universal_is_mentioned_by_requirements(const struct requirement_vector *reqs, const struct universal *psource)
bool req_vec_is_impossible_to_fulfill(const struct requirement_vector *reqs)
bool req_implies_req(const struct requirement *req1, const struct requirement *req2)
void req_copy(struct requirement *dst, const struct requirement *src)
enum req_unchanging_status is_req_unchanging(const struct req_context *context, const struct requirement *req)
bool req_is_impossible_to_fulfill(const struct requirement *req)
const char * universal_name_translation(const struct universal *psource, char *buf, size_t bufsz)
struct universal universal_by_rule_name(const char *kind, const char *value)
bool universals_mean_unfulfilled(struct requirement_vector *reqs, struct universal *unis, size_t n_unis)
struct req_vec_problem * req_vec_suggest_improvement(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
const struct impr_type * building
const struct action * action
const struct player * player
enum unit_activity activity
const struct output_type * output
const struct unit_type * unittype
const struct extra_type * extra
const struct specialist * specialist
req_vec_num_in_item vector_number
enum req_vec_change_operation operation
int num_suggested_solutions
char description_translated[500]
struct req_vec_change * suggested_solutions