Feature #61 » 0031-Add-map-parameter-for-is_req_active_cb.patch
common/requirements.c | ||
---|---|---|
/* Function pointer for requirement-type-specific is_req_active handlers */
|
||
typedef enum fc_tristate
|
||
(*is_req_active_cb)(const struct req_context *context,
|
||
(*is_req_active_cb)(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req);
|
||
... | ... | |
context and req must not be null, and req must be a none requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_none_req_active(const struct req_context *context,
|
||
is_none_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a building requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_building_req_active(const struct req_context *context,
|
||
is_building_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_buildinggenus_req_active(const struct req_context *context,
|
||
is_buildinggenus_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_buildingflag_req_active(const struct req_context *context,
|
||
is_buildingflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_plr_flag_req_active(const struct req_context *context,
|
||
is_plr_flag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_plr_state_req_active(const struct req_context *context,
|
||
is_plr_state_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a tech requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_tech_req_active(const struct req_context *context,
|
||
is_tech_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a techflag requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_techflag_req_active(const struct req_context *context,
|
||
is_techflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a minculture requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minculture_req_active(const struct req_context *context,
|
||
is_minculture_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minforeignpct_req_active(const struct req_context *context,
|
||
is_minforeignpct_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_maxunitsontile_req_active(const struct req_context *context,
|
||
is_maxunitsontile_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
if (unit_list_size(context->tile->units) <= max_units) {
|
||
return TRI_YES;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (unit_list_size(adjc_tile->units) <= max_units) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (unit_list_size(context->tile->units) <= max_units) {
|
||
return TRI_YES;
|
||
}
|
||
adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (unit_list_size(adjc_tile->units) <= max_units) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
context and req must not be null, and req must be an extra requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_extra_req_active(const struct req_context *context,
|
||
is_extra_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
const struct extra_type *pextra;
|
||
enum fc_tristate ret;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_EXTRA);
|
||
... | ... | |
context and req must not be null, and req must be a goods requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_good_req_active(const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
is_good_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
const struct goods_type *pgood;
|
||
... | ... | |
context and req must not be null, and req must be an action requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_action_req_active(const struct req_context *context,
|
||
is_action_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_outputtype_req_active(const struct req_context *context,
|
||
is_outputtype_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a specialist requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_specialist_req_active(const struct req_context *context,
|
||
is_specialist_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a terrain requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_terrain_req_active(const struct req_context *context,
|
||
is_terrain_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_terrainclass_req_active(const struct req_context *context,
|
||
is_terrainclass_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_terrainflag_req_active(const struct req_context *context,
|
||
is_terrainflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a roadflag requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_roadflag_req_active(const struct req_context *context,
|
||
is_roadflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
enum road_flag_id roadflag;
|
||
enum fc_tristate ret;
|
||
struct civ_map *nmap = &(wld.map);
|
||
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_ROADFLAG);
|
||
... | ... | |
context and req must not be null, and req must be an extraflag requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_extraflag_req_active(const struct req_context *context,
|
||
is_extraflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
enum extra_flag_id extraflag;
|
||
enum fc_tristate ret;
|
||
const struct civ_map *nmap = &(wld.map);
|
||
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_EXTRAFLAG);
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_terrainalter_req_active(const struct req_context *context,
|
||
is_terrainalter_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a gov requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_gov_req_active(const struct req_context *context,
|
||
is_gov_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a style requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_style_req_active(const struct req_context *context,
|
||
is_style_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a mintechs requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_mintechs_req_active(const struct req_context *context,
|
||
is_mintechs_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
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 req_context *context,
|
||
is_ai_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a nation requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_nation_req_active(const struct req_context *context,
|
||
is_nation_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_nationgroup_req_active(const struct req_context *context,
|
||
is_nationgroup_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_nationality_req_active(const struct req_context *context,
|
||
is_nationality_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_originalowner_req_active(const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
is_originalowner_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
const struct nation_type *nation;
|
||
... | ... | |
context and req must not be null, and req must be a diplrel requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_diplrel_req_active(const struct req_context *context,
|
||
is_diplrel_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_diplrel_tile_req_active(const struct req_context *context,
|
||
is_diplrel_tile_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_diplrel_tile_o_req_active(const struct req_context *context,
|
||
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)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_diplrel_unitany_req_active(const struct req_context *context,
|
||
is_diplrel_unitany_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_diplrel_unitany_o_req_active(const struct req_context *context,
|
||
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)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a unittype requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_unittype_req_active(const struct req_context *context,
|
||
is_unittype_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a unitflag requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_unitflag_req_active(const struct req_context *context,
|
||
is_unitflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a unitclass requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_unitclass_req_active(const struct req_context *context,
|
||
is_unitclass_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_unitclassflag_req_active(const struct req_context *context,
|
||
is_unitclassflag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a unitstate requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_unitstate_req_active(const struct req_context *context,
|
||
is_unitstate_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
return BOOL_TO_TRISTATE(context->unit->transporter != NULL);
|
||
case USP_LIVABLE_TILE:
|
||
return BOOL_TO_TRISTATE(
|
||
can_unit_exist_at_tile(&(wld.map), context->unit,
|
||
can_unit_exist_at_tile(nmap, context->unit,
|
||
unit_tile(context->unit)));
|
||
break;
|
||
case USP_TRANSPORTING:
|
||
... | ... | |
context and req must not be null, and req must be an activity requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_activity_req_active(const struct req_context *context,
|
||
is_activity_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a minveteran requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minveteran_req_active(const struct req_context *context,
|
||
is_minveteran_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minmovefrags_req_active(const struct req_context *context,
|
||
is_minmovefrags_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minhitpoints_req_active(const struct req_context *context,
|
||
is_minhitpoints_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be an age requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_age_req_active(const struct req_context *context,
|
||
is_age_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
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 req_context *context,
|
||
is_form_age_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a citytile requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_citytile_req_active(const struct req_context *context,
|
||
is_citytile_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
if (is_city_in_tile(context->tile, context->city)) {
|
||
return TRI_YES;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (is_city_in_tile(adjc_tile, context->city)) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (is_city_in_tile(context->tile, context->city)) {
|
||
return TRI_YES;
|
||
}
|
||
adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (is_city_in_tile(adjc_tile, context->city)) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (context->tile->owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (adjc_tile->owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (context->tile->owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (adjc_tile->owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (context->tile->extras_owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (adjc_tile->extras_owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (context->tile->extras_owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (adjc_tile->extras_owner != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (context->tile->worked != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (adjc_tile->worked != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (context->tile->worked != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
if (adjc_tile->worked != NULL) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (tile_continent(target_tile) == cc) {
|
||
return TRI_YES;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), target_tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, target_tile, adjc_tile) {
|
||
if (tile_continent(adjc_tile) == cc) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
if (tile_continent(target_tile) == cc) {
|
||
return TRI_YES;
|
||
}
|
||
adjc_iterate(&(wld.map), target_tile, adjc_tile) {
|
||
adjc_iterate(nmap, target_tile, adjc_tile) {
|
||
if (tile_continent(adjc_tile) == cc) {
|
||
return TRI_YES;
|
||
}
|
||
... | ... | |
* Maybe, the city floats? Even if the rules prohibit it... */
|
||
return TRI_MAYBE;
|
||
}
|
||
adjc_iterate(&(wld.map), cc_tile, adjc_tile) {
|
||
adjc_iterate(nmap, cc_tile, adjc_tile) {
|
||
Continent_id tc = tile_continent(adjc_tile);
|
||
if (0 != tc) {
|
||
... | ... | |
case REQ_RANGE_ADJACENT:
|
||
if (ukt) {
|
||
/* If ALL the tiles in range are on cc, we can say it's false */
|
||
square_iterate(&(wld.map), target_tile, 1, adjc_tile) {
|
||
square_iterate(nmap, target_tile, 1, adjc_tile) {
|
||
if (tile_continent(adjc_tile) != cc) {
|
||
return TRI_MAYBE;
|
||
}
|
||
... | ... | |
return TRI_NO;
|
||
} else {
|
||
square_iterate(&(wld.map), target_tile, 1, adjc_tile) {
|
||
square_iterate(nmap, target_tile, 1, adjc_tile) {
|
||
Continent_id tc = tile_continent(adjc_tile);
|
||
if (0 == tc) {
|
||
... | ... | |
case REQ_RANGE_CADJACENT:
|
||
if (ukt) {
|
||
/* If ALL the tiles in range are on cc, we can say it's false */
|
||
circle_iterate(&(wld.map), target_tile, 1, cadjc_tile) {
|
||
circle_iterate(nmap, target_tile, 1, cadjc_tile) {
|
||
if (tile_continent(cadjc_tile) != cc) {
|
||
return TRI_MAYBE;
|
||
}
|
||
} circle_iterate_end;
|
||
} else {
|
||
circle_iterate(&(wld.map), target_tile, 1, cadjc_tile) {
|
||
circle_iterate(nmap, target_tile, 1, cadjc_tile) {
|
||
Continent_id tc = tile_continent(cadjc_tile);
|
||
if (0 == tc) {
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_citystatus_req_active(const struct req_context *context,
|
||
is_citystatus_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a minsize requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minsize_req_active(const struct req_context *context,
|
||
is_minsize_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a counter requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_counter_req_active(const struct req_context *context,
|
||
is_counter_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_achievement_req_active(const struct req_context *context,
|
||
is_achievement_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
maxlatitude requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_latitude_req_active(const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
is_latitude_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
int min = -MAP_MAX_LATITUDE, max = MAP_MAX_LATITUDE;
|
||
... | ... | |
return TRI_MAYBE;
|
||
}
|
||
cardinal_adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
cardinal_adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
int tile_lat = map_signed_latitude(adjc_tile);
|
||
if (min <= tile_lat && max >= tile_lat) {
|
||
... | ... | |
return TRI_MAYBE;
|
||
}
|
||
adjc_iterate(&(wld.map), context->tile, adjc_tile) {
|
||
adjc_iterate(nmap, context->tile, adjc_tile) {
|
||
int tile_lat = map_signed_latitude(adjc_tile);
|
||
if (min <= tile_lat && max >= tile_lat) {
|
||
... | ... | |
context and req must not be null, and req must be a minyear requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_minyear_req_active(const struct req_context *context,
|
||
is_minyear_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a mincalfrag requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_mincalfrag_req_active(const struct req_context *context,
|
||
is_mincalfrag_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a topology requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_topology_req_active(const struct req_context *context,
|
||
is_topology_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
context and req must not be null, and req must be a wrap requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_wrap_req_active(const struct req_context *context,
|
||
is_wrap_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
requirement
|
||
**************************************************************************/
|
||
static enum fc_tristate
|
||
is_serversetting_req_active(const struct req_context *context,
|
||
is_serversetting_req_active(const struct civ_map *nmap,
|
||
const struct req_context *context,
|
||
const struct player *other_player,
|
||
const struct requirement *req)
|
||
{
|
||
... | ... | |
fc_assert_ret_val(req_definitions[req->source.kind].cb != NULL, TRI_NO);
|
||
return req_definitions[req->source.kind].cb(context, other_player, req);
|
||
return req_definitions[req->source.kind].cb(&(wld.map), context,
|
||
other_player, req);
|
||
}
|
||
/**********************************************************************//**
|
common/requirements.h | ||
---|---|---|
}
|
||
#endif /* __cplusplus */
|
||
#endif /* FC__REQUIREMENTS_H */
|
||
#endif /* FC__REQUIREMENTS_H */
|
common/road.c | ||
---|---|---|
Returns TRUE iff any cardinally adjacent tile contains a road with
|
||
the given flag (does not check ptile itself).
|
||
****************************************************************************/
|
||
bool is_road_flag_card_near(struct civ_map *nmap, const struct tile *ptile,
|
||
bool is_road_flag_card_near(const struct civ_map *nmap,
|
||
const struct tile *ptile,
|
||
enum road_flag_id flag)
|
||
{
|
||
extra_type_by_cause_iterate(EC_ROAD, pextra) {
|
||
... | ... | |
Returns TRUE iff any adjacent tile contains a road with the given flag
|
||
(does not check ptile itself).
|
||
****************************************************************************/
|
||
bool is_road_flag_near_tile(struct civ_map *nmap, const struct tile *ptile,
|
||
bool is_road_flag_near_tile(const struct civ_map *nmap,
|
||
const struct tile *ptile,
|
||
enum road_flag_id flag)
|
||
{
|
||
extra_type_by_cause_iterate(EC_ROAD, pextra) {
|
common/road.h | ||
---|---|---|
/* Functions to operate on a road flag. */
|
||
bool road_has_flag(const struct road_type *proad, enum road_flag_id flag);
|
||
bool is_road_flag_card_near(struct civ_map *nmap, const struct tile *ptile,
|
||
bool is_road_flag_card_near(const struct civ_map *nmap, const struct tile *ptile,
|
||
enum road_flag_id flag);
|
||
bool is_road_flag_near_tile(struct civ_map *nmap, const struct tile *ptile,
|
||
bool is_road_flag_near_tile(const struct civ_map *nmap, const struct tile *ptile,
|
||
enum road_flag_id flag);
|
||
bool road_can_be_built(const struct road_type *proad, const struct tile *ptile);
|