Project

General

Profile

Feature #61 » 0010-Add-map-parameter-for-is_req_active_cb.patch

S3_1 - Marko Lindqvist, 12/14/2023 12:11 AM

View differences:

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)
{
......
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)
{
IS_REQ_ACTIVE_VARIANT_ASSERT(VUT_GOOD);
......
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)
{
......
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 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;
}
......
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)
{
......
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)
{
......
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)
{
......
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);
(2-2/2)