Project

General

Profile

Feature #613 ยป 0001-Make-req-eval-functions-take-other_context-insted-of.patch

main - Alina Lenk, 05/13/2024 06:09 PM

View differences:

ai/default/daimilitary.c
**************************************************************************/
static enum fc_tristate
tactical_req_cb(const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement *req,
void *data, int n_data)
{
......
/* FIXME: in actor_reqs, may allow attack _from_ a city with... */
if (req->survives || NULL == context->city || is_great_wonder(b)
|| !city_has_building(context->city, b) || b->sabotage <= 0) {
return tri_req_active(context, other_player, req);
return tri_req_active(context, other_context, req);
}
/* Else may be sabotaged */
}
......
return TRI_MAYBE;
case VUT_MINVETERAN:
/* Can be changed forth but not back */
return is_req_preventing(context, other_player, req, RPT_POSSIBLE)
return is_req_preventing(context, other_context, req, RPT_POSSIBLE)
> REQUCH_CTRL ? TRI_NO : TRI_MAYBE;
case VUT_MINFOREIGNPCT:
case VUT_NATIONALITY:
/* Can be changed back but hardly forth (foreign citizens reduced first) */
switch (tri_req_active(context, other_player, req)) {
switch (tri_req_active(context, other_context, req)) {
case TRI_NO:
return req->present ? TRI_NO : TRI_MAYBE;
case TRI_YES:
......
case VUT_MINYEAR:
/* If it is not near, won't change */
return tri_req_active_turns(n_data, 5 /* WAG */,
context, other_player, req);
context, other_context, req);
case VUT_CITYSTATUS:
if (CITYS_OWNED_BY_ORIGINAL != req->source.value.citystatus
&& CITYS_TRANSFERRED != req->source.value.citystatus) {
......
case VUT_TERRFLAG:
case VUT_TERRAINALTER:
case VUT_NONE:
return tri_req_active(context, other_player, req);
return tri_req_active(context, other_context, req);
case VUT_COUNT:
/* Not implemented. */
break;
......
enabler) {
/* We assume that we could build or move units into the city
* that are not present there yet */
if (TRI_NO != tri_reqs_cb_active(&actor_ctx, target_player,
if (TRI_NO != tri_reqs_cb_active(&actor_ctx, &target_ctx,
&enabler->actor_reqs, NULL,
tactical_req_cb, NULL, turns)
&&
TRI_NO != tri_reqs_cb_active(&target_ctx, actor_player,
TRI_NO != tri_reqs_cb_active(&target_ctx, &actor_ctx,
&enabler->target_reqs, NULL,
tactical_req_cb, NULL, turns)) {
return TRUE;
common/actions.c
const struct req_context *actor,
const struct req_context *target)
{
return are_reqs_active(actor, target != NULL ? target->player : NULL,
&enabler->actor_reqs, RPT_CERTAIN)
&& are_reqs_active(target, actor != NULL ? actor->player : NULL,
&enabler->target_reqs, RPT_CERTAIN);
return are_reqs_active(actor, target, &enabler->actor_reqs, RPT_CERTAIN)
&& are_reqs_active(target, actor, &enabler->target_reqs, RPT_CERTAIN);
}
/**********************************************************************//**
......
result = TRI_NO;
action_enabler_list_iterate(action_enablers_for_action(wanted_action),
enabler) {
current = fc_tristate_and(mke_eval_reqs(actor->player, actor,
target->player,
current = fc_tristate_and(mke_eval_reqs(actor->player,
actor, target,
&enabler->actor_reqs,
RPT_CERTAIN),
mke_eval_reqs(actor->player, target,
actor->player,
mke_eval_reqs(actor->player,
target, actor,
&enabler->target_reqs,
RPT_CERTAIN));
if (current == TRI_YES) {
......
If meta knowledge is missing TRI_MAYBE will be returned.
context may be NULL. This is equivalent to passing an empty context.
context and other_context may be NULL. This is equivalent to passing
empty contexts.
**************************************************************************/
static bool is_effect_val_known(enum effect_type effect_type,
const struct player *pov_player,
const struct req_context *context,
const struct player *other_player)
const struct req_context *other_context)
{
effect_list_iterate(get_effects(effect_type), peffect) {
if (TRI_MAYBE == mke_eval_reqs(pov_player, context,
other_player,
if (TRI_MAYBE == mke_eval_reqs(pov_player, context, other_context,
&(peffect->reqs), RPT_CERTAIN)) {
return FALSE;
}
......
.unit = act_unit,
.unittype = unit_type_get(act_unit),
},
tgt_player)
&(const struct req_context) {
.player = tgt_player,
})
&& is_effect_val_known(EFT_ACTION_RESIST_PCT, act_player,
&(const struct req_context) {
.player = tgt_player,
.city = tgt_city,
.unit = act_unit,
},
act_player)) {
&(const struct req_context) {
.player = act_player,
})) {
int unconverted = action_dice_roll_odds(act_player, act_unit, tgt_city,
tgt_player, paction);
struct act_prob result = { .min = unconverted * ACTPROB_VAL_1_PCT,
......
.unittype = actu_type,
.action = paction,
},
tgt_player,
&(const struct req_context) {
.player = tgt_player,
},
EFT_ACTION_ODDS_PCT))
/ 100)
- ((odds
......
.unittype = actu_type,
.action = paction,
},
act_player,
&(const struct req_context) {
.player = act_player,
},
EFT_ACTION_RESIST_PCT))
/ 100);
......
{
action_enabler_list_iterate(action_enablers_for_action(wanted_action),
enabler) {
if (are_reqs_active(target, actor_player,
if (are_reqs_active(target,
&(const struct req_context) {
.player = actor_player,
},
&enabler->target_reqs, RPT_POSSIBLE)) {
return TRUE;
}
common/base.c
.player = pplayer,
.tile = ptile,
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->reqs, RPT_POSSIBLE);
}
......
.unit = punit,
.unittype = unit_type_get(punit),
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->reqs, RPT_CERTAIN);
}
common/combat.c
.city = pcity,
.tile = ptile,
},
owner, EFT_NUKE_PROOF)) {
&(const struct req_context) {
.player = owner,
},
EFT_NUKE_PROOF)) {
return pcity;
}
} square_iterate_end;
common/diptreaty.c
* the requirements. */
if (client_player == NULL || client_player == pfrom) {
if (!are_reqs_active(&(const struct req_context) { .player = pfrom },
pto, &clause_infos[type].giver_reqs, RPT_POSSIBLE)) {
&(const struct req_context) { .player = pto },
&clause_infos[type].giver_reqs, RPT_POSSIBLE)) {
return FALSE;
}
}
if (client_player == NULL || client_player == pto) {
if (!are_reqs_active(&(const struct req_context) { .player = pto },
pfrom, &clause_infos[type].receiver_reqs,
&(const struct req_context) { .player = pfrom },
&clause_infos[type].receiver_reqs,
RPT_POSSIBLE)) {
return FALSE;
}
}
if (client_player == NULL) {
if (!are_reqs_active(&(const struct req_context) { .player = pfrom },
pfrom, &clause_infos[type].either_reqs,
&(const struct req_context) { .player = pto },
&clause_infos[type].either_reqs,
RPT_POSSIBLE)
&& !are_reqs_active(&(const struct req_context) { .player = pto },
pfrom, &clause_infos[type].either_reqs,
&(const struct req_context) { .player = pfrom },
&clause_infos[type].either_reqs,
RPT_POSSIBLE)) {
return FALSE;
}
common/effects.c
context may be NULL. This is equivalent to passing an empty context.
**************************************************************************/
static bool is_effect_prevented(const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct effect *peffect,
const enum req_problem_type prob_type)
{
......
/* Only check present=FALSE requirements; these will return _FALSE_
* from is_req_active() if met, and need reversed prob_type */
if (!preq->present
&& !is_req_active(context, other_player,
&& !is_req_active(context, other_context,
preq, REVERSED_RPT(prob_type))) {
return TRUE;
}
......
context gives the target (or targets) to evaluate requirements against
effect_type gives the effect type to be considered
context may be NULL. This is equivalent to passing an empty context.
context and other_context may be NULL. This is equivalent to passing
empty contexts.
Returns the effect sources of this type _currently active_.
......
**************************************************************************/
int get_target_bonus_effects(struct effect_list *plist,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
enum effect_type effect_type)
{
int bonus = 0;
......
/* Loop over all effects of this type. */
effect_list_iterate(get_effects(effect_type), peffect) {
/* For each effect, see if it is active. */
if (are_reqs_active(context, other_player,
if (are_reqs_active(context, other_context,
&peffect->reqs, RPT_CERTAIN)) {
/* This code will add value of effect. If there's multiplier for
/* This code will add value of effect. If there's multiplier for
* effect and target_player aren't null, then value is multiplied
* by player's multiplier factor. */
if (peffect->multiplier) {
......
.unit = punit,
.unittype = utype,
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
etype);
}
common/effects.h
int get_target_bonus_effects(struct effect_list *plist,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
enum effect_type effect_type);
double get_effect_expected_value(const struct req_context *context,
const struct player *other_player,
common/extras.c
.player = pplayer,
.tile = ptile,
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->reqs,
RPT_POSSIBLE);
}
......
.unit = punit,
.unittype = unit_type_get(punit),
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->reqs,
RPT_CERTAIN);
}
......
.player = pplayer,
.tile = ptile,
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->rmreqs,
RPT_POSSIBLE);
}
......
.unit = punit,
.unittype = unit_type_get(punit),
},
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->rmreqs, RPT_CERTAIN);
}
......
}
extra_type_by_rmcause_iterate(ERM_ENTER, extra) {
if (tile_has_extra(ptile, extra)
&& are_reqs_active(&context, tile_owner(ptile), &extra->rmreqs,
RPT_POSSIBLE)) {
&& are_reqs_active(&context,
&(const struct req_context) {
.player = tile_owner(ptile),
},
&extra->rmreqs, RPT_POSSIBLE)) {
return TRUE;
}
} extra_type_by_rmcause_iterate_end;
......
}
extra_type_by_rmcause_iterate(ERM_ENTER, extra) {
if (tile_has_extra(ptile, extra)
&& are_reqs_active(&context, tile_owner(ptile), &extra->rmreqs,
RPT_POSSIBLE)) {
&& are_reqs_active(&context,
&(const struct req_context) {
.player = tile_owner(ptile),
},
&extra->rmreqs, RPT_POSSIBLE)) {
return TRUE;
}
} extra_type_by_rmcause_iterate_end;
......
&& is_native_tile_to_extra(pextra, ptile)
&& !extra_conflicting_on_tile(pextra, ptile)
&& are_reqs_active(&(const struct req_context) { .tile = ptile },
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->appearance_reqs, RPT_CERTAIN);
}
......
&& is_extra_removed_by(pextra, ERM_DISAPPEARANCE)
&& can_extra_be_removed(pextra, ptile)
&& are_reqs_active(&(const struct req_context) { .tile = ptile },
tile_owner(ptile),
&(const struct req_context) {
.player = tile_owner(ptile),
},
&pextra->disappearance_reqs, RPT_CERTAIN);
}
common/metaknowledge.c
Is an evaluation of the requirement accurate when pov_player evaluates
it?
context may be NULL. This is equivalent to passing an empty context.
context and other_context may be NULL. This is equivalent to passing
empty contexts.
TODO: Move the data to a data file. That will
- let non programmers help complete it and/or fix what is wrong
......
**************************************************************************/
static bool is_req_knowable(const struct player *pov_player,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement *req,
const enum req_problem_type prob_type)
{
......
if (context == NULL) {
context = req_context_empty();
}
if (other_context == NULL) {
other_context = req_context_empty();
}
if (req->source.kind == VUT_UTFLAG
|| req->source.kind == VUT_UTYPE
......
|| req->source.kind == VUT_DIPLREL_UNITANY_O) {
switch (req->range) {
case REQ_RANGE_LOCAL:
if (other_player == NULL
if (other_context->player == NULL
|| context->player == NULL) {
/* The two players may exist but not be passed when the problem
* type is RPT_POSSIBLE. */
......
}
if (pov_player == context->player
|| pov_player == other_player) {
|| pov_player == other_context->player) {
return TRUE;
}
if (can_plr_see_all_sym_diplrels_of(pov_player, context->player)
|| can_plr_see_all_sym_diplrels_of(pov_player, other_player)) {
|| can_plr_see_all_sym_diplrels_of(pov_player,
other_context->player)) {
return TRUE;
}
......
/**********************************************************************//**
Evaluate a single requirement given pov_player's knowledge.
context may be NULL. This is equivalent to passing an empty context.
context and other_context may be NULL. This is equivalent to passing
empty contexts.
Note: Assumed to use pov_player's data.
**************************************************************************/
enum fc_tristate
mke_eval_req(const struct player *pov_player,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement *req,
const enum req_problem_type prob_type)
{
if (!is_req_knowable(pov_player, context, other_player,
if (!is_req_knowable(pov_player, context, other_context,
req, prob_type)) {
return TRI_MAYBE;
}
if (is_req_active(context, other_player, req, prob_type)) {
if (is_req_active(context, other_context, req, prob_type)) {
return TRI_YES;
} else {
return TRI_NO;
......
/**********************************************************************//**
Evaluate a requirement vector given pov_player's knowledge.
context may be NULL. This is equivalent to passing an empty context.
context and other_context may be NULL. This is equivalent to passing
empty contexts.
Note: Assumed to use pov_player's data.
**************************************************************************/
enum fc_tristate
mke_eval_reqs(const struct player *pov_player,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement_vector *reqs,
const enum req_problem_type prob_type)
{
......
result = TRI_YES;
requirement_vector_iterate(reqs, preq) {
current = mke_eval_req(pov_player, context, other_player,
current = mke_eval_req(pov_player, context, other_context,
preq, prob_type);
if (current == TRI_NO) {
return TRI_NO;
common/metaknowledge.h
enum fc_tristate
mke_eval_req(const struct player *pov_player,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement *req,
const enum req_problem_type prob_type);
enum fc_tristate
mke_eval_reqs(const struct player *pov_player,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement_vector *reqs,
const enum req_problem_type prob_type);
common/player.c
.unittype = off_ut,
.action = paction,
},
tgt_plr,
&(const struct req_context) {
.player = tgt_plr,
},
outcome);
if (casus_belli_amount >= CASUS_BELLI_OUTRAGE) {
common/requirements.c
static
enum fc_tristate tri_req_present(const struct civ_map *nmap,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement *req);
/* Function pointer for requirement-type-specific is_req_active handlers */
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 req_context *other_context,
const struct requirement *req);
static inline bool are_tiles_in_range(const struct tile *tile1,
......
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
context, other_context and req must not be null,
and req must be a none requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_NONE);
......
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
context, other_context and req must not be null,
and req must be a building requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct impr_type *building;
......
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
context, other_context and req must not be null,
and req must be a building genus requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_IMPR_GENUS);
......
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
context, other_context and req must not be null,
and req must be a building flag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_IMPR_FLAG);
......
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
context, other_context and req must not be null,
and req must be a player flag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_PLAYER_FLAG);
......
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
context, other_context and req must not be null,
and req must be a player state requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_PLAYER_STATE);
......
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
context, other_context and req must not be null,
and req must be a tech requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
Tech_type_id tech;
......
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
context, other_context and req must not be null,
and req must be a techflag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum tech_flag_id techflag;
......
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
context, other_context and req must not be null,
and req must be a minculture requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
int minculture;
......
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
context, other_context and req must not be null,
and req must be a minforeignpct requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
int min_foreign_pct, foreign_pct;
......
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
context, other_context and req must not be null,
and req must be a maxunitsontile requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
int max_units;
......
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
context, other_context and req must not be null,
and req must be an extra requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct extra_type *pextra;
......
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
context, other_context and req must not be null,
and req must be a goods requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct goods_type *pgood;
......
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
context, other_context and req must not be null,
and req must be an action requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_ACTION);
......
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
context, other_context and req must not be null,
and req must be an output type requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_OTYPE);
......
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
context, other_context and req must not be null,
and req must be a specialist requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_SPECIALIST);
......
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
context, other_context and req must not be null,
and req must be a terrain requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct terrain *pterrain;
......
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
context, other_context and req must not be null,
and req must be a terrain class requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum terrain_class pclass;
......
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
context, other_context and req must not be null,
and req must be a terrain flag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum terrain_flag_id terrflag;
......
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
context, other_context and req must not be null,
and req must be a roadflag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum road_flag_id roadflag;
......
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
context, other_context and req must not be null,
and req must be an extraflag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum extra_flag_id extraflag;
......
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
context, other_context and req must not be null,
and req must be a terrainalter requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum terrain_alteration alteration;
......
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
context, other_context and req must not be null,
and req must be a gov requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_GOVERNMENT);
......
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
context, other_context and req must not be null,
and req must be a style requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_STYLE);
......
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
context, other_context and req must not be null,
and req must be a mintechs requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINTECHS);
......
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 mincities requirement
context, other_context and req must not be null,
and req must be a mincities requirement
**************************************************************************/
static enum fc_tristate
is_mincities_req_active(const struct civ_map *nmap,
const struct req_context *context,
const struct player *other_player,
const struct req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINCITIES);
......
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
context, other_context and req must not be null,
and req must be an AI level requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_AI_LEVEL);
......
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
context, other_context and req must not be null,
and req must be a nation requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct nation_type *nation;
......
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
context, other_context and req must not be null,
and req must be a nation group requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct nation_group *ngroup;
......
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
context, other_context and req must not be null,
and req must be a nationality requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct nation_type *nationality;
......
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
context, other_context and req must not be null,
and req must be an original owner requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct nation_type *nation;
......
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
context, other_context and req must not be null,
and req must be a diplrel requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_DIPLREL);
return is_diplrel_in_range(context->player, other_player, req->range,
req->source.value.diplrel);
return is_diplrel_in_range(context->player, other_context->player,
req->range, req->source.value.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_tile
requirement
context, other_context and req must not be null,
and req must be a diplrel_tile requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_DIPLREL_TILE);
......
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
context, other_context and req must not be null,
and req must be a diplrel_tile_o requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_DIPLREL_TILE_O);
return is_diplrel_in_range(context->tile ? tile_owner(context->tile)
: NULL,
other_player,
other_context->player,
req->range,
req->source.value.diplrel);
}
......
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
context, other_context and req must not be null,
and req must be a diplrel_unitany requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_DIPLREL_UNITANY);
......
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
context, other_context and req must not be null,
and req must be a diplrel_unitany_o requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_DIPLREL_UNITANY_O);
return is_diplrel_unitany_in_range(context->tile, other_player,
return is_diplrel_unitany_in_range(context->tile, other_context->player,
req->range,
req->source.value.diplrel);
}
......
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
context, other_context and req must not be null,
and req must be a unittype requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct unit_type *punittype;
......
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
context, other_context and req must not be null,
and req must be a unitflag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum unit_type_flag_id unitflag;
......
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
context, other_context and req must not be null,
and req must be a unitclass requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct unit_class *pclass;
......
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
context, other_context and req must not be null,
and req must be a unitclassflag requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum unit_class_flag_id ucflag;
......
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
context, other_context and req must not be null,
and req must be a unitstate requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum ustate_prop uprop;
......
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
context, other_context and req must not be null,
and req must be an activity requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum unit_activity activity;
......
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
context, other_context and req must not be null,
and req must be a minveteran requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINVETERAN);
......
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
context, other_context and req must not be null,
and req must be a minmovefrags requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINMOVES);
......
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
context, other_context and req must not be null,
and req must be a minhitpoints requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINHP);
......
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
context, other_context and req must not be null,
and req must be an age requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_AGE);
......
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
context, other_context and req must not be null,
and req must be a form age requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_FORM_AGE);
......
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
context, other_context and req must not be null,
and req must be a citytile requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum citytile_type citytile;
......
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
context, other_context and req must not be null,
and req must be a city status requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
enum citystatus_type citystatus;
......
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
context, other_context and req must not be null,
and req must be a minsize requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_MINSIZE);
......
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
context, other_context and req must not be null,
and req must be a counter requirement
**************************************************************************/
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 req_context *other_context,
const struct requirement *req)
{
const struct counter *count;
......
context, ignoring parts of the requirement that can be handled uniformly
for all requirement types.
... This diff was truncated because it exceeds the maximum size that can be displayed.
    (1-1/1)