Freeciv-3.1: /fast/freeciv/nightly/S3_1/common/player.c File Reference

Freeciv-3.1

Loading...
Searching...
No Matches
Data Structures | Macros | Functions | Variables
player.c File Reference
`#include "fcintl.h"`
`#include "log.h"`
`#include "mem.h"`
`#include "shared.h"`
`#include "support.h"`
`#include "ai.h"`
`#include "city.h"`
`#include "fc_interface.h"`
`#include "featured_text.h"`
`#include "game.h"`
`#include "government.h"`
`#include "idex.h"`
`#include "improvement.h"`
`#include "map.h"`
`#include "research.h"`
`#include "rgbcolor.h"`
`#include "tech.h"`
`#include "unit.h"`
`#include "unitlist.h"`
`#include "vision.h"`
`#include "player.h"`

Go to the source code of this file.

## Data Structures

struct | player_slot

## Macros

#define | DIPLREL_MESS_SIZE (3 + (DRO_LAST * (5 + 4 + 3 + 2 + 1)))

## Functions

static void | player_defaults (struct player *pplayer)
static void | player_diplstate_new (const struct player *plr1, const struct player *plr2)
static void | player_diplstate_defaults (const struct player *plr1, const struct player *plr2)
static void | player_diplstate_destroy (const struct player *plr1, const struct player *plr2)
enum diplstate_type | cancel_pact_result (enum diplstate_type oldstate)
enum dipl_reason | pplayer_can_cancel_treaty (const struct player *p1, const struct player *p2)
static bool | is_valid_alliance (const struct player *p1, const struct player *p2)
enum dipl_reason | pplayer_can_make_treaty (const struct player *p1, const struct player *p2, enum diplstate_type treaty)
bool | player_has_embassy (const struct player *pplayer, const struct player *pplayer2)
bool | team_has_embassy (const struct team *pteam, const struct player *tgt_player)
bool | player_has_real_embassy (const struct player *pplayer, const struct player *pplayer2)
bool | player_has_embassy_from_effect (const struct player *pplayer, const struct player *pplayer2)
bool | player_owns_city (const struct player *pplayer, const struct city *pcity)
bool | player_can_invade_tile (const struct player *pplayer, const struct tile *ptile)
struct player_diplstate * | player_diplstate_get (const struct player *plr1, const struct player *plr2)
void | player_slots_init (void)
bool | player_slots_initialised (void)
void | player_slots_free (void)
struct player_slot * | player_slot_first (void)
struct player_slot * | player_slot_next (struct player_slot *pslot)
int | player_slot_count (void)
int | player_slot_index (const struct player_slot *pslot)
struct player * | player_slot_get_player (const struct player_slot *pslot)
bool | player_slot_is_used (const struct player_slot *pslot)
struct player_slot * | player_slot_by_number (int player_id)
int | player_slot_max_used_number (void)
struct player * | player_new (struct player_slot *pslot)
void | player_set_color (struct player *pplayer, const struct rgbcolor *prgbcolor)
void | player_clear (struct player *pplayer, bool full)
void | player_ruleset_close (struct player *pplayer)
void | player_destroy (struct player *pplayer)
int | player_count (void)
int | player_index (const struct player *pplayer)
int | player_number (const struct player *pplayer)
struct player * | player_by_number (const int player_id)
bool | player_set_nation (struct player *pplayer, struct nation_type *pnation)
struct player * | player_by_name (const char *name)
const char * | player_name (const struct player *pplayer)
static const char * | player_name_by_number (int i)
struct player * | player_by_name_prefix (const char *name, enum m_pre_result *result)
struct player * | player_by_user (const char *name)
int | player_age (const struct player *pplayer)
bool | player_can_trust_tile_has_no_units (const struct player *pplayer, const struct tile *ptile)
bool | can_player_see_hypotetic_units_at (const struct player *pplayer, const struct tile *ptile)
bool | can_player_see_unit_at (const struct player *pplayer, const struct unit *punit, const struct tile *ptile, bool is_transported)
bool | can_player_see_unit (const struct player *pplayer, const struct unit *punit)
bool | can_player_see_units_in_city (const struct player *pplayer, const struct city *pcity)
bool | can_player_see_city_internals (const struct player *pplayer, const struct city *pcity)
bool | player_can_see_city_externals (const struct player *pow_player, const struct city *target_city)
struct city * | player_city_by_number (const struct player *pplayer, int city_id)
struct unit * | player_unit_by_number (const struct player *pplayer, int unit_id)
bool | player_in_city_map (const struct player *pplayer, const struct tile *ptile)
int | num_known_tech_with_flag (const struct player *pplayer, enum tech_flag_id flag)
int | player_get_expected_income (const struct player *pplayer)
bool | player_knows_techs_with_flag (const struct player *pplayer, enum tech_flag_id flag)
struct city * | player_primary_capital (const struct player *pplayer)
const char * | love_text (const int love)
bool | pplayers_at_war (const struct player *pplayer, const struct player *pplayer2)
bool | pplayers_allied (const struct player *pplayer, const struct player *pplayer2)
bool | pplayers_in_peace (const struct player *pplayer, const struct player *pplayer2)
bool | players_non_invade (const struct player *pplayer1, const struct player *pplayer2)
bool | pplayers_non_attack (const struct player *pplayer, const struct player *pplayer2)
bool | players_on_same_team (const struct player *pplayer1, const struct player *pplayer2)
bool | gives_shared_vision (const struct player *me, const struct player *them)
bool | are_diplstates_equal (const struct player_diplstate *pds1, const struct player_diplstate *pds2)
bool | is_diplrel_between (const struct player *player1, const struct player *player2, int diplrel)
bool | is_diplrel_to_other (const struct player *pplayer, int diplrel)
int | diplrel_by_rule_name (const char *value)
const char * | diplrel_rule_name (int value)
const char * | diplrel_name_translation (int value)
enum casus_belli_range | casus_belli_range_for (const struct player *offender, const struct unit_type *off_ut, const struct player *tgt_plr, const enum effect_type outcome, const struct action *paction, const struct tile *tgt_tile)
static bv_diplrel_all_reqs * | diplrel_mess_gen (void)
static bv_diplrel_all_reqs * | diplrel_mess_get (void)
void | diplrel_mess_close (void)
bv_diplrel_all_reqs | diplrel_req_contradicts (const struct requirement *req)
int | player_in_territory (const struct player *pplayer, const struct player *pplayer2)
bool | is_valid_username (const char *name)
bool | is_settable_ai_level (enum ai_level level)
int | number_of_ai_levels (void)
void * | player_ai_data (const struct player *pplayer, const struct ai_type *ai)
void | player_set_ai_data (struct player *pplayer, const struct ai_type *ai, void *data)
int | player_multiplier_value (const struct player *pplayer, const struct multiplier *pmul)
int | player_multiplier_effect_value (const struct player *pplayer, const struct multiplier *pmul)
int | player_multiplier_target_value (const struct player *pplayer, const struct multiplier *pmul)
bool | player_has_flag (const struct player *pplayer, enum plr_flag_id flag)

## Variables

struct { |
struct player_slot * slots |
int used_slots |
} | player_slots |
static bv_diplrel_all_reqs * | diplrel_mess = NULL

## Macro Definition Documentation

## ◆ DIPLREL_MESS_SIZE

#define DIPLREL_MESS_SIZE (3 + (DRO_LAST * (5 + 4 + 3 + 2 + 1)))

Definition at line 1644 of file player.c.

## Function Documentation

## ◆ are_diplstates_equal()

bool are_diplstates_equal | ( | const struct player_diplstate * | pds1,
|  | const struct player_diplstate * | pds2
| ) |  |

Return TRUE iff the two diplstates are equal.

Definition at line 1469 of file player.c.

## ◆ can_player_see_city_internals()

bool can_player_see_city_internals | ( | const struct player * | pplayer,
|  | const struct city * | pcity
| ) |  |

Return TRUE iff the player can see the city's internals. This means the full city packet is sent to the client, who should then be able to popup a dialog for it.

Returns TRUE if given a NULL player. This is used by the client when in observer mode.

Definition at line 1129 of file player.c.

Referenced by broadcast_city_info(), can_player_see_units_in_city(), city_packet_common(), control_mouse_cursor(), do_map_click(), is_action_possible(), is_req_knowable(), is_tile_seen_city(), is_tile_seen_trade_route(), meswin_add(), num_supported_units_in_city(), and player_can_see_city_externals().

## ◆ can_player_see_hypotetic_units_at()

bool can_player_see_hypotetic_units_at | ( | const struct player * | pplayer,
|  | const struct tile * | ptile
| ) |  |

Check if pplayer could see all units on ptile if it had units.

See can_player_see_unit_at() for rules about when an unit is visible.

Definition at line 984 of file player.c.

Referenced by action_prob_vs_units_full(), ap_diplomat_battle(), is_action_possible(), and is_req_knowable().

## ◆ can_player_see_unit()

bool can_player_see_unit | ( | const struct player * | pplayer,
|  | const struct unit * | punit
| ) |  |

Checks if a unit can be seen by pplayer at its current location.

See can_player_see_unit_at.

Definition at line 1084 of file player.c.

Referenced by action_prob(), action_prob_vs_units_full(), create_city(), create_extra(), destroy_extra(), find_best_tile_to_paradrop_to(), get_units_seen_via_ally(), give_allied_visibility(), is_action_possible(), is_req_knowable(), is_square_threatened(), map_change_seen(), map_claim_base(), maybe_cancel_patrol_due_to_enemy(), player_in_territory(), remove_allied_visibility(), remove_city(), send_combat(), send_unit_info(), tile_has_units_not_allied_to_but_seen_by(), transfer_city(), unit_move(), unit_transport_load_send(), and wakeup_neighbor_sentries().

## ◆ can_player_see_unit_at()

bool can_player_see_unit_at | ( | const struct player * | pplayer,
|  | const struct unit * | punit,
|  | const struct tile * | ptile,
|  | bool | is_transported
| ) |  |

Checks if a unit can be seen by pplayer at (x,y). A player can see a unit if they: (a) can see the tile AND (b) can see the unit at the tile (i.e. unit not invisible at this tile) AND (c) the unit is outside a city OR in an allied city AND (d) the unit isn't in a transporter, or we are allied AND (e) the unit isn't in a transporter, or we can see the transporter

Definition at line 1025 of file player.c.

Referenced by can_player_see_unit(), server_remove_unit_full(), and unit_move().

## ◆ can_player_see_units_in_city()

bool can_player_see_units_in_city | ( | const struct player * | pplayer,
|  | const struct city * | pcity
| ) |  |

Return TRUE iff the player can see units in the city. Either they can see all units or none.

If the player can see units in the city, then the server sends the unit info for units in the city to the client. The client uses the tile's unitlist to determine whether to show the city occupied flag. Of course the units will be visible to the player as well, if they click on them.

If the player can't see units in the city, then the server doesn't send the unit info for these units. The client therefore uses the "occupied" flag sent in the short city packet to determine whether to show the city occupied flag.

Note that can_player_see_city_internals => can_player_see_units_in_city. Otherwise the player would not know anything about the city's units at all, since the full city packet has no "occupied" flag.

Returns TRUE if given a NULL player. This is used by the client when in observer mode.

Definition at line 1113 of file player.c.

Referenced by can_player_see_hypotetic_units_at(), can_player_see_unit_at(), client_remove_unit(), create_city(), do_move_unit(), handle_city_info(), handle_unit_packet_common(), meswin_popup_city(), num_present_units_in_city(), popup_info_text(), remove_city(), show_full_citybar(), and unit_change_homecity_handling().

## ◆ cancel_pact_result()

enum diplstate_type cancel_pact_result | ( | enum diplstate_type | oldstate | ) |

Return the diplomatic state that cancelling a pact will end up in.

Definition at line 67 of file player.c.

Referenced by handle_diplomacy_cancel_pact(), players_war_callback(), and players_war_callback().

## ◆ casus_belli_range_for()

enum casus_belli_range casus_belli_range_for | ( | const struct player * | offender,
|  | const struct unit_type * | off_ut,
|  | const struct player * | tgt_plr,
|  | const enum effect_type | outcome,
|  | const struct action * | paction,
|  | const struct tile * | tgt_tile
| ) |  |

Definition at line 1604 of file player.c.

Referenced by action_consequence_common(), and dai_action_value_unit_vs_city().

## ◆ diplrel_by_rule_name()

int diplrel_by_rule_name | ( | const char * | value | ) |

Return the diplomatic relation that has the given (untranslated) rule name.

Definition at line 1545 of file player.c.

Referenced by universal_value_from_str().

## ◆ diplrel_mess_close()

void diplrel_mess_close | ( | void |  | ) |

Free diplrel_mess

Definition at line 1772 of file player.c.

Referenced by libfreeciv_free().

## ◆ diplrel_mess_gen()

static bv_diplrel_all_reqs * diplrel_mess_gen | ( | void |  | ) |

static

Generate and return an array of mutually exclusive requirement sets for the DiplRel requirement type. The array has DIPLREL_MESS_SIZE sets.

A mutually exclusive set is a set of requirements were the presence of one requirement proves the absence of every other requirement. In other words: at most one of the requirements in the set can be present.

Definition at line 1654 of file player.c.

Referenced by diplrel_mess_get().

## ◆ diplrel_mess_get()

static bv_diplrel_all_reqs * diplrel_mess_get | ( | void |  | ) |

static

Get the mutually exclusive requirement sets for DiplRel.

Definition at line 1759 of file player.c.

Referenced by diplrel_req_contradicts().

## ◆ diplrel_name_translation()

const char * diplrel_name_translation | ( | int | value | ) |

Return the translated name of the given diplomatic relation.

Definition at line 1591 of file player.c.

Referenced by helptext_unit(), req_text_insert(), universal_name_translation(), and worklist_item_postpone_req_vec().

## ◆ diplrel_req_contradicts()

bv_diplrel_all_reqs diplrel_req_contradicts | ( | const struct requirement * | req | ) |

Get the DiplRel requirements that are known to contradict the specified DiplRel requirement.

The known contratictions have their position in the enumeration of all possible DiplRel requirements set in the returned bitvector.

Definition at line 1787 of file player.c.

Referenced by are_requirements_contradictions().

## ◆ diplrel_rule_name()

const char * diplrel_rule_name | ( | int | value | ) |

Return the (untranslated) rule name of the given diplomatic relation.

Definition at line 1579 of file player.c.

Referenced by universal_rule_name().

## ◆ gives_shared_vision()

bool gives_shared_vision | ( | const struct player * | me,
|  | const struct player * | them
| ) |  |

Return TRUE iff the player me gives shared vision to player them.

Definition at line 1461 of file player.c.

Referenced by create_clause_menu(), dai_diplomacy_actions(), dai_go_to_war(), dai_share(), get_vision_status(), give_shared_vision(), handle_diplomacy_cancel_pact(), is_diplrel_between(), kill_player(), plr_widget::nation_selected(), package_player_info(), popup_add_menu(), popup_diplomacy_dialog(), popup_diplomatic_objects(), receive_packet_player_info_100(), remove_shared_vision(), server_remove_player(), sg_save_player_main(), shared_vision_is_safe(), diplo_wdg::show_menu(), update_players_menu(), and plr_report::update_report().

## ◆ is_diplrel_between()

bool is_diplrel_between | ( | const struct player * | player1,
|  | const struct player * | player2,
|  | int | diplrel
| ) |  |

Return TRUE iff player1 has the diplomatic relation to player2

Definition at line 1480 of file player.c.

Referenced by is_diplrel_in_range(), and is_diplrel_to_other().

## ◆ is_diplrel_to_other()

bool is_diplrel_to_other | ( | const struct player * | pplayer,
|  | int | diplrel
| ) |  |

Return TRUE iff pplayer has the diplomatic relation to any living player

Definition at line 1526 of file player.c.

Referenced by is_diplrel_in_range().

## ◆ is_settable_ai_level()

bool is_settable_ai_level | ( | enum ai_level | level | ) |

Return is AI can be set to given level

Definition at line 1883 of file player.c.

Referenced by create_ai_menu(), create_conn_menu(), create_players_dialog(), create_start_page(), pregame_options::init(), real_conn_list_dialog_update(), server_ai_level(), fc_client::start_page_menu(), and plr_report::toggle_ai_mode().

## ◆ is_valid_alliance()

static bool is_valid_alliance | ( | const struct player * | p1,
|  | const struct player * | p2
| ) |  |

static

Returns TRUE iff p1 can be in alliance with p2.

Check that we are not at war with any of p2's allies. Note that for an alliance to be made, we need to check this both ways.

The reason for this is to avoid the dread 'love-love-hate' triad, in which p1 is allied to p2 is allied to p3 is at war with p1. These lead to strange situations.

Definition at line 126 of file player.c.

Referenced by pplayer_can_make_treaty().

## ◆ is_valid_username()

bool is_valid_username | ( | const char * | name | ) |

Returns whether this is a valid username. This is used by the server to validate usernames and should be used by the client to avoid invalid ones.

Definition at line 1872 of file player.c.

Referenced by client_main(), and handle_login_request().

## ◆ love_text()

const char * love_text | ( | const int | love | ) |

Return a text describing an AI's love for you. (Oooh, kinky!!)

Definition at line 1330 of file player.c.

Referenced by col_love().

## ◆ num_known_tech_with_flag()

int num_known_tech_with_flag | ( | const struct player * | pplayer,
|  | enum tech_flag_id | flag
| ) |  |

Returns the number of techs the player has researched which has this flag. Needs to be optimized later (e.g. int tech_flags[TF_COUNT] in struct player)

Definition at line 1249 of file player.c.

Referenced by is_claimable_ocean(), and player_knows_techs_with_flag().

## ◆ number_of_ai_levels()

int number_of_ai_levels | ( | void |  | ) |

Return number of AI levels in game

Definition at line 1896 of file player.c.

## ◆ player_age()

int player_age | ( | const struct player * | pplayer | ) |

"Age" of the player: number of turns spent alive since created.

Definition at line 945 of file player.c.

Referenced by is_age_req_active(), and tri_req_active_turns().

## ◆ player_ai_data()

void * player_ai_data | ( | const struct player * | pplayer,
|  | const struct ai_type * | ai
| ) |  |

Return pointer to ai data of given player and ai type.

Definition at line 1904 of file player.c.

Referenced by def_ai_player_data(), tai_player_data(), tai_player_free(), texai_city_destruction_recv(), texai_city_info_recv(), texai_player_data(), texai_player_free(), texai_player_units(), texai_unit_destruction_recv(), and texai_unit_info_recv().

## ◆ player_by_name()

struct player * player_by_name | ( | const char * | name | ) |

Find player by given name.

Definition at line 872 of file player.c.

Referenced by aifill(), api_find_player_by_name(), create_command_newcomer(), create_command_pregame(), makeup_connection_name(), observe_command(), pick_random_player_name(), sg_load_treaties(), sg_load_treaties(), and take_command().

## ◆ player_by_name_prefix()

struct player * player_by_name_prefix | ( | const char * | name,
|  | enum m_pre_result * | result
| ) |  |

Find player by its name prefix

Definition at line 911 of file player.c.

Referenced by aicmd_command(), debug_command(), delegate_command(), handle_chat_msg_req(), mapimg_checkplayers(), observe_command(), playercolor_command(), playernation_command(), remove_player_command(), set_ai_level(), take_command(), team_command(), and toggle_ai_command().

## ◆ player_by_number()

struct player * player_by_number | ( | const int | player_id | ) |

Return struct player pointer for the given player index.

You can retrieve players that are not in the game (with IDs larger than player_count). An out-of-range player request will return NULL.

Definition at line 840 of file player.c.

Referenced by diplo_dlg::add_widget(), aifill(), diplo_wdg::all_advances(), api_find_player(), begin_phase(), button_press_callback(), bvplayers_str(), city_from_great_wonder(), client_aitoggle_player(), conn_list_selection(), connect_list_right_button(), connection_list_event(), diplo_wdg::diplo_wdg(), diplomacy_dialog_city_callback(), diplomacy_dialog_city_callback(), diplomacy_dialog_tech_callback(), diplomacy_dialog_tech_callback(), editbar_player_pov_combobox_changed(), editor_apply_tool(), editor_grab_applied_player(), editor_unit_virtual_create(), end_phase(), endgame_report_dialog_player(), find_diplomacy_dialog(), get_diplomacy_dialog(), get_info_label_text(), get_player_or_user_name(), diplo_wdg::give_advance(), diplo_wdg::give_city(), great_wonder_owner(), handle_city_info(), handle_city_short_info(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_meeting_req(), handle_diplomacy_cancel_pact(), handle_diplomacy_create_clause(), handle_diplomacy_create_clause_req(), handle_diplomacy_init_meeting(), handle_diplomacy_init_meeting_req(), handle_diplomacy_remove_clause(), handle_diplomacy_remove_clause_req(), handle_edit_city_create(), handle_edit_player(), handle_edit_player_remove(), handle_edit_player_vision(), handle_edit_tile(), handle_edit_tile_extra(), handle_edit_toggle_fogofwar(), handle_edit_unit_create(), handle_edit_unit_remove(), handle_nation_select_req(), handle_player_diplstate(), handle_player_ready(), handle_spaceship_info(), handle_tile_info(), handle_unit_short_info(), imgcolor_player(), kill_unit(), left_button_press_callback(), mapimg_checkplayers(), object_extract(), objtype_get_object_from_id(), player_by_name_prefix(), player_name_by_number(), players_ai_skill_callback(), players_ai_skill_callback(), players_ai_toggle_callback(), players_ai_toggle_callback(), players_intel_callback(), players_intel_callback(), players_intel_wonder_callback(), players_intel_wonder_callback(), players_sship_callback(), players_sship_callback(), players_vision_callback(), players_vision_callback(), players_war_callback(), players_war_callback(), plrdlg_sort_func(), popup_diplomacy_dialog(), property_page_create_objects(), research_iter_player_valid(), research_name_translation(), research_player_iter_init(), research_pretty_name(), research_rule_name(), right_button_press_callback(), sg_load_map_owner(), sg_load_map_owner(), sg_load_player_city(), sg_load_player_city(), sg_load_player_unit(), sg_load_player_unit(), sg_load_player_vision(), sg_load_player_vision(), sg_load_player_vision_city(), sg_load_player_vision_city(), diplo_wdg::show_menu(), shuffled_player(), start_command(), texai_city_info_recv(), texai_unit_info_recv(), toggle_goto_nations_cities_dialog_callback(), unpackage_short_unit(), unpackage_unit(), update_players_menu(), and endgame_report::update_report().

## ◆ player_by_user()

struct player * player_by_user | ( | const char * | name | ) |

Find player by its user name (not player/leader name)

Definition at line 931 of file player.c.

Referenced by create_command_newcomer(), create_command_pregame(), establish_new_connection(), makeup_connection_name(), and pick_random_player_name().

## ◆ player_can_invade_tile()

bool player_can_invade_tile | ( | const struct player * | pplayer,
|  | const struct tile * | ptile
| ) |  |

Return TRUE iff the player can invade a particular tile (linked with borders and diplomatic states).

Definition at line 264 of file player.c.

Referenced by pf_danger_node_init(), pf_fuel_node_init(), pf_normal_node_init(), player_may_explore(), unit_move_to_tile_test(), and unit_teleport_to_tile_test().

## ◆ player_can_see_city_externals()

bool player_can_see_city_externals | ( | const struct player * | pow_player,
|  | const struct city * | target_city
| ) |  |

Returns TRUE iff pow_player can see externally visible features of target_city.

A city's external features are visible to its owner, to players that currently sees the tile it is located at and to players that has it as a trade partner.

Definition at line 1143 of file player.c.

Referenced by action_prob_vs_city_full(), broadcast_city_info(), is_action_possible(), is_req_knowable(), and refresh_dumb_city().

## ◆ player_can_trust_tile_has_no_units()

bool player_can_trust_tile_has_no_units | ( | const struct player * | pplayer,
|  | const struct tile * | ptile
| ) |  |

Returns TRUE iff pplayer can trust that ptile really has no units when it looks empty. A tile looks empty if the player can't see any units on it and it doesn't contain anything marked as occupied by a unit.

See can_player_see_unit_at() for rules about when an unit is visible.

Definition at line 958 of file player.c.

Referenced by action_prob_vs_units_full(), and can_player_see_hypotetic_units_at().

## ◆ player_city_by_number()

struct city * player_city_by_number | ( | const struct player * | pplayer,
|  | int | city_id
| ) |  |

If the specified player owns the city with the specified id, return pointer to the city struct. Else return NULL. Now always uses fast idex_lookup_city.

pplayer may be NULL in which case all cities registered to hash are considered - even those not currently owned by any player. Callers expect this behavior.

Definition at line 1179 of file player.c.

Referenced by api_find_city(), city_from_wonder(), dai_find_strategic_airbase(), do_capture_units(), do_unit_establish_trade(), get_unit_info_label_text2(), handle_city_buy(), handle_city_change(), handle_city_change_specialist(), handle_city_make_specialist(), handle_city_make_worker(), handle_city_options_req(), handle_city_rally_point(), handle_city_refresh(), handle_city_rename(), handle_city_sell(), handle_city_worklist(), player_primary_capital(), popup_info_text(), sg_load_player_cities(), sg_load_player_cities(), supported_unit_activate_close_callback(), supported_unit_activate_close_callback(), unit_description(), hud_units::update_actions(), and update_city_activity().

## ◆ player_clear()

void player_clear | ( | struct player * | pplayer,
|  | bool | full
| ) |  |

Clear all player data.

If full is set, also

- The nation is cleared
- The team is cleared
- Nationality information of remaining units is adjusted

Definition at line 660 of file player.c.

Referenced by game_reset(), player_destroy(), and server_remove_player().

## ◆ player_count()

int player_count | ( | void |  | ) |

Return the number of players.

Definition at line 808 of file player.c.

Referenced by aifill(), api_methods_private_list_players(), assign_player_colors(), begin_turn(), bvplayers_count(), connection_attach_real(), create_command_newcomer(), create_start_positions(), generator_init_topology(), get_info_label_text(), handle_edit_player_create(), handle_start_phase(), historian_generic(), init_new_game(), is_allowed_to_take(), make_history_report(), map_fractal_generate(), map_generate_fair_islands(), mapgenerator2(), mapgenerator3(), mapgenerator4(), mapimg_client_plrcolor_count(), mapimg_client_plrcolor_get(), maxplayers_callback(), normal_player_count(), refresh_tool_applied_player_combo(), report_final_scores(), report_top_five_cities(), report_wonders_of_the_world(), sg_load_players_basic(), sg_load_players_basic(), sg_save_players(), show_colors(), show_players(), start_command(), take_command(), and plr_report::update_report().

## ◆ player_defaults()

static void player_defaults | ( | struct player * | pplayer | ) |

static

Set player structure to its default values. No initialisation to ruleset-dependent values should be done here.

Definition at line 544 of file player.c.

Referenced by player_new().

## ◆ player_destroy()

void player_destroy | ( | struct player * | pplayer | ) |

Destroys and remove a player from the game.

Definition at line 747 of file player.c.

Referenced by handle_player_remove(), player_slots_free(), server_create_player(), and server_remove_player().

## ◆ player_diplstate_defaults()

static void player_diplstate_defaults | ( | const struct player * | plr1,
|  | const struct player * | plr2
| ) |  |

static

Set diplstate between given two players to default values.

Definition at line 298 of file player.c.

Referenced by player_defaults().

## ◆ player_diplstate_destroy()

static void player_diplstate_destroy | ( | const struct player * | plr1,
|  | const struct player * | plr2
| ) |  |

static

Free resources used by diplstate between given two players.

Definition at line 334 of file player.c.

Referenced by player_destroy().

## ◆ player_diplstate_get()

struct player_diplstate * player_diplstate_get | ( | const struct player * | plr1,
|  | const struct player * | plr2
| ) |  |

Returns diplomatic state type between two players

Definition at line 317 of file player.c.

Referenced by action_give_casus_belli(), add_clause(), adv_data_phase_init(), adv_is_player_dangerous(), barbarian_initial_wars(), can_plr_see_all_sym_diplrels_of(), cities_trade_route_type(), col_diplstate(), col_government(), could_intel_with_player(), could_meet_with_player(), create_clause_menu(), dai_data_phase_begin(), dai_diplomacy_actions(), dai_diplomacy_begin_new_phase(), dai_diplomacy_first_contact(), dai_effect_value(), dai_go_to_war(), dai_goldequiv_clause(), dai_hunter_try_launch(), dai_incident_war(), dai_treaty_accepted(), dai_treaty_evaluate(), dai_war_desire(), diplo_wdg::diplo_wdg(), diplstate_value(), do_paradrop(), expl_act_not_enabl(), fill_row(), get_allied_with_enemy_player(), get_embassy_status(), get_gold_info(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact(), handle_player_diplstate(), is_diplrel_between(), is_valid_alliance(), make_contact(), plr_widget::nation_selected(), need_war_enabler(), package_player_diplstate(), package_player_info(), player_diplstate_defaults(), player_diplstate_destroy(), player_has_embassy_from_effect(), player_mood(), player_nation_callback(), players_non_invade(), players_war_callback(), players_war_callback(), popup_add_menu(), popup_diplomacy_dialog(), popup_diplomatic_objects(), popup_goto_airlift_dialog(), popup_info_text(), popup_players_nations_dialog(), pplayer_can_cancel_treaty(), pplayer_can_make_treaty(), pplayers_allied(), pplayers_at_war(), pplayers_in_peace(), pplayers_non_attack(), real_players_dialog_update(), redraw_unit_info_label(), rel_may_become_war(), score_tooltip(), sg_load_player_main(), sg_load_player_main(), sg_load_players(), sg_load_players(), sg_save_player_main(), shared_vision_is_safe(), diplo_wdg::show_menu(), split_player(), srv_ready(), update_diplomatics(), and update_intel_dialog().

## ◆ player_diplstate_new()

static void player_diplstate_new | ( | const struct player * | plr1,
|  | const struct player * | plr2
| ) |  |

static

Allocate new diplstate structure for tracking state between given two players.

Definition at line 278 of file player.c.

Referenced by player_new().

## ◆ player_get_expected_income()

int player_get_expected_income | ( | const struct player * | pplayer | ) |

Return the expected net income of the player this turn. This includes tax revenue and upkeep, but not one-time purchases or found gold.

This function depends on pcity->prod[O_GOLD] being set for all cities, so make sure the player's cities have been refreshed.

Definition at line 1262 of file player.c.

Referenced by dai_manage_cities(), get_info_label_text(), get_info_label_text_popup(), package_player_info(), show_new_turn_info(), and fc_client::update_info_label().

## ◆ player_has_embassy()

bool player_has_embassy | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Check if pplayer has an embassy with pplayer2. We always have an embassy with ourselves.

Definition at line 202 of file player.c.

Referenced by could_meet_with_player(), dai_choose_diplomat_offensive(), dai_manage_diplomat(), dai_share(), find_city_to_diplomat(), get_embassy_status(), is_diplrel_between(), and research_total_bulbs_required().

## ◆ player_has_embassy_from_effect()

bool player_has_embassy_from_effect | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Returns whether pplayer has got embassy with pplayer2 thanks to an effect (e.g. Macro Polo Embassy).

Definition at line 244 of file player.c.

Referenced by player_has_embassy(), and team_has_embassy().

## ◆ player_has_flag()

bool player_has_flag | ( | const struct player * | pplayer,
|  | enum plr_flag_id | flag
| ) |  |

Check if player has given flag

Definition at line 1954 of file player.c.

Referenced by api_methods_player_has_flag(), handle_edit_player(), objbind_get_value_from_object(), objbind_pack_current_values(), real_conn_list_dialog_update(), sg_save_player_main(), and fc_client::update_start_page().

## ◆ player_has_real_embassy()

bool player_has_real_embassy | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Returns whether pplayer has a real embassy with pplayer2, established from a diplomat, or through diplomatic meeting.

Definition at line 234 of file player.c.

Referenced by add_clause(), create_clause_menu(), handle_diplomacy_accept_treaty_req(), is_diplrel_between(), package_player_info(), player_has_embassy(), popup_add_menu(), popup_diplomatic_objects(), sg_save_player_main(), diplo_wdg::show_menu(), and team_has_embassy().

## ◆ player_in_city_map()

bool player_in_city_map | ( | const struct player * | pplayer,
|  | const struct tile * | ptile
| ) |  |

Return true iff tile is inside any of the player's city map.

Definition at line 1225 of file player.c.

Referenced by fill_grid_sprite_array().

## ◆ player_in_territory()

int player_in_territory | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Return the number of pplayer2's visible units in pplayer's territory, from the point of view of pplayer. Units that cannot be seen by pplayer will not be found (this function doesn't cheat).

Definition at line 1842 of file player.c.

Referenced by dai_diplomacy_begin_new_phase().

## ◆ player_index()

int player_index | ( | const struct player * | pplayer | ) |

Return the player index.

Currently same as player_number(), but indicates use as an array index. The array must be sized by player_slot_count() or MAX_NUM_PLAYER_SLOTS (player_count() cannot be used) and is likely to be sparse.

Definition at line 820 of file player.c.

Referenced by achievement_check(), achievement_player_has(), achievement_plr(), adv_dipl_free(), adv_dipl_get(), adv_dipl_new(), adv_is_player_dangerous(), build_landarea_map(), cmp_love(), col_love(), create_vision_dependencies(), dai_diplomacy_actions(), dai_diplomacy_begin_new_phase(), dai_diplomacy_defaults(), dai_diplomacy_destroy(), dai_diplomacy_first_contact(), dai_diplomacy_get(), dai_diplomacy_new(), dai_go_to_war(), dai_goldequiv_clause(), dai_hunter_manage(), dai_incident_nuclear(), dai_incident_nuclear_not_target(), dai_incident_nuclear_self(), dai_incident_simple(), dai_incident_war(), dai_manage_taxes(), dai_player_load_relations(), dai_player_save_relations(), dai_players_can_agree_on_ceasefire(), dai_treaty_accepted(), dai_unit_new_task(), dai_war_desire(), destroy_extra(), establish_embassy(), event_cache_add_for_player(), event_cache_match(), event_cache_player_add(), event_cache_save(), fill_grid_sprite_array(), fill_sprite_array(), found_new_tech(), get_player_landarea(), give_shared_vision(), gives_shared_vision(), handle_achievement_info(), handle_edit_city(), img_createmap(), img_playerstr(), img_save_ppm(), init_new_game(), kill_unit(), log_civ_score_now(), map_claim_base(), mapimg_checkplayers(), mapimg_client_define(), mapimg_create(), objbind_get_value_from_object(), package_player_diplstate(), package_player_info(), player_diplstate_destroy(), player_diplstate_get(), player_diplstate_new(), player_has_real_embassy(), popup_airlift_dialog(), popup_goto_airlift_dialog(), popup_goto_dialog(), rank_users(), real_diplo_log(), really_gives_vision(), remove_shared_vision(), send_unit_info(), server_remove_player(), sg_load_map_known(), sg_load_map_known(), sg_load_player_main(), sg_load_player_main(), sg_load_players(), sg_load_players(), sg_save_map_known(), sg_save_player_cities(), sg_save_player_main(), srv_ready(), tileset_player_init(), toggle_goto_nations_cities_dialog_callback(), transfer_city(), unit_goes_out_of_sight(), unit_move(), unit_transport_load_send(), and update_goto_dialog().

## ◆ player_knows_techs_with_flag()

bool player_knows_techs_with_flag | ( | const struct player * | pplayer,
|  | enum tech_flag_id | flag
| ) |  |

Returns TRUE iff the player knows at least one tech which has the given flag.

Definition at line 1304 of file player.c.

Referenced by can_build_extra_base(), dai_choose_attacker_air(), and is_techflag_req_active().

## ◆ player_multiplier_effect_value()

int player_multiplier_effect_value | ( | const struct player * | pplayer,
|  | const struct multiplier * | pmul
| ) |  |

Return the multiplier value currently in effect for pplayer, scaled from display units to the units used in the effect system (if different). Result is multiplied by 100 (caller should divide down).

Definition at line 1933 of file player.c.

Referenced by dai_effect_value(), get_city_dialog_culture_text(), get_city_dialog_illness_text(), get_city_dialog_output_text(), get_potential_improvement_bonus(), and get_target_bonus_effects().

## ◆ player_multiplier_target_value()

int player_multiplier_target_value | ( | const struct player * | pplayer,
|  | const struct multiplier * | pmul
| ) |  |

Return the player's target value for a multiplier (which may be different from the value currently in force; it will take effect next turn). Result is in display units.

Definition at line 1945 of file player.c.

Referenced by multipler_rates_dialog::multipler_rates_dialog(), and multiplier_dialog_update_values().

## ◆ player_multiplier_value()

int player_multiplier_value | ( | const struct player * | pplayer,
|  | const struct multiplier * | pmul
| ) |  |

Return the multiplier value currently in effect for pplayer (in display units).

Definition at line 1922 of file player.c.

Referenced by dai_adjust_policies(), multiplier_dialog_update_values(), and player_multiplier_effect_value().

## ◆ player_name()

const char * player_name | ( | const struct player * | pplayer | ) |

Return the leader name of the player.

Definition at line 886 of file player.c.

Referenced by adv_data_get(), agents_unit_changed(), agents_unit_new(), agents_unit_remove(), aicmd_command(), aifill(), announce_player(), away_command(), begin_phase(), can_unit_move_to_tile_with_notify(), chat_msg_to_player(), check_city_migrations_player(), check_for_game_over(), citizens_convert(), citizens_convert_conquest(), citizens_print(), city_add_unit(), city_build_unit(), city_from_great_wonder(), city_from_wonder(), city_name_suggestion(), civil_war(), civil_war_triggered(), client_take_player(), cmp_name(), col_name(), conn_description(), conn_menu_player_command(), conn_menu_player_command(), conn_menu_team_chosen(), conn_menu_team_chosen(), connection_detach(), create_barbarian_player(), create_command_newcomer(), create_command_pregame(), create_conn_menu(), create_races_dialog(), create_spaceship_dialog(), dai_auto_settler_reset(), dai_choose_diplomat_offensive(), dai_choose_paratrooper(), dai_diplomacy_actions(), dai_diplomacy_begin_new_phase(), dai_diplomacy_first_contact(), dai_diplomacy_suggest(), dai_do_build_city(), dai_go_to_war(), dai_goldequiv_clause(), dai_incident_war(), dai_manage_taxes(), dai_manage_tech(), dai_plr_data_get(), dai_spend_gold(), dai_treaty_evaluate(), dai_treaty_react(), debug_command(), default_title_for_player(), delegate_command(), delegate_player_str(), detach_command(), diplomat_bribe(), do_spaceship_place(), do_tech_parasite_effect(), do_unit_change_homecity(), end_turn(), endgame_report_dialog_player(), establish_new_connection(), explain_why_no_action_enabled(), extviewer_refresh_widgets(), fit_nationset_to_players(), form_chat_name(), generate_players(), get_info_label_text(), get_player_landarea(), give_shared_vision(), government_change(), handle_chat_msg_req(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact(), handle_edit_player(), handle_event(), handle_nation_select_req(), handle_player_change_government(), handle_player_multiplier(), handle_player_rates(), handle_tile_info(), handle_unit_orders(), illegal_action_msg(), img_playerstr(), init_new_game(), log_civ_score_now(), make_contact(), map_change_seen(), map_hide_tile(), map_show_tile(), observe_button_callback(), observe_command(), package_player_common(), place_starting_unit(), player_balance_treasury_units(), player_balance_treasury_units_and_buildings(), player_name_by_number(), player_nation_defaults(), player_tech_upkeep(), playercolor_command(), playernation_command(), players_ai_skill_callback(), players_ai_skill_callback(), players_ai_toggle_callback(), players_ai_toggle_callback(), rank_users(), real_conn_list_dialog_update(), real_diplo_log(), real_tech_log(), really_diplomacy_cancel_meeting(), refresh_player_pov_indicator(), refresh_tool_applied_player_combo(), remove_player_command(), remove_shared_vision(), research_name_translation(), research_rule_name(), ruler_title_for_player(), sell_random_building(), sell_random_unit(), send_delegation_info(), server_player_name_is_allowed(), server_remove_player(), server_remove_unit_full(), set_ai_level(), set_ai_level_direct(), sg_load_map_owner(), sg_load_map_owner(), sg_load_players(), sg_load_players(), sg_load_players_basic(), sg_load_players_basic(), sg_load_sanitycheck(), sg_load_sanitycheck(), sg_save_player_main(), sg_save_treaties(), show_colors(), show_conn_popup(), show_delegations(), show_players(), show_teams(), shuffled_player(), spy_poison(), fc_client::start_page_menu(), surrender_command(), take_command(), team_command(), team_remove_player(), plr_report::toggle_ai_mode(), toggle_ai_player_direct(), try_summon_barbarians(), unit_conquer_city(), unit_do_destroy_city(), update_diplomatics(), update_dumb_city(), update_intel_dialog(), endgame_report::update_report(), update_revolution(), fc_client::update_start_page(), update_start_page_buttons(), and war_countdown().

## ◆ player_name_by_number()

static const char * player_name_by_number | ( | int | i | ) |

static

Find player by name, allowing unambigous prefix (ie abbreviation). Returns NULL if could not match, or if ambiguous or other problem, and fills *result with characterisation of match/non-match (see shared.[ch])

Definition at line 900 of file player.c.

Referenced by player_by_name_prefix().

## ◆ player_new()

struct player * player_new | ( | struct player_slot * | pslot | ) |

Creates a new player for the slot. If slot is NULL, it will lookup to a free slot. If the slot is already used, then just return the player.

Definition at line 486 of file player.c.

Referenced by handle_player_info(), and server_create_player().

## ◆ player_number()

int player_number | ( | const struct player * | pplayer | ) |

Return the player index/number/id.

Definition at line 828 of file player.c.

Referenced by api_methods_player_number(), begin_phase(), call_meeting_dlg_callback(), cancel_pact_dlg_callback(), check_leaving_edit_mode(), cities_callback(), city_from_great_wonder(), city_from_wonder(), city_original_owner(), clear_old_treaty(), client_player_number(), client_take_player(), cmp_love(), conn_menu_ready_chosen(), conn_menu_ready_chosen(), create_barbarian_player(), create_clause_menu(), dai_diplomacy_actions(), dai_diplomacy_suggest(), dai_go_to_war(), dai_treaty_evaluate(), diplo_wdg::dbl_click(), diplo_dialog_returnkey(), diplomacy_dialog_add_pact_clause(), diplomacy_dialog_add_pact_clause(), diplomacy_dialog_embassy_callback(), diplomacy_dialog_embassy_callback(), diplomacy_dialog_map_callback(), diplomacy_dialog_map_callback(), diplomacy_dialog_seamap_callback(), diplomacy_dialog_seamap_callback(), diplomacy_dialog_vision_callback(), diplomacy_dialog_vision_callback(), diplomacy_main_response(), diplomacy_response(), editor_grab_applied_player(), embassy_callback(), end_phase(), fill_row(), fill_tile_edit_packet(), diplo_wdg::give_embassy(), diplo_wdg::give_shared_vision(), gold_callback(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact(), handle_diplomacy_create_clause(), handle_diplomacy_create_clause_req(), handle_diplomacy_init_meeting_req(), handle_diplomacy_remove_clause(), handle_diplomacy_remove_clause_req(), handle_edit_player(), handle_edit_player_create(), handle_edit_toggle_fogofwar(), handle_endgame_player(), handle_player_info(), handle_player_remove(), handle_research_info(), handle_unknown_research(), img_playerstr(), initialize_globals(), is_player_phase(), log_civ_score_now(), map_change_seen(), maps_callback(), model_get_player_iter(), objbind_pack_current_values(), object_put(), objtype_get_id_from_object(), races_dialog::ok_pressed(), package_city(), package_conn_info(), package_dumb_city(), package_player_common(), package_short_unit(), package_unit(), diplo_wdg::pact_allianze(), pact_callback(), diplo_wdg::pact_ceasfire(), diplo_wdg::pact_peace(), paste_tile(), player_balance_treasury_units(), player_balance_treasury_units_and_buildings(), player_index(), player_preferred_color(), player_tech_upkeep(), popup_add_menu(), popup_diplomatic_objects(), popup_goto_airlift_dialog(), races_dialog_ok_callback(), races_response(), races_dialog::random_pressed(), ready_button_callback(), real_conn_list_dialog_update(), real_players_dialog_update(), really_diplomacy_cancel_meeting(), refresh_player_pov_indicator(), refresh_tool_applied_player_combo(), reject_all_treaties(), remove_clause_callback(), report_final_scores(), plr_report::req_caancel_threaty(), plr_report::req_meeeting(), plr_report::req_wiithdrw_vision(), research_get(), diplo_wdg::response_accept(), diplo_wdg::response_cancel(), row_callback(), diplo_wdg::sea_map_clause(), send_diplomatic_meetings(), send_spaceship_info(), send_tile_info(), server_player_set_name_full(), sg_load_player_attributes(), sg_load_player_attributes(), sg_load_player_cities(), sg_load_player_cities(), sg_load_player_city(), sg_load_player_city(), sg_load_player_main(), sg_load_player_main(), sg_load_player_unit(), sg_load_player_unit(), sg_load_player_units(), sg_load_player_units(), sg_load_player_units_transport(), sg_load_player_units_transport(), sg_load_player_vision(), sg_load_player_vision(), sg_load_players_basic(), sg_load_players_basic(), sg_save_map_owner(), sg_save_player_attributes(), sg_save_player_cities(), sg_save_player_main(), sg_save_player_units(), sg_save_player_vision(), sg_save_players(), fc_client::slot_pregame_start(), srv_ready(), start_command(), team_add_player(), team_remove_player(), techs_callback(), texai_city_update(), texai_unit_update(), update_clauses_list(), update_diplomacy_dialog(), update_diplomatics(), vision_callback(), withdraw_vision_dlg_callback(), wonder_built(), wonder_destroyed(), and diplo_wdg::world_map_clause().

## ◆ player_owns_city()

bool player_owns_city | ( | const struct player * | pplayer,
|  | const struct city * | pcity
| ) |  |

Return TRUE iff the given player owns the city.

Definition at line 255 of file player.c.

Referenced by calc_civ_score(), popup_find_dialog(), really_handle_city_buy(), and update_goto_dialog().

## ◆ player_primary_capital()

struct city * player_primary_capital | ( | const struct player * | pplayer | ) |

Locate the player's primary capital city, (NULL Otherwise)

Definition at line 1313 of file player.c.

Referenced by center_next_player_capital(), center_on_something(), do_expel_unit(), handle_spaceship_launch(), unit_hud_selector::island_filter(), key_center_capital(), plr_widget::nation_selected(), unit_do_destroy_city(), update_intel_dialog(), and fc_client::update_sidebar_tooltips().

## ◆ player_ruleset_close()

void player_ruleset_close | ( | struct player * | pplayer | ) |

Clear the ruleset dependent pointers of the player structure. Called by game_ruleset_free().

Definition at line 736 of file player.c.

Referenced by game_ruleset_free().

## ◆ player_set_ai_data()

void player_set_ai_data | ( | struct player * | pplayer,
|  | const struct ai_type * | ai,
|  | void * | data
| ) |  |

Attach ai data to player

Definition at line 1912 of file player.c.

Referenced by dai_player_alloc(), dai_player_free(), tai_player_alloc(), tai_player_free(), texai_player_alloc(), and texai_player_free().

## ◆ player_set_color()

void player_set_color | ( | struct player * | pplayer,
|  | const struct rgbcolor * | prgbcolor
| ) |  |

Set the player's color. May be NULL in pregame.

Definition at line 639 of file player.c.

Referenced by assign_player_colors(), handle_player_info(), server_create_player(), and server_player_set_color().

## ◆ player_set_nation()

bool player_set_nation | ( | struct player * | pplayer,
|  | struct nation_type * | pnation
| ) |  |

Set the player's nation to the given nation (may be NULL). Returns TRUE iff there was a change. Doesn't check if the nation is legal wrt nationset.

Definition at line 852 of file player.c.

Referenced by aifill(), create_animals(), fit_nationset_to_players(), handle_edit_player(), handle_nation_select_req(), handle_player_info(), nationset_action(), player_clear(), player_nation_defaults(), player_ruleset_close(), playernation_command(), sg_load_player_main(), sg_load_player_main(), sg_load_players(), and sg_load_players().

## ◆ player_slot_by_number()

struct player_slot * player_slot_by_number | ( | int | player_id | ) |

Return the possibly unused and uninitialized player slot.

Definition at line 456 of file player.c.

Referenced by handle_city_nationalities(), handle_conn_info(), handle_player_info(), handle_player_remove(), player_by_number(), server_create_player(), sg_load_map_known(), sg_load_map_known(), and sg_save_map_known().

## ◆ player_slot_count()

int player_slot_count | ( | void |  | ) |

Returns the total number of player slots, i.e. the maximum number of players (including barbarians, etc.) that could ever exist at once.

Definition at line 411 of file player.c.

Referenced by adv_data_init(), aifill(), check_leaving_edit_mode(), check_player_or_user_name(), compat_load_020600(), create_command_newcomer(), dai_data_init(), dai_diplomacy_begin_new_phase(), edithand_init(), found_new_tech(), give_shared_vision(), handle_edit_player_create(), init_new_game(), is_allowed_to_take(), kill_unit(), log_civ_score_init(), object_put(), package_conn_info(), package_player_common(), player_by_name_prefix(), player_new(), player_slot_by_number(), player_slot_next(), player_slots_init(), rank_users(), remove_shared_vision(), researches_init(), scan_score_log(), server_player_set_name_full(), set_shuffled_players(), sg_load_players_basic(), sg_load_players_basic(), shuffle_players(), start_command(), and take_command().

## ◆ player_slot_first()

struct player_slot * player_slot_first | ( | void |  | ) |

Returns the first player slot.

Definition at line 392 of file player.c.

## ◆ player_slot_get_player()

struct player * player_slot_get_player | ( | const struct player_slot * | pslot | ) |

Returns the team corresponding to the slot. If the slot is not used, it will return NULL. See also player_slot_is_used().

Definition at line 430 of file player.c.

Referenced by achievement_check(), citizen_happiness_nationality(), citizens_convert(), citizens_convert_conquest(), citizens_count(), citizens_dialog_row(), citizens_print(), citizens_unit_nationality(), citizens_update(), col_nation(), do_city_migration(), extviewer_refresh_widgets(), handle_conn_info(), handle_player_remove(), is_nationality_req_active(), log_civ_score_now(), package_city(), player_by_number(), text_happiness_nationality(), and city_dialog::update_nation_table().

## ◆ player_slot_index()

int player_slot_index | ( | const struct player_slot * | pslot | ) |

Returns the index of the player slot.

Definition at line 419 of file player.c.

Referenced by adv_data_init(), citizens_dialog_row(), citizens_nation_get(), citizens_nation_set(), compat_load_020400(), compat_load_020600(), compat_load_030000(), compat_load_030100(), dai_data_init(), extviewer_refresh_widgets(), insert_server_side_agent(), log_civ_score_free(), log_civ_score_init(), log_civ_score_now(), package_city(), player_defaults(), player_new(), player_number(), player_slot_max_used_number(), send_player_remove_info_c(), sg_load_player_city_citizens(), sg_load_player_city_citizens(), sg_load_players_basic(), sg_load_players_basic(), sg_save_player_cities(), and tileset_init().

## ◆ player_slot_is_used()

bool player_slot_is_used | ( | const struct player_slot * | pslot | ) |

Returns TRUE is this slot is "used" i.e. corresponds to a valid, initialized player that exists in the game.

Definition at line 441 of file player.c.

Referenced by extviewer_refresh_widgets(), handle_player_info(), handle_player_remove(), log_civ_score_now(), player_new(), player_slot_max_used_number(), send_player_remove_info_c(), server_create_player(), sg_load_map_known(), sg_load_map_known(), sg_load_player_city_citizens(), sg_load_player_city_citizens(), and sg_save_map_known().

## ◆ player_slot_max_used_number()

int player_slot_max_used_number | ( | void |  | ) |

Return the highest used player slot index.

Definition at line 469 of file player.c.

Referenced by sg_load_map_known(), sg_load_map_known(), and sg_save_map_known().

## ◆ player_slot_next()

struct player_slot * player_slot_next | ( | struct player_slot * | pslot | ) |

Returns the next slot.

Definition at line 400 of file player.c.

## ◆ player_slots_free()

void player_slots_free | ( | void |  | ) |

Remove all player slots.

Definition at line 379 of file player.c.

Referenced by game_free().

## ◆ player_slots_init()

void player_slots_init | ( | void |  | ) |

Initialise all player slots (= pointer to player pointers).

Definition at line 353 of file player.c.

Referenced by game_init().

## ◆ player_slots_initialised()

bool player_slots_initialised | ( | void |  | ) |

Return whether player slots are already initialized.

Definition at line 371 of file player.c.

Referenced by player_new(), player_slot_by_number(), player_slot_is_used(), and research_iter_player_next().

## ◆ player_unit_by_number()

struct unit * player_unit_by_number | ( | const struct player * | pplayer,
|  | int | unit_id
| ) |  |

If the specified player owns the unit with the specified id, return pointer to the unit struct. Else return NULL. Uses fast idex_lookup_city.

pplayer may be NULL in which case all units registered to hash are considered - even those not currently owned by any player. Callers expect this behavior.

Definition at line 1205 of file player.c.

Referenced by api_find_unit(), auto_settler_setup_work(), diplomat_bribe(), unit_item::disband(), do_capture_units(), do_disband_alternative(), execute_orders(), find_something_to_kill(), goto_map_unit(), handle_city_name_suggestion_info(), handle_city_name_suggestion_req(), handle_city_sabotage_list(), handle_unit_action_answer(), handle_unit_action_query(), handle_unit_change_activity(), handle_unit_change_activity_real(), handle_unit_orders(), handle_unit_packet_common(), handle_unit_server_side_agent_set(), handle_unit_sscs_set(), middle_present_unit_release(), middle_supported_unit_release(), present_unit_activate_close_callback(), present_unit_activate_close_callback(), present_unit_callback(), present_unit_callback(), present_unit_middle_callback(), right_unit_release(), settler_evaluate_city_requests(), settler_evaluate_improvements(), sg_load_player_units_transport(), sg_load_player_units_transport(), supported_unit_activate_close_callback(), supported_unit_activate_close_callback(), supported_unit_callback(), supported_unit_callback(), supported_unit_middle_callback(), unit_activate_callback(), unit_activate_callback(), unit_center_callback(), unit_center_callback(), unit_disband_callback(), unit_disband_callback(), unit_fortify_callback(), unit_fortify_callback(), unit_homecity_callback(), unit_homecity_callback(), unit_load_callback(), unit_load_callback(), unit_perform_action(), unit_select_callback(), unit_sentry_callback(), unit_sentry_callback(), unit_unload_callback(), unit_unload_callback(), unit_upgrade_callback(), unit_upgrade_callback(), units_orders_city_dlg_callback(), usdlg_cmd_center(), usdlg_cmd_cursor_changed(), and usdlg_cmd_focus_real().

## ◆ players_non_invade()

bool players_non_invade | ( | const struct player * | pplayer1,
|  | const struct player * | pplayer2
| ) |  |

Returns TRUE if players can't enter each others' territory.

Definition at line 1418 of file player.c.

Referenced by player_can_invade_tile().

## ◆ players_on_same_team()

bool players_on_same_team | ( | const struct player * | pplayer1,
|  | const struct player * | pplayer2
| ) |  |

Return TRUE if players are in the same team

Definition at line 1452 of file player.c.

Referenced by compute_tech_sell_price(), conn_can_see_vote(), conn_can_vote(), dai_diplomacy_actions(), dai_diplomacy_begin_new_phase(), dai_effect_value(), dai_share(), diplomacy_possible(), handle_diplomacy_cancel_pact(), notify_team(), package_player_info(), players_in_same_range(), pplayer_can_cancel_treaty(), pplayer_can_make_treaty(), sg_load_players(), sg_load_players(), srv_ready(), update_diplomatics(), update_players_menu(), and plr_report::update_report().

## ◆ pplayer_can_cancel_treaty()

enum dipl_reason pplayer_can_cancel_treaty | ( | const struct player * | p1,
|  | const struct player * | p2
| ) |  |

The senate may not allow you to break the treaty. In this case you must first dissolve the senate then you can break it. This is waived if you have statue of liberty since you could easily just dissolve and then recreate it.

Definition at line 92 of file player.c.

Referenced by dai_go_to_war(), handle_diplomacy_cancel_pact(), popup_diplomacy_dialog(), update_players_menu(), and plr_report::update_report().

## ◆ pplayer_can_make_treaty()

enum dipl_reason pplayer_can_make_treaty | ( | const struct player * | p1,
|  | const struct player * | p2,
|  | enum diplstate_type | treaty
| ) |  |

Returns the reason p1 can't make given treaty with p2, or DIPL_OK if they can.

We cannot regress in a treaty chain. So we cannot suggest 'Peace' if we are in 'Alliance'. Then you have to cancel.

For alliance there is only one condition: We are not at war with any of p2's allies.

Definition at line 153 of file player.c.

Referenced by handle_diplomacy_accept_treaty_req(), popup_diplomatic_objects(), sg_load_players(), and sg_load_players().

## ◆ pplayers_allied()

bool pplayers_allied | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Returns true iff players are allied.

Definition at line 1381 of file player.c.

Referenced by action_hard_reqs_actor(), adv_danger_at(), adv_data_phase_init(), api_edit_create_unit_full(), api_edit_unit_teleport(), api_edit_unit_teleport_old(), api_methods_enemy_tile(), autosettler_tile_behavior(), calculate_want_for_paratrooper(), can_create_unit_at_tile(), can_player_see_unit_at(), can_player_see_units_in_city(), chat_msg_to_allies(), check_for_game_over(), compute_tech_sell_price(), could_unit_load(), create_extra(), dai_action_value_unit_vs_city(), dai_caravan_can_trade_cities_diff_cont(), dai_choose_diplomat_offensive(), dai_choose_trade_route(), dai_consider_tile_dangerous(), dai_data_phase_begin(), dai_diplomacy_actions(), dai_diplomacy_begin_new_phase(), dai_incident_war(), dai_manage_caravan(), dai_manage_diplomat(), dai_war_desire(), destroy_extra(), diplomat_bribe(), do_attack(), do_paradrop(), does_foreign_trade_param_allow(), find_best_tile_to_paradrop_to(), find_city_to_diplomat(), find_nearest_safe_city(), get_allied_with_enemy_player(), get_attacker(), get_default_diplstate(), handle_diplomacy_cancel_pact(), handle_edit_unit_create(), is_action_possible(), is_friendly_city_near(), is_plr_zoc_client(), is_plr_zoc_srv(), is_valid_alliance(), map_change_seen(), maybe_cancel_patrol_due_to_enemy(), non_allied_not_listed_at(), overview_tile_color(), pf_get_move_scope(), pf_transport_check(), player_can_trust_tile_has_no_units(), player_may_explore(), players_in_same_range(), redraw_unit_info_label(), reinforcements_cost_and_value(), score_tooltip(), sg_load_players(), sg_load_players(), test_unit_can_airlift_to(), throw_units_from_illegal_cities(), tile_allied_city(), tile_allied_unit(), tile_has_units_not_allied_to_but_seen_by(), tile_non_allied_city(), tile_non_allied_unit(), transfer_city_units(), unit_being_aggressive(), unit_move_to_tile_test(), unit_teleport_to_tile_test(), update_diplomatics(), wakeup_neighbor_sentries(), and war_countdown().

## ◆ pplayers_at_war()

bool pplayers_at_war | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Returns true iff players can attack each other.

Definition at line 1364 of file player.c.

Referenced by action_prob_vs_units_full(), adv_danger_at(), aiguard_check_guard(), api_edit_unit_move_old(), api_edit_unit_teleport_old(), can_player_attack_tile(), citizen_happiness_nationality(), dai_action_value_unit_vs_city(), dai_consider_tile_dangerous(), dai_diplomacy_actions(), dai_rampage_want(), do_paradrop(), does_foreign_trade_param_allow(), find_best_tile_to_paradrop_to(), find_closest_city(), find_something_to_kill(), is_square_threatened(), kill_unit(), pf_attack_possible(), restrict_infra(), sg_load_player_units(), text_happiness_nationality(), tile_enemy_city(), tile_enemy_unit(), unit_conquer_city(), unit_move(), and unit_occupies_tile().

## ◆ pplayers_in_peace()

bool pplayers_in_peace | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Returns true iff players are allied or at peace.

Definition at line 1402 of file player.c.

Referenced by dai_goldequiv_clause(), does_foreign_trade_param_allow(), and settler_map_iterate().

## ◆ pplayers_non_attack()

bool pplayers_non_attack | ( | const struct player * | pplayer,
|  | const struct player * | pplayer2
| ) |  |

Returns true iff players have peace, cease-fire, or armistice.

Definition at line 1435 of file player.c.

Referenced by dai_diplomacy_begin_new_phase(), dai_goldequiv_clause(), do_attack(), do_paradrop(), popup_advanced_terrain_dialog(), tile_non_attack_city(), tile_non_attack_unit(), unit_move_to_tile_test(), and unit_teleport_to_tile_test().

## ◆ team_has_embassy()

bool team_has_embassy | ( | const struct team * | pteam,
|  | const struct player * | tgt_player
| ) |  |

Check if team has an embassy with tgt_player. Team always has an embassy with its members.

Definition at line 214 of file player.c.

Referenced by can_plr_see_all_sym_diplrels_of(), can_see_techs_of_target(), col_government(), could_intel_with_player(), create_clause_menu(), dem_line_item(), get_culture_info(), get_gold_info(), get_luxury_info(), get_researching_info(), get_science_info(), get_tax_info(), have_diplomat_info_about(), make_contact(), plr_widget::nation_selected(), notify_embassies(), notify_research_embassies(), player_info_level(), popup_add_menu(), send_research_info(), and update_intel_dialog().

## Variable Documentation

## ◆ diplrel_mess

bv_diplrel_all_reqs* diplrel_mess = NULL

static

Definition at line 1754 of file player.c.

Referenced by diplrel_mess_close(), and diplrel_mess_get().

## ◆ [struct]

struct { ... } player_slots

Referenced by player_count(), player_destroy(), player_new(), player_slot_by_number(), player_slot_first(), player_slot_index(), player_slot_next(), player_slots_free(), player_slots_init(), and player_slots_initialised().

## ◆ slots

struct player_slot* slots

Definition at line 50 of file player.c.

Referenced by is_action_possible(), kill_unit(), sg_load_players_basic(), and sg_load_players_basic().

## ◆ used_slots

int used_slots

Definition at line 51 of file player.c.