14#ifndef FC__REQUIREMENTS_H
15#define FC__REQUIREMENTS_H
38#define SPECENUM_NAME req_range
39#define SPECENUM_VALUE0 REQ_RANGE_LOCAL
40#define SPECENUM_VALUE0NAME "Local"
41#define SPECENUM_VALUE1 REQ_RANGE_CADJACENT
42#define SPECENUM_VALUE1NAME "CAdjacent"
43#define SPECENUM_VALUE2 REQ_RANGE_ADJACENT
44#define SPECENUM_VALUE2NAME "Adjacent"
45#define SPECENUM_VALUE3 REQ_RANGE_CITY
46#define SPECENUM_VALUE3NAME "City"
47#define SPECENUM_VALUE4 REQ_RANGE_TRADE_ROUTE
49#define SPECENUM_VALUE4NAME "Traderoute"
50#define SPECENUM_VALUE5 REQ_RANGE_CONTINENT
51#define SPECENUM_VALUE5NAME "Continent"
52#define SPECENUM_VALUE6 REQ_RANGE_PLAYER
53#define SPECENUM_VALUE6NAME "Player"
54#define SPECENUM_VALUE7 REQ_RANGE_TEAM
55#define SPECENUM_VALUE7NAME "Team"
56#define SPECENUM_VALUE8 REQ_RANGE_ALLIANCE
57#define SPECENUM_VALUE8NAME "Alliance"
58#define SPECENUM_VALUE9 REQ_RANGE_WORLD
59#define SPECENUM_VALUE9NAME "World"
60#define SPECENUM_COUNT REQ_RANGE_COUNT
61#define REQ_RANGE_MAX (REQ_RANGE_COUNT - 1)
64#define req_range_iterate(_range_) \
66 enum req_range _range_; \
67 for (_range_ = REQ_RANGE_LOCAL ; _range_ < REQ_RANGE_COUNT ; \
68 _range_ = (enum req_range)(_range_ + 1)) {
70#define req_range_iterate_end \
88#define SPECVEC_TAG requirement
89#define SPECVEC_TYPE struct requirement
91#define requirement_vector_iterate(req_vec, preq) \
92 TYPED_VECTOR_ITERATE(struct requirement, req_vec, preq)
93#define requirement_vector_iterate_end VECTOR_ITERATE_END
162 const struct requirement_vector *vec);
165 const struct player *other_player,
168 const struct player *other_player,
172 const struct player *other_player,
173 const struct requirement_vector *
reqs,
179 const struct player *other_player,
186 const struct player *other_player,
188 void *data,
int n_data);
192 const struct player *other_player,
194 void *data,
int n_data);
197 const struct player *other_player,
198 const struct requirement_vector *
reqs,
199 struct requirement_vector *maybe_reqs,
201 void *data,
int n_data);
208 const struct player *other_player,
213 const struct requirement_vector *vec);
216 enum universals_n kind);
241 const struct requirement_vector *vec);
251typedef struct requirement_vector *
252(*requirement_vector_by_number)(
const void *parent_item,
266 const struct requirement_vector *vec);
267struct requirement_vector *
272#define SPECENUM_NAME req_vec_change_operation
273#define SPECENUM_VALUE0 RVCO_REMOVE
274#define SPECENUM_VALUE0NAME N_("Remove")
275#define SPECENUM_VALUE1 RVCO_APPEND
276#define SPECENUM_VALUE1NAME N_("Append")
277#define SPECENUM_COUNT RVCO_NOOP
302 const void *parent_item);
315 const void *parent_item);
319 const void *parent_item);
323 const void *parent_item);
327 const void *parent_item);
331 const void *parent_item);
351 char *buf,
size_t bufsz);
363#define universal_is_mentioned_by_requirement(preq, psource) \
364 are_universals_equal(&preq->source, psource)
366 const struct requirement_vector *
reqs,
377 const struct requirement_vector *
reqs,
388#define universals_iterate(_univ_) \
390 enum universals_n _univ_; \
391 for (_univ_ = VUT_NONE; _univ_ < VUT_COUNT; _univ_ = (enum universals_n)(_univ_ + 1)) {
393#define universals_iterate_end \
401#define requirement_fulfilled_by_government(_gov_, _rqs_) \
402 universal_fulfills_requirements(FALSE, (_rqs_), \
403 &(struct universal){.kind = VUT_GOVERNMENT, .value = {.govern = (_gov_)}})
404#define requirement_fulfilled_by_nation(_nat_, _rqs_) \
405 universal_fulfills_requirements(FALSE, (_rqs_), \
406 &(struct universal){.kind = VUT_NATION, .value = {.nation = (_nat_)}})
407#define requirement_fulfilled_by_improvement(_imp_, _rqs_) \
408 universal_fulfills_requirements(FALSE, (_rqs_), \
409 &(struct universal){.kind = VUT_IMPROVEMENT, \
410 .value = {.building = (_imp_)}})
411#define requirement_fulfilled_by_terrain(_ter_, _rqs_) \
412 universal_fulfills_requirements(FALSE, (_rqs_), \
413 &(struct universal){.kind = VUT_TERRAIN, \
414 .value = {.terrain = (_ter_)}})
415#define requirement_fulfilled_by_unit_class(_uc_, _rqs_) \
416 universal_fulfills_requirements(FALSE, (_rqs_), \
417 &(struct universal){.kind = VUT_UCLASS, .value = {.uclass = (_uc_)}})
418#define requirement_fulfilled_by_unit_type(_ut_, _rqs_) \
419 universal_fulfills_requirements(FALSE, (_rqs_), \
420 &(struct universal){.kind = VUT_UTYPE, .value = {.utype = (_ut_)}})
421#define requirement_fulfilled_by_extra(_ex_, _rqs_) \
422 universal_fulfills_requirements(FALSE, (_rqs_), \
423 &(struct universal){.kind = VUT_EXTRA, .value = {.extra = (_ex_)}})
424#define requirement_fulfilled_by_output_type(_o_, _rqs_) \
425 universal_fulfills_requirements(FALSE, (_rqs_), \
426 &(struct universal){.kind = VUT_OTYPE, .value = {.outputtype = (_o_)}})
427#define requirement_fulfilled_by_action(_act_, _rqs_) \
428 universal_fulfills_requirements(FALSE, (_rqs_), \
429 &(struct universal){.kind = VUT_ACTION, .value = {.action = (_act_)}})
431#define requirement_needs_improvement(_imp_, _rqs_) \
432 universal_fulfills_requirements(TRUE, (_rqs_), \
433 &(struct universal){.kind = VUT_IMPROVEMENT, \
434 .value = {.building = (_imp_)}})
437 const enum req_range
range,
439 const int max_value);
441#define requirement_diplrel_ereq(_id_, _range_, _present_) \
442 requirement_kind_ereq(_id_, _range_, _present_, DRO_LAST)
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)
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)
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)
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)
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)
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)
enum fc_tristate(* req_tester_cb)(const struct req_context *context, const struct player *other_player, const struct requirement *req, void *data, int n_data)
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)
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)
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)
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)
bool are_requirements_contradictions(const struct requirement *req1, const struct requirement *req2)
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)
bool universal_is_legal_in_requirement(const struct universal *univ)
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)
struct req_vec_problem * req_vec_get_first_missing_univ(const struct requirement_vector *vec, requirement_vector_number get_num, const void *parent_item)
struct 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 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)
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)
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(const struct req_context *context, const struct player *other_player, 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)
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 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
const struct output_type * output
const struct unit_type * unittype
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