Freeciv-3.3
Loading...
Searching...
No Matches
Functions | Variables
extras.c File Reference
#include "rand.h"
#include "string_vector.h"
#include "base.h"
#include "game.h"
#include "map.h"
#include "research.h"
#include "road.h"
#include "extras.h"

Go to the source code of this file.

Functions

void extras_init (void)
 
void extras_free (void)
 
int extra_count (void)
 
int extra_number (const struct extra_type *pextra)
 
struct extra_typeextra_by_number (int id)
 
const charextra_name_translation (const struct extra_type *pextra)
 
const charextra_rule_name (const struct extra_type *pextra)
 
struct extra_typeextra_type_by_rule_name (const char *name)
 
struct extra_typeextra_type_by_translated_name (const char *name)
 
struct extra_type_listextra_type_list_by_cause (enum extra_cause cause)
 
struct extra_type_listextra_type_list_of_unit_hiders (void)
 
struct extra_type_listextra_type_list_of_zoccers (void)
 
struct extra_type_listextra_type_list_of_terr_claimers (void)
 
struct extra_typerand_extra_for_tile (struct tile *ptile, enum extra_cause cause, bool generated)
 
void extra_to_caused_by_list (struct extra_type *pextra, enum extra_cause cause)
 
struct extra_type_listextra_type_list_by_rmcause (enum extra_rmcause rmcause)
 
struct extra_type_listextra_type_list_cleanable (void)
 
void _extra_to_removed_by_list (struct extra_type *pextra, enum extra_rmcause rmcause)
 
bool is_extra_removed_by (const struct extra_type *pextra, enum extra_rmcause rmcause)
 
bool is_extra_card_near (const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pextra)
 
bool is_extra_near_tile (const struct civ_map *nmap, const struct tile *ptile, const struct extra_type *pextra)
 
bool extra_can_be_built (const struct extra_type *pextra, const struct tile *ptile)
 
bool can_build_extra_base (const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
 
bool player_can_build_extra (const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
 
bool player_can_place_extra (const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
 
bool can_build_extra (const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
 
static bool can_extra_be_removed (const struct extra_type *pextra, const struct tile *ptile)
 
bool player_can_remove_extra (const struct extra_type *pextra, const struct player *pplayer, const struct tile *ptile)
 
bool can_remove_extra (const struct extra_type *pextra, const struct unit *punit, const struct tile *ptile)
 
bool is_native_tile_to_extra (const struct extra_type *pextra, const struct tile *ptile)
 
bool extra_conflicting_on_tile (const struct extra_type *pextra, const struct tile *ptile)
 
bool hut_on_tile (const struct tile *ptile)
 
bool unit_can_enter_hut (const struct unit *punit, const struct tile *ptile)
 
bool unit_can_displace_hut (const struct unit *punit, const struct tile *ptile)
 
struct extra_typenext_extra_for_tile (const struct tile *ptile, enum extra_cause cause, const struct player *pplayer, const struct unit *punit)
 
struct extra_typeprev_extra_in_tile (const struct tile *ptile, enum extra_rmcause rmcause, const struct player *pplayer, const struct unit *punit)
 
struct extra_typeprev_cleanable_in_tile (const struct tile *ptile, const struct player *pplayer, const struct unit *punit)
 
bool is_native_extra_to_uclass (const struct extra_type *pextra, const struct unit_class *pclass)
 
bool is_native_extra_to_utype (const struct extra_type *pextra, const struct unit_type *punittype)
 
bool extra_has_flag (const struct extra_type *pextra, enum extra_flag_id flag)
 
bool is_extra_flag_card_near (const struct civ_map *nmap, const struct tile *ptile, enum extra_flag_id flag)
 
bool is_extra_flag_near_tile (const struct civ_map *nmap, const struct tile *ptile, enum extra_flag_id flag)
 
void user_extra_flags_init (void)
 
void extra_flags_free (void)
 
void set_user_extra_flag_name (enum extra_flag_id id, const char *name, const char *helptxt)
 
const charextra_flag_id_name_cb (enum extra_flag_id flag)
 
const charextra_flag_helptxt (enum extra_flag_id id)
 
bool extra_flag_is_in_use (enum extra_flag_id id)
 
bool can_extras_coexist (const struct extra_type *pextra1, const struct extra_type *pextra2)
 
bool extra_causes_env_upset (struct extra_type *pextra, enum environment_upset_type upset)
 
bool is_extra_caused_by_worker_action (const struct extra_type *pextra)
 
bool is_extra_removed_by_worker_action (const struct extra_type *pextra)
 
bool is_extra_caused_by_action (const struct extra_type *pextra, const struct action *paction)
 
bool is_extra_removed_by_action (const struct extra_type *pextra, const struct action *paction)
 
enum extra_cause activity_to_extra_cause (enum unit_activity act)
 
enum extra_rmcause activity_to_extra_rmcause (enum unit_activity act)
 
struct playerextra_owner (const struct tile *ptile)
 
bool can_extra_appear (const struct extra_type *pextra, const struct tile *ptile)
 
bool can_extra_disappear (const struct extra_type *pextra, const struct tile *ptile)
 
bool player_knows_extra_exist (const struct player *pplayer, const struct extra_type *pextra, const struct tile *ptile)
 

Variables

static struct extra_type extras [MAX_EXTRA_TYPES]
 
static struct user_flag user_extra_flags [MAX_NUM_USER_EXTRA_FLAGS]
 
static struct extra_type_listcaused_by [EC_LAST]
 
static struct extra_type_listremoved_by [ERM_COUNT]
 
static struct extra_type_listcleanable
 
static struct extra_type_listunit_hidden
 
static struct extra_type_listzoccers
 
static struct extra_type_listterr_claimer
 

Function Documentation

◆ _extra_to_removed_by_list()

void _extra_to_removed_by_list ( struct extra_type pextra,
enum extra_rmcause  rmcause 
)

Add extra type to list of extra removed by given cause.

Definition at line 340 of file extras.c.

Referenced by extra_to_removed_by_list().

◆ activity_to_extra_cause()

enum extra_cause activity_to_extra_cause ( enum unit_activity  act)

◆ activity_to_extra_rmcause()

enum extra_rmcause activity_to_extra_rmcause ( enum unit_activity  act)

◆ can_build_extra()

bool can_build_extra ( const struct extra_type pextra,
const struct unit punit,
const struct tile ptile 
)

Tells if unit can build extra on tile.

Definition at line 535 of file extras.c.

Referenced by actres_possible(), can_unit_do_connect(), and next_extra_for_tile().

◆ can_build_extra_base()

bool can_build_extra_base ( const struct extra_type pextra,
const struct player pplayer,
const struct tile ptile 
)

Tells if player can build extra to tile with suitable unit.

Definition at line 413 of file extras.c.

Referenced by can_build_base(), can_build_extra(), can_build_road(), player_can_build_base(), player_can_build_extra(), and player_can_build_road().

◆ can_extra_appear()

bool can_extra_appear ( const struct extra_type pextra,
const struct tile ptile 
)

Are all the requirements for extra to appear on tile fulfilled.

Definition at line 1136 of file extras.c.

Referenced by end_turn().

◆ can_extra_be_removed()

static bool can_extra_be_removed ( const struct extra_type pextra,
const struct tile ptile 
)
static

Is it possible at all to remove this extra now

Definition at line 561 of file extras.c.

Referenced by can_extra_disappear(), can_remove_extra(), and player_can_remove_extra().

◆ can_extra_disappear()

bool can_extra_disappear ( const struct extra_type pextra,
const struct tile ptile 
)

Are all the requirements for extra to disappear from tile fulfilled.

Definition at line 1152 of file extras.c.

Referenced by end_turn().

◆ can_extras_coexist()

bool can_extras_coexist ( const struct extra_type pextra1,
const struct extra_type pextra2 
)

◆ can_remove_extra()

bool can_remove_extra ( const struct extra_type pextra,
const struct unit punit,
const struct tile ptile 
)

Tells if unit can remove extra from tile. Does not examine action requirements if an action is required for it.

Definition at line 618 of file extras.c.

Referenced by actres_possible(), prev_cleanable_in_tile(), and prev_extra_in_tile().

◆ extra_by_number()

struct extra_type * extra_by_number ( int  id)

◆ extra_can_be_built()

bool extra_can_be_built ( const struct extra_type pextra,
const struct tile ptile 
)

Tells if extra can build to tile if all other requirements are met.

Definition at line 394 of file extras.c.

Referenced by can_build_extra_base().

◆ extra_causes_env_upset()

bool extra_causes_env_upset ( struct extra_type pextra,
enum environment_upset_type  upset 
)

Does the extra count toward environment upset?

Definition at line 1030 of file extras.c.

Referenced by update_environmental_upset().

◆ extra_conflicting_on_tile()

bool extra_conflicting_on_tile ( const struct extra_type pextra,
const struct tile ptile 
)

Returns TRUE iff an extra that conflicts with pextra exists at ptile.

Definition at line 688 of file extras.c.

Referenced by can_extra_appear().

◆ extra_count()

int extra_count ( void  )

Return the number of extra_types.

Definition at line 153 of file extras.c.

Referenced by fill_tile_edit_packet(), helptext_unit(), player_tile_init(), receive_packet_ruleset_terrain_100(), and tileset_setup_base().

◆ extra_flag_helptxt()

const char * extra_flag_helptxt ( enum extra_flag_id  id)

Return the (untranslated) help text of the user extra flag.

Definition at line 988 of file extras.c.

Referenced by helptext_extra(), save_terrain_ruleset(), and send_ruleset_extras().

◆ extra_flag_id_name_cb()

const char * extra_flag_id_name_cb ( enum extra_flag_id  flag)

Extra flag name callback, called from specenum code.

Definition at line 976 of file extras.c.

Referenced by save_terrain_ruleset().

◆ extra_flag_is_in_use()

bool extra_flag_is_in_use ( enum extra_flag_id  id)

Returns TRUE iff the specified extra type flag is in use by any extra type.

Parameters
idthe extra type flag to check if is in use.
Returns
TRUE if the extra type flag is used in the current ruleset.

Definition at line 1001 of file extras.c.

Referenced by universal_never_there().

◆ extra_flags_free()

void extra_flags_free ( void  )

Frees the memory associated with all extra flags

Definition at line 935 of file extras.c.

Referenced by game_ruleset_free().

◆ extra_has_flag()

bool extra_has_flag ( const struct extra_type pextra,
enum extra_flag_id  flag 
)

◆ extra_name_translation()

const char * extra_name_translation ( const struct extra_type pextra)

◆ extra_number()

int extra_number ( const struct extra_type pextra)

◆ extra_owner()

struct player * extra_owner ( const struct tile ptile)

◆ extra_rule_name()

const char * extra_rule_name ( const struct extra_type pextra)

◆ extra_to_caused_by_list()

void extra_to_caused_by_list ( struct extra_type pextra,
enum extra_cause  cause 
)

Add extra type to list of extra caused by given cause.

Definition at line 312 of file extras.c.

Referenced by handle_ruleset_extra(), and load_ruleset_terrain().

◆ extra_type_by_rule_name()

struct extra_type * extra_type_by_rule_name ( const char name)

◆ extra_type_by_translated_name()

struct extra_type * extra_type_by_translated_name ( const char name)

Returns extra type matching the translated name, or NULL if there is no extra type with that name.

Definition at line 235 of file extras.c.

Referenced by help_update_extra(), help_dialog::make_tree(), and help_widget::set_topic_extra().

◆ extra_type_list_by_cause()

struct extra_type_list * extra_type_list_by_cause ( enum extra_cause  cause)

◆ extra_type_list_by_rmcause()

struct extra_type_list * extra_type_list_by_rmcause ( enum extra_rmcause  rmcause)

Returns extra type list for given rmcause.

Definition at line 322 of file extras.c.

◆ extra_type_list_cleanable()

struct extra_type_list * extra_type_list_cleanable ( void  )

Returns extra type list of cleanables

Definition at line 332 of file extras.c.

◆ extra_type_list_of_terr_claimers()

struct extra_type_list * extra_type_list_of_terr_claimers ( void  )

◆ extra_type_list_of_unit_hiders()

struct extra_type_list * extra_type_list_of_unit_hiders ( void  )

Returns extra types that hide units.

Definition at line 259 of file extras.c.

Referenced by handle_ruleset_extra(), load_ruleset_terrain(), and player_can_trust_tile_has_no_units().

◆ extra_type_list_of_zoccers()

struct extra_type_list * extra_type_list_of_zoccers ( void  )

Returns extra types that cauze ZoC by themselves.

Definition at line 267 of file extras.c.

Referenced by handle_ruleset_extra(), is_plr_zoc_client(), is_plr_zoc_srv(), and load_ruleset_terrain().

◆ extras_free()

void extras_free ( void  )

Free the memory associated with extras

Definition at line 84 of file extras.c.

Referenced by game_ruleset_free().

◆ extras_init()

void extras_init ( void  )

Initialize extras structures.

Definition at line 45 of file extras.c.

Referenced by game_ruleset_init().

◆ hut_on_tile()

bool hut_on_tile ( const struct tile ptile)

Returns TRUE iff an extra on the tile is a hut (removed by entering). The effect of entering is handled by unit_enter_hut() in unittools.c

Definition at line 705 of file extras.c.

Referenced by adv_data_phase_init(), dai_unit_move(), explorer_desirable(), and is_valid_start_pos().

◆ is_extra_card_near()

bool is_extra_card_near ( const struct civ_map nmap,
const struct tile ptile,
const struct extra_type pextra 
)

Is there extra of the given type cardinally near tile? (Does not check ptile itself.)

Definition at line 363 of file extras.c.

Referenced by is_extra_req_active().

◆ is_extra_caused_by_action()

bool is_extra_caused_by_action ( const struct extra_type pextra,
const struct action paction 
)

Is the extra caused by specific worker action?

Definition at line 1070 of file extras.c.

Referenced by texai_tile_worker_task_select(), and worker_evaluate_improvements().

◆ is_extra_caused_by_worker_action()

bool is_extra_caused_by_worker_action ( const struct extra_type pextra)

Is the extra caused by some kind of worker action?

Definition at line 1046 of file extras.c.

Referenced by helptext_extra(), initialize_infrastructure_cache(), load_ruleset_terrain(), and save_terrain_ruleset().

◆ is_extra_flag_card_near()

bool is_extra_flag_card_near ( const struct civ_map nmap,
const struct tile ptile,
enum extra_flag_id  flag 
)

Returns TRUE iff any cardinally adjacent tile contains an extra with the given flag (does not check ptile itself).

Definition at line 884 of file extras.c.

Referenced by is_extraflag_req_active().

◆ is_extra_flag_near_tile()

bool is_extra_flag_near_tile ( const struct civ_map nmap,
const struct tile ptile,
enum extra_flag_id  flag 
)

Returns TRUE iff any adjacent tile contains an extra with the given flag (does not check ptile itself).

Definition at line 904 of file extras.c.

Referenced by is_extraflag_req_active().

◆ is_extra_near_tile()

bool is_extra_near_tile ( const struct civ_map nmap,
const struct tile ptile,
const struct extra_type pextra 
)

Is there extra of the given type near tile? (Does not check ptile itself.)

Definition at line 379 of file extras.c.

Referenced by is_extra_req_active().

◆ is_extra_removed_by()

bool is_extra_removed_by ( const struct extra_type pextra,
enum extra_rmcause  rmcause 
)

◆ is_extra_removed_by_action()

bool is_extra_removed_by_action ( const struct extra_type pextra,
const struct action paction 
)

Is the extra removed by specific worker action?

Definition at line 1080 of file extras.c.

Referenced by texai_tile_worker_task_select(), and worker_evaluate_improvements().

◆ is_extra_removed_by_worker_action()

bool is_extra_removed_by_worker_action ( const struct extra_type pextra)

Is the extra removed by some kind of worker action?

Definition at line 1059 of file extras.c.

Referenced by initialize_infrastructure_cache().

◆ is_native_extra_to_uclass()

bool is_native_extra_to_uclass ( const struct extra_type pextra,
const struct unit_class pclass 
)

◆ is_native_extra_to_utype()

bool is_native_extra_to_utype ( const struct extra_type pextra,
const struct unit_type punittype 
)

Is extra native to unit type?

Definition at line 866 of file extras.c.

Referenced by create_extra(), destroy_extra(), and tile_has_not_aggressive_extra_for_unit().

◆ is_native_tile_to_extra()

bool is_native_tile_to_extra ( const struct extra_type pextra,
const struct tile ptile 
)

Is tile native to extra?

Definition at line 641 of file extras.c.

Referenced by add_recursive_extras(), can_extra_appear(), create_city(), rand_extra_for_tile(), remove_city(), and tile_change_terrain().

◆ next_extra_for_tile()

struct extra_type * next_extra_for_tile ( const struct tile ptile,
enum extra_cause  cause,
const struct player pplayer,
const struct unit punit 
)

◆ player_can_build_extra()

bool player_can_build_extra ( const struct extra_type pextra,
const struct player pplayer,
const struct tile ptile 
)

Tells if player can build extra to tile with suitable unit.

Definition at line 468 of file extras.c.

Referenced by adv_calc_extra(), can_extra_be_removed(), impr_provides_buildable_extras(), next_extra_for_tile(), player_can_place_extra(), and upgrade_city_extras().

◆ player_can_place_extra()

bool player_can_place_extra ( const struct extra_type pextra,
const struct player pplayer,
const struct tile ptile 
)

Tells if player can place extra on tile.

Definition at line 490 of file extras.c.

Referenced by handle_player_place_infra(), and infra_placement_set_tile().

◆ player_can_remove_extra()

bool player_can_remove_extra ( const struct extra_type pextra,
const struct player pplayer,
const struct tile ptile 
)

Tells if player can remove extra from tile with suitable unit. Entering or Frightening huts are not considered.

Definition at line 595 of file extras.c.

Referenced by adv_calc_rmextra(), prev_cleanable_in_tile(), and prev_extra_in_tile().

◆ player_knows_extra_exist()

bool player_knows_extra_exist ( const struct player pplayer,
const struct extra_type pextra,
const struct tile ptile 
)

Extra is not hidden from the user.

Definition at line 1167 of file extras.c.

Referenced by send_tile_info(), and update_player_tile_knowledge().

◆ prev_cleanable_in_tile()

struct extra_type * prev_cleanable_in_tile ( const struct tile ptile,
const struct player pplayer,
const struct unit punit 
)

Returns prev cleanable extra that unit or player can remove from tile.

Definition at line 831 of file extras.c.

Referenced by real_menus_update().

◆ prev_extra_in_tile()

struct extra_type * prev_extra_in_tile ( const struct tile ptile,
enum extra_rmcause  rmcause,
const struct player pplayer,
const struct unit punit 
)

◆ rand_extra_for_tile()

struct extra_type * rand_extra_for_tile ( struct tile ptile,
enum extra_cause  cause,
bool  generated 
)

Return random extra type for given cause that is native to the tile.

Definition at line 283 of file extras.c.

Referenced by do_nuke_tile(), fair_map_make_huts(), make_huts(), and place_pollution().

◆ set_user_extra_flag_name()

void set_user_extra_flag_name ( enum extra_flag_id  id,
const char name,
const char helptxt 
)

Sets user defined name for extra flag.

Definition at line 947 of file extras.c.

Referenced by handle_ruleset_extra_flag(), and load_terrain_names().

◆ unit_can_displace_hut()

bool unit_can_displace_hut ( const struct unit punit,
const struct tile ptile 
)

Returns TRUE iff the unit can enter or frighten any hut on the tile. For the unit, tests only its class and its owner.

Definition at line 749 of file extras.c.

Referenced by actres_possible().

◆ unit_can_enter_hut()

bool unit_can_enter_hut ( const struct unit punit,
const struct tile ptile 
)

Returns TRUE iff the unit can enter any hut on the tile. For the unit, tests only its class and its owner.

Definition at line 720 of file extras.c.

Referenced by dai_rampage_want(), and explorer_desirable().

◆ user_extra_flags_init()

void user_extra_flags_init ( void  )

Initialize user extra flags.

Definition at line 923 of file extras.c.

Referenced by game_ruleset_init().

Variable Documentation

◆ caused_by

struct extra_type_list* caused_by[EC_LAST]
static

◆ cleanable

struct extra_type_list* cleanable
static

◆ extras

◆ removed_by

struct extra_type_list* removed_by[ERM_COUNT]
static

◆ terr_claimer

struct extra_type_list* terr_claimer
static

Definition at line 40 of file extras.c.

Referenced by extra_type_list_of_terr_claimers(), extras_free(), and extras_init().

◆ unit_hidden

struct extra_type_list* unit_hidden
static

Definition at line 38 of file extras.c.

Referenced by extra_type_list_of_unit_hiders(), extras_free(), and extras_init().

◆ user_extra_flags

struct user_flag user_extra_flags[MAX_NUM_USER_EXTRA_FLAGS]
static

◆ zoccers

struct extra_type_list* zoccers
static