Freeciv21
Develop your civilization from humble roots to a global empire
player.h File Reference
#include "city.h"
#include "effects.h"
#include "spaceship.h"
#include "tech.h"
#include "traits.h"
#include "specenum_gen.h"
#include "speclist.h"
+ Include dependency graph for player.h:

Go to the source code of this file.

Classes

struct  player_economic
 
struct  player_score
 
struct  player_ai
 
struct  player_diplstate
 
struct  attribute_block_s
 
struct  player
 

Macros

#define PLAYER_DEFAULT_TAX_RATE   0
 
#define PLAYER_DEFAULT_SCIENCE_RATE   100
 
#define PLAYER_DEFAULT_LUXURY_RATE   0
 
#define ANON_PLAYER_NAME   "noname"
 
#define ANON_USER_NAME   N_("Unassigned")
 
#define SPECENUM_NAME   plr_flag_id
 
#define SPECENUM_VALUE0   PLRF_AI
 
#define SPECENUM_VALUE0NAME   "ai"
 
#define SPECENUM_VALUE1   PLRF_SCENARIO_RESERVED
 
#define SPECENUM_VALUE1NAME   "ScenarioReserved"
 
#define SPECENUM_COUNT   PLRF_COUNT
 
#define SPECENUM_BITVECTOR   bv_plr_flags
 
#define SPECENUM_NAME   player_status
 
#define SPECENUM_VALUE0   PSTATUS_NORMAL
 
#define SPECENUM_VALUE1   PSTATUS_DYING
 
#define SPECENUM_VALUE2   PSTATUS_WINNER
 
#define SPECENUM_VALUE3   PSTATUS_SURRENDER
 
#define SPECENUM_COUNT   PSTATUS_COUNT
 
#define SPECENUM_NAME   diplstate_type
 
#define SPECENUM_VALUE0   DS_ARMISTICE
 
#define SPECENUM_VALUE0NAME   N_("?diplomatic_state:Armistice")
 
#define SPECENUM_VALUE1   DS_WAR
 
#define SPECENUM_VALUE1NAME   N_("?diplomatic_state:War")
 
#define SPECENUM_VALUE2   DS_CEASEFIRE
 
#define SPECENUM_VALUE2NAME   N_("?diplomatic_state:Cease-fire")
 
#define SPECENUM_VALUE3   DS_PEACE
 
#define SPECENUM_VALUE3NAME   N_("?diplomatic_state:Peace")
 
#define SPECENUM_VALUE4   DS_ALLIANCE
 
#define SPECENUM_VALUE4NAME   N_("?diplomatic_state:Alliance")
 
#define SPECENUM_VALUE5   DS_NO_CONTACT
 
#define SPECENUM_VALUE5NAME   N_("?diplomatic_state:Never met")
 
#define SPECENUM_VALUE6   DS_TEAM
 
#define SPECENUM_VALUE6NAME   N_("?diplomatic_state:Team")
 
#define SPECENUM_COUNT   DS_LAST
 
#define SPECENUM_NAME   diplrel_other
 
#define SPECENUM_VALUE7   DRO_GIVES_SHARED_VISION
 
#define SPECENUM_VALUE7NAME   N_("Gives shared vision")
 
#define SPECENUM_VALUE8   DRO_RECEIVES_SHARED_VISION
 
#define SPECENUM_VALUE8NAME   N_("Receives shared vision")
 
#define SPECENUM_VALUE9   DRO_HOSTS_EMBASSY
 
#define SPECENUM_VALUE9NAME   N_("Hosts embassy")
 
#define SPECENUM_VALUE10   DRO_HAS_EMBASSY
 
#define SPECENUM_VALUE10NAME   N_("Has embassy")
 
#define SPECENUM_VALUE11   DRO_HOSTS_REAL_EMBASSY
 
#define SPECENUM_VALUE11NAME   N_("Hosts real embassy")
 
#define SPECENUM_VALUE12   DRO_HAS_REAL_EMBASSY
 
#define SPECENUM_VALUE12NAME   N_("Has real embassy")
 
#define SPECENUM_VALUE13   DRO_HAS_CASUS_BELLI
 
#define SPECENUM_VALUE13NAME   N_("Has Casus Belli")
 
#define SPECENUM_VALUE14   DRO_PROVIDED_CASUS_BELLI
 
#define SPECENUM_VALUE14NAME   N_("Provided Casus Belli")
 
#define SPECENUM_VALUE15   DRO_FOREIGN
 
#define SPECENUM_VALUE15NAME   N_("Foreign")
 
#define SPECENUM_VALUE16   DRO_HAS_CONTACT
 
#define SPECENUM_VALUE16NAME   N_("Has Contact")
 
#define SPECENUM_COUNT   DRO_LAST
 
#define MAX_ATTRIBUTE_BLOCK   (256 * 1024)
 
#define is_human(plr)   !player_has_flag((plr), PLRF_AI)
 
#define is_ai(plr)   player_has_flag((plr), PLRF_AI)
 
#define set_as_human(plr)   BV_CLR((plr)->flags, PLRF_AI)
 
#define set_as_ai(plr)   BV_SET((plr)->flags, PLRF_AI)
 
#define player_slots_iterate(_pslot)
 
#define player_slots_iterate_end
 
#define players_iterate(_pplayer)
 
#define players_iterate_end
 
#define players_iterate_alive(_pplayer)
 
#define players_iterate_alive_end
 
#define SPECLIST_TAG   player
 
#define SPECLIST_TYPE   struct player
 
#define player_list_iterate(playerlist, pplayer)    TYPED_LIST_ITERATE(struct player, playerlist, pplayer)
 
#define player_list_iterate_end   LIST_ITERATE_END
 
#define MAX_AI_LOVE   1000
 
#define ai_level_cmd(_level_)   ai_level_name(_level_)
 

Enumerations

enum  plrcolor_mode {
  PLRCOL_PLR_ORDER , PLRCOL_PLR_RANDOM , PLRCOL_PLR_SET , PLRCOL_TEAM_ORDER ,
  PLRCOL_NATION_ORDER
}
 
enum  dipl_reason {
  DIPL_OK , DIPL_ERROR , DIPL_SENATE_BLOCKING , DIPL_ALLIANCE_PROBLEM_US ,
  DIPL_ALLIANCE_PROBLEM_THEM
}
 
enum  player_debug_types { PLAYER_DEBUG_DIPLOMACY , PLAYER_DEBUG_TECH , PLAYER_DEBUG_LAST }
 

Functions

 BV_DEFINE (bv_pstatus, PSTATUS_COUNT)
 
 BV_DEFINE (bv_diplrel_all_reqs,((DRO_LAST - 1) *2) *REQ_RANGE_COUNT+2)
 
 BV_DEFINE (bv_debug, PLAYER_DEBUG_LAST)
 
bool player_has_flag (const struct player *pplayer, enum plr_flag_id flag)
 Check if player has given flag. More...
 
void player_slots_init ()
 Initialise all player slots (= pointer to player pointers). More...
 
bool player_slots_initialised ()
 Return whether player slots are already initialized. More...
 
void player_slots_free ()
 Remove all player slots. More...
 
struct player_slotplayer_slot_first ()
 Returns the first player slot. More...
 
struct player_slotplayer_slot_next (struct player_slot *pslot)
 Returns the next slot. More...
 
int player_slot_index (const struct player_slot *pslot)
 Returns the index of the player slot. More...
 
struct playerplayer_slot_get_player (const struct player_slot *pslot)
 Returns the team corresponding to the slot. More...
 
bool player_slot_is_used (const struct player_slot *pslot)
 Returns TRUE is this slot is "used" i.e. More...
 
struct player_slotplayer_slot_by_number (int player_id)
 Return the possibly unused and uninitialized player slot. More...
 
int player_slot_max_used_number ()
 Return the highest used player slot index. More...
 
struct playerplayer_new (struct player_slot *pslot)
 Creates a new player for the slot. More...
 
void player_set_color (struct player *pplayer, const struct rgbcolor *prgbcolor)
 Set the player's color. More...
 
void player_clear (struct player *pplayer, bool full)
 Clear all player data. More...
 
void player_ruleset_close (struct player *pplayer)
 Clear the ruleset dependent pointers of the player structure. More...
 
void player_destroy (struct player *pplayer)
 Destroys and remove a player from the game. More...
 
int player_count ()
 Return the number of players. More...
 
int player_index (const struct player *pplayer)
 Return the player index. More...
 
int player_number (const struct player *pplayer)
 Return the player index/number/id. More...
 
struct playerplayer_by_number (const int player_id)
 Return struct player pointer for the given player index. More...
 
const char * player_name (const struct player *pplayer)
 Return the leader name of the player. More...
 
struct playerplayer_by_name (const char *name)
 Find player by given name. More...
 
struct playerplayer_by_name_prefix (const char *name, enum m_pre_result *result)
 Find player by its name prefix. More...
 
struct playerplayer_by_user (const char *name)
 Find player by its user name (not player/leader name) More...
 
bool player_set_nation (struct player *pplayer, struct nation_type *pnation)
 Set the player's nation to the given nation (may be nullptr). More...
 
bool player_has_embassy (const struct player *pplayer, const struct player *pplayer2)
 Check if pplayer has an embassy with pplayer2. More...
 
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. More...
 
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. More...
 
int player_age (const struct player *pplayer)
 "Age" of the player: number of turns spent alive since created. More...
 
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. More...
 
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. More...
 
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. More...
 
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). More...
 
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. More...
 
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. More...
 
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. More...
 
bool player_owns_city (const struct player *pplayer, const struct city *pcity)
 Return TRUE iff the given player owns the city. More...
 
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). More...
 
struct cityplayer_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. More...
 
struct unitplayer_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. More...
 
bool player_in_city_map (const struct player *pplayer, const struct tile *ptile)
 Return true iff x,y is inside any of the player's city map. More...
 
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. More...
 
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. More...
 
int player_get_expected_income (const struct player *pplayer)
 Return the expected net income of the player this turn. More...
 
struct cityplayer_primary_capital (const struct player *pplayer)
 Locate the player's primary capital city, (nullptr Otherwise) More...
 
std::vector< city * > player_gov_centers (const struct player *pplayer)
 Locate the player's government centers. More...
 
const char * love_text (const int love)
 Return a text describing an AI's love for you. More...
 
enum diplstate_type cancel_pact_result (enum diplstate_type oldstate)
 Return the diplomatic state that cancelling a pact will end up in. More...
 
struct player_diplstateplayer_diplstate_get (const struct player *plr1, const struct player *plr2)
 Returns diplomatic state type between two players. More...
 
enum dipl_reason pplayer_can_make_treaty (const struct player *p1, const struct player *p2, enum diplstate_type treaty)
 Returns true iff p1 can make given treaty with p2. More...
 
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. More...
 
bool pplayers_at_war (const struct player *pplayer, const struct player *pplayer2)
 Returns true iff players can attack each other. More...
 
bool pplayers_allied (const struct player *pplayer, const struct player *pplayer2)
 Returns true iff players are allied. More...
 
bool pplayers_in_peace (const struct player *pplayer, const struct player *pplayer2)
 Returns true iff players are allied or at peace. More...
 
bool players_non_invade (const struct player *pplayer1, const struct player *pplayer2)
 Returns TRUE if players can't enter each others' territory. More...
 
bool pplayers_non_attack (const struct player *pplayer, const struct player *pplayer2)
 Returns true iff players have peace, cease-fire, or armistice. More...
 
bool players_on_same_team (const struct player *pplayer1, const struct player *pplayer2)
 Return TRUE if players are in the same team. More...
 
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. More...
 
static bool is_barbarian (const struct player *pplayer)
 
bool gives_shared_vision (const struct player *me, const struct player *them)
 Return TRUE iff the player me gives shared vision to player them. More...
 
void diplrel_mess_close ()
 Free diplrel_mess. More...
 
bool is_diplrel_between (const struct player *player1, const struct player *player2, int diplrel)
 Return TRUE iff player1 has the diplomatic relation to player2. More...
 
bool is_diplrel_to_other (const struct player *pplayer, int diplrel)
 Return TRUE iff pplayer has the diplomatic relation to any living player. More...
 
int diplrel_by_rule_name (const char *value)
 Return the diplomatic relation that has the given (untranslated) rule name. More...
 
const char * diplrel_rule_name (int value)
 Return the (untranslated) rule name of the given diplomatic relation. More...
 
const char * diplrel_name_translation (int value)
 Return the translated name of the given diplomatic relation. More...
 
enum casus_belli_range casus_belli_range_for (const struct player *offender, const struct player *tgt_plr, const enum effect_type outcome, const struct action *paction, const struct tile *tgt_tile)
 Return the Casus Belli range when offender performs paction to tgt_plr at tgt_tile and the outcome is outcome. More...
 
bv_diplrel_all_reqs diplrel_req_contradicts (const struct requirement *req)
 Get the DiplRel requirements that are known to contradict the specified DiplRel requirement. More...
 
int player_multiplier_value (const struct player *pplayer, const struct multiplier *pmul)
 Return the multiplier value currently in effect for pplayer (in display units). More...
 
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). More...
 
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). More...
 
bool is_valid_username (const char *name)
 Returns whether this is a valid username. More...
 
bool is_settable_ai_level (enum ai_level level)
 Return is AI can be set to given level. More...
 
void * player_ai_data (const struct player *pplayer, const struct ai_type *ai)
 Return pointer to ai data of given player and ai type. More...
 
void player_set_ai_data (struct player *pplayer, const struct ai_type *ai, void *data)
 Attach ai data to player. More...
 
static bool player_is_cpuhog (const struct player *pplayer)
 

Macro Definition Documentation

◆ ai_level_cmd

#define ai_level_cmd (   _level_)    ai_level_name(_level_)

Definition at line 551 of file player.h.

◆ ANON_PLAYER_NAME

#define ANON_PLAYER_NAME   "noname"

Definition at line 26 of file player.h.

◆ ANON_USER_NAME

#define ANON_USER_NAME   N_("Unassigned")

Definition at line 31 of file player.h.

◆ is_ai

#define is_ai (   plr)    player_has_flag((plr), PLRF_AI)

Definition at line 227 of file player.h.

◆ is_human

#define is_human (   plr)    !player_has_flag((plr), PLRF_AI)

Definition at line 226 of file player.h.

◆ MAX_AI_LOVE

#define MAX_AI_LOVE   1000

Definition at line 546 of file player.h.

◆ MAX_ATTRIBUTE_BLOCK

#define MAX_ATTRIBUTE_BLOCK   (256 * 1024)

Definition at line 219 of file player.h.

◆ PLAYER_DEFAULT_LUXURY_RATE

#define PLAYER_DEFAULT_LUXURY_RATE   0

Definition at line 24 of file player.h.

◆ PLAYER_DEFAULT_SCIENCE_RATE

#define PLAYER_DEFAULT_SCIENCE_RATE   100

Definition at line 23 of file player.h.

◆ PLAYER_DEFAULT_TAX_RATE

#define PLAYER_DEFAULT_TAX_RATE   0

Definition at line 22 of file player.h.

◆ player_list_iterate

#define player_list_iterate (   playerlist,
  pplayer 
)     TYPED_LIST_ITERATE(struct player, playerlist, pplayer)

Definition at line 541 of file player.h.

◆ player_list_iterate_end

#define player_list_iterate_end   LIST_ITERATE_END

Definition at line 543 of file player.h.

◆ player_slots_iterate

#define player_slots_iterate (   _pslot)
Value:
struct player_slot *_pslot = player_slot_first(); \
for (; nullptr != _pslot; _pslot = player_slot_next(_pslot)) {
bool player_slots_initialised()
Return whether player slots are already initialized.
Definition: player.cpp:341
struct player_slot * player_slot_first()
Returns the first player slot.
Definition: player.cpp:358
struct player_slot * player_slot_next(struct player_slot *pslot)
Returns the next slot.
Definition: player.cpp:363

Definition at line 505 of file player.h.

◆ player_slots_iterate_end

#define player_slots_iterate_end
Value:
} \
}

Definition at line 509 of file player.h.

◆ players_iterate

#define players_iterate (   _pplayer)
Value:
player_slots_iterate(_pslot##_pplayer) \
{ \
struct player *_pplayer = player_slot_get_player(_pslot##_pplayer); \
if (_pplayer != nullptr) {
#define player_slots_iterate(_pslot)
Definition: player.h:505
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
Definition: player.cpp:384
Definition: player.h:231

Definition at line 514 of file player.h.

◆ players_iterate_alive

#define players_iterate_alive (   _pplayer)
Value:
players_iterate(_pplayer) \
{ \
if (!_pplayer->is_alive) { \
continue; \
}
#define players_iterate(_pplayer)
Definition: player.h:514

Definition at line 526 of file player.h.

◆ players_iterate_alive_end

#define players_iterate_alive_end
Value:
} \
players_iterate_end;

Definition at line 532 of file player.h.

◆ players_iterate_end

#define players_iterate_end
Value:
} \
} \
player_slots_iterate_end;

Definition at line 520 of file player.h.

◆ set_as_ai

#define set_as_ai (   plr)    BV_SET((plr)->flags, PLRF_AI)

Definition at line 229 of file player.h.

◆ set_as_human

#define set_as_human (   plr)    BV_CLR((plr)->flags, PLRF_AI)

Definition at line 228 of file player.h.

◆ SPECENUM_BITVECTOR

#define SPECENUM_BITVECTOR   bv_plr_flags

Definition at line 47 of file player.h.

◆ SPECENUM_COUNT [1/4]

#define SPECENUM_COUNT   PLRF_COUNT

Definition at line 176 of file player.h.

◆ SPECENUM_COUNT [2/4]

#define SPECENUM_COUNT   PSTATUS_COUNT

Definition at line 176 of file player.h.

◆ SPECENUM_COUNT [3/4]

#define SPECENUM_COUNT   DS_LAST

Definition at line 176 of file player.h.

◆ SPECENUM_COUNT [4/4]

#define SPECENUM_COUNT   DRO_LAST

Definition at line 176 of file player.h.

◆ SPECENUM_NAME [1/4]

#define SPECENUM_NAME   plr_flag_id

Definition at line 155 of file player.h.

◆ SPECENUM_NAME [2/4]

#define SPECENUM_NAME   player_status

Definition at line 155 of file player.h.

◆ SPECENUM_NAME [3/4]

#define SPECENUM_NAME   diplstate_type

Definition at line 155 of file player.h.

◆ SPECENUM_NAME [4/4]

#define SPECENUM_NAME   diplrel_other

Definition at line 155 of file player.h.

◆ SPECENUM_VALUE0 [1/3]

#define SPECENUM_VALUE0   PLRF_AI

Definition at line 130 of file player.h.

◆ SPECENUM_VALUE0 [2/3]

#define SPECENUM_VALUE0   PSTATUS_NORMAL

Definition at line 130 of file player.h.

◆ SPECENUM_VALUE0 [3/3]

#define SPECENUM_VALUE0   DS_ARMISTICE

Definition at line 130 of file player.h.

◆ SPECENUM_VALUE0NAME [1/2]

#define SPECENUM_VALUE0NAME   "ai"

Definition at line 131 of file player.h.

◆ SPECENUM_VALUE0NAME [2/2]

#define SPECENUM_VALUE0NAME   N_("?diplomatic_state:Armistice")

Definition at line 131 of file player.h.

◆ SPECENUM_VALUE1 [1/3]

#define SPECENUM_VALUE1   PLRF_SCENARIO_RESERVED

Definition at line 132 of file player.h.

◆ SPECENUM_VALUE1 [2/3]

#define SPECENUM_VALUE1   PSTATUS_DYING

Definition at line 132 of file player.h.

◆ SPECENUM_VALUE1 [3/3]

#define SPECENUM_VALUE1   DS_WAR

Definition at line 132 of file player.h.

◆ SPECENUM_VALUE10

#define SPECENUM_VALUE10   DRO_HAS_EMBASSY

Definition at line 162 of file player.h.

◆ SPECENUM_VALUE10NAME

#define SPECENUM_VALUE10NAME   N_("Has embassy")

Definition at line 163 of file player.h.

◆ SPECENUM_VALUE11

#define SPECENUM_VALUE11   DRO_HOSTS_REAL_EMBASSY

Definition at line 164 of file player.h.

◆ SPECENUM_VALUE11NAME

#define SPECENUM_VALUE11NAME   N_("Hosts real embassy")

Definition at line 165 of file player.h.

◆ SPECENUM_VALUE12

#define SPECENUM_VALUE12   DRO_HAS_REAL_EMBASSY

Definition at line 166 of file player.h.

◆ SPECENUM_VALUE12NAME

#define SPECENUM_VALUE12NAME   N_("Has real embassy")

Definition at line 167 of file player.h.

◆ SPECENUM_VALUE13

#define SPECENUM_VALUE13   DRO_HAS_CASUS_BELLI

Definition at line 168 of file player.h.

◆ SPECENUM_VALUE13NAME

#define SPECENUM_VALUE13NAME   N_("Has Casus Belli")

Definition at line 169 of file player.h.

◆ SPECENUM_VALUE14

#define SPECENUM_VALUE14   DRO_PROVIDED_CASUS_BELLI

Definition at line 170 of file player.h.

◆ SPECENUM_VALUE14NAME

#define SPECENUM_VALUE14NAME   N_("Provided Casus Belli")

Definition at line 171 of file player.h.

◆ SPECENUM_VALUE15

#define SPECENUM_VALUE15   DRO_FOREIGN

Definition at line 172 of file player.h.

◆ SPECENUM_VALUE15NAME

#define SPECENUM_VALUE15NAME   N_("Foreign")

Definition at line 173 of file player.h.

◆ SPECENUM_VALUE16

#define SPECENUM_VALUE16   DRO_HAS_CONTACT

Definition at line 174 of file player.h.

◆ SPECENUM_VALUE16NAME

#define SPECENUM_VALUE16NAME   N_("Has Contact")

Definition at line 175 of file player.h.

◆ SPECENUM_VALUE1NAME [1/2]

#define SPECENUM_VALUE1NAME   "ScenarioReserved"

Definition at line 133 of file player.h.

◆ SPECENUM_VALUE1NAME [2/2]

#define SPECENUM_VALUE1NAME   N_("?diplomatic_state:War")

Definition at line 133 of file player.h.

◆ SPECENUM_VALUE2 [1/2]

#define SPECENUM_VALUE2   PSTATUS_WINNER

Definition at line 134 of file player.h.

◆ SPECENUM_VALUE2 [2/2]

#define SPECENUM_VALUE2   DS_CEASEFIRE

Definition at line 134 of file player.h.

◆ SPECENUM_VALUE2NAME

#define SPECENUM_VALUE2NAME   N_("?diplomatic_state:Cease-fire")

Definition at line 135 of file player.h.

◆ SPECENUM_VALUE3 [1/2]

#define SPECENUM_VALUE3   PSTATUS_SURRENDER

Definition at line 136 of file player.h.

◆ SPECENUM_VALUE3 [2/2]

#define SPECENUM_VALUE3   DS_PEACE

Definition at line 136 of file player.h.

◆ SPECENUM_VALUE3NAME

#define SPECENUM_VALUE3NAME   N_("?diplomatic_state:Peace")

Definition at line 137 of file player.h.

◆ SPECENUM_VALUE4

#define SPECENUM_VALUE4   DS_ALLIANCE

Definition at line 138 of file player.h.

◆ SPECENUM_VALUE4NAME

#define SPECENUM_VALUE4NAME   N_("?diplomatic_state:Alliance")

Definition at line 139 of file player.h.

◆ SPECENUM_VALUE5

#define SPECENUM_VALUE5   DS_NO_CONTACT

Definition at line 140 of file player.h.

◆ SPECENUM_VALUE5NAME

#define SPECENUM_VALUE5NAME   N_("?diplomatic_state:Never met")

Definition at line 141 of file player.h.

◆ SPECENUM_VALUE6

#define SPECENUM_VALUE6   DS_TEAM

Definition at line 142 of file player.h.

◆ SPECENUM_VALUE6NAME

#define SPECENUM_VALUE6NAME   N_("?diplomatic_state:Team")

Definition at line 143 of file player.h.

◆ SPECENUM_VALUE7

#define SPECENUM_VALUE7   DRO_GIVES_SHARED_VISION

Definition at line 156 of file player.h.

◆ SPECENUM_VALUE7NAME

#define SPECENUM_VALUE7NAME   N_("Gives shared vision")

Definition at line 157 of file player.h.

◆ SPECENUM_VALUE8

#define SPECENUM_VALUE8   DRO_RECEIVES_SHARED_VISION

Definition at line 158 of file player.h.

◆ SPECENUM_VALUE8NAME

#define SPECENUM_VALUE8NAME   N_("Receives shared vision")

Definition at line 159 of file player.h.

◆ SPECENUM_VALUE9

#define SPECENUM_VALUE9   DRO_HOSTS_EMBASSY

Definition at line 160 of file player.h.

◆ SPECENUM_VALUE9NAME

#define SPECENUM_VALUE9NAME   N_("Hosts embassy")

Definition at line 161 of file player.h.

◆ SPECLIST_TAG

#define SPECLIST_TAG   player

Definition at line 537 of file player.h.

◆ SPECLIST_TYPE

#define SPECLIST_TYPE   struct player

Definition at line 538 of file player.h.

Enumeration Type Documentation

◆ dipl_reason

Enumerator
DIPL_OK 
DIPL_ERROR 
DIPL_SENATE_BLOCKING 
DIPL_ALLIANCE_PROBLEM_US 
DIPL_ALLIANCE_PROBLEM_THEM 

Definition at line 183 of file player.h.

◆ player_debug_types

Enumerator
PLAYER_DEBUG_DIPLOMACY 
PLAYER_DEBUG_TECH 
PLAYER_DEBUG_LAST 

Definition at line 208 of file player.h.

◆ plrcolor_mode

Enumerator
PLRCOL_PLR_ORDER 
PLRCOL_PLR_RANDOM 
PLRCOL_PLR_SET 
PLRCOL_TEAM_ORDER 
PLRCOL_NATION_ORDER 

Definition at line 33 of file player.h.

Function Documentation

◆ BV_DEFINE() [1/3]

BV_DEFINE ( bv_debug  ,
PLAYER_DEBUG_LAST   
)

◆ BV_DEFINE() [2/3]

BV_DEFINE ( bv_diplrel_all_reqs  ,
((DRO_LAST - 1) *2) *REQ_RANGE_COUNT+  2 
)

◆ BV_DEFINE() [3/3]

BV_DEFINE ( bv_pstatus  ,
PSTATUS_COUNT   
)

◆ 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 nullptr player. This is used by the client when in observer mode.

Definition at line 1060 of file player.cpp.

Referenced by broadcast_city_info(), can_player_see_units_in_city(), city_packet_common(), is_req_knowable(), is_tile_seen_city(), is_tile_seen_traderoute(), meswin_add(), 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 917 of file player.cpp.

Referenced by is_req_knowable().

◆ can_player_see_unit()

◆ 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 he: (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 959 of file player.cpp.

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 he clicks 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 nullptr player. This is used by the client when in observer mode.

Definition at line 1045 of file player.cpp.

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(), traditional_citybar_painter::paint(), polished_citybar_painter::paint(), popup_info_text(), remove_city(), 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 58 of file player.cpp.

Referenced by handle_diplomacy_cancel_pact_explicit().

◆ casus_belli_range_for()

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

Return the Casus Belli range when offender performs paction to tgt_plr at tgt_tile and the outcome is outcome.

Definition at line 1538 of file player.cpp.

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 1492 of file player.cpp.

Referenced by universal_by_number().

◆ diplrel_mess_close()

void diplrel_mess_close ( )

Free diplrel_mess.

Definition at line 1701 of file player.cpp.

Referenced by free_libfreeciv().

◆ diplrel_name_translation()

const char* diplrel_name_translation ( int  value)

Return the translated name of the given diplomatic relation.

Definition at line 1538 of file player.cpp.

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 1714 of file player.cpp.

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 1526 of file player.cpp.

Referenced by universal_rule_name().

◆ gives_shared_vision()

◆ is_barbarian()

◆ 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 1422 of file player.cpp.

Referenced by 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 1471 of file player.cpp.

◆ 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 1825 of file player.cpp.

Referenced by pregame_options::pregame_options(), page_pregame::start_page_menu(), and plr_report::toggle_ai_mode().

◆ 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 1793 of file player.cpp.

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 1283 of file player.cpp.

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 1181 of file player.cpp.

Referenced by is_claimable_ocean(), and player_knows_techs_with_flag().

◆ player_age()

int player_age ( const struct player pplayer)

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

Definition at line 876 of file player.cpp.

Referenced by is_req_active().

◆ 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 1838 of file player.cpp.

Referenced by def_ai_player_data(), tai_player_data(), tai_player_free(), texai_check_messages(), texai_player_data(), texai_player_free(), 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 800 of file player.cpp.

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

◆ player_by_name_prefix()

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

◆ 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 nullptr.

Definition at line 768 of file player.cpp.

Referenced by diplo_dlg::add_widget(), aifill(), diplo_wdg::all_advances(), api_find_player(), bvplayers_str(), city_from_great_wonder(), diplo_wdg::diplo_wdg(), editor_apply_tool(), editor_grab_applied_player(), editor_unit_virtual_create(), get_info_label_text(), diplo_wdg::give_advance(), diplo_wdg::give_city(), great_wonder_is_built(), great_wonder_owner(), handle_city_info(), handle_city_short_info(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_meeting_req(), handle_diplomacy_cancel_pact_explicit(), 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(), mapimg_checkplayers(), player_by_name_prefix(), player_name_by_number(), research_is_valid(), research_name_translation(), research_pretty_name(), research_rule_name(), sg_load_map_owner(), sg_load_player_city(), sg_load_player_unit(), sg_load_player_vision(), sg_load_player_vision_city(), diplo_wdg::show_menu(), shuffled_player(), start_command(), texai_city_info_recv(), texai_unit_info_recv(), unpackage_short_unit(), unpackage_unit(), 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 860 of file player.cpp.

Referenced by 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 236 of file player.cpp.

Referenced by explorer_tb(), pf_danger_node_init(), pf_fuel_node_init(), and pf_normal_node_init().

◆ 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 1074 of file player.cpp.

Referenced by broadcast_city_info(), 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 889 of file player.cpp.

Referenced by 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 nullptr. Now always uses fast idex_lookup_city.

pplayer may be nullptr 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 1113 of file player.cpp.

Referenced by api_find_city(), city_from_wonder(), dai_find_strategic_airbase(), do_unit_establish_trade(), handle_city_buy(), handle_city_change(), handle_city_change_specialist(), handle_city_make_specialist(), handle_city_make_worker(), handle_city_manager(), 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(), governor::run(), sg_load_player_cities(), 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, then the nation and the team will be cleared too.

Definition at line 615 of file player.cpp.

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

◆ player_count()

◆ player_destroy()

void player_destroy ( struct player pplayer)

Destroys and remove a player from the game.

Definition at line 684 of file player.cpp.

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

◆ player_diplstate_get()

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

◆ 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 1194 of file player.cpp.

Referenced by dai_manage_cities(), get_info_label_text(), get_info_label_text_popup(), show_new_turn_info(), and pageGame::updateInfoLabelTimeout().

◆ player_gov_centers()

std::vector<city *> player_gov_centers ( const struct player pplayer)

Locate the player's government centers.

Definition at line 1264 of file player.cpp.

Referenced by city_refresh(), cityresult_fill(), cm_state_init(), dai_city_want(), dai_manage_taxes(), and get_city_dialog_output_text().

◆ player_has_embassy()

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

◆ 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 216 of file player.cpp.

Referenced by player_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 1888 of file player.cpp.

Referenced by api_methods_player_has_flag(), handle_edit_player(), sg_save_player_main(), and page_pregame::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 206 of file player.cpp.

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

◆ player_in_city_map()

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

Return true iff x,y is inside any of the player's city map.

Definition at line 1159 of file player.cpp.

Referenced by freeciv::layer_grid::fill_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 1761 of file player.cpp.

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 748 of file player.cpp.

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(), diplo_log_prefix(), establish_embassy(), event_cache_add_for_player(), event_cache_match(), event_cache_player_add(), event_cache_save(), freeciv::layer_background::fill_sprite_array(), freeciv::layer_grid::fill_sprite_array(), found_new_tech(), get_player_landarea(), give_shared_vision(), gives_shared_vision(), handle_achievement_info(), handle_edit_city(), img_createmap(), img_save(), init_new_game(), freeciv::layer_background::initialize_player(), freeciv::layer_grid::initialize_player(), kill_unit(), log_civ_score_now(), map_claim_base(), mapimg_checkplayers(), mapimg_client_define(), mapimg_create(), package_player_diplstate(), package_player_info(), player_diplstate_destroy(), player_diplstate_get(), player_diplstate_new(), player_has_real_embassy(), player_limit_to_max_rates(), rank_users(), really_gives_vision(), remove_shared_vision(), send_unit_info(), sg_load_map_known(), sg_load_player_main(), sg_load_players(), sg_save_map_known(), sg_save_player_cities(), sg_save_player_main(), srv_ready(), tileset_player_init(), transfer_city(), transform_unit(), unit_goes_out_of_sight(), unit_move(), and unit_transport_load_send().

◆ player_is_cpuhog()

static bool player_is_cpuhog ( const struct player pplayer)
inlinestatic

Definition at line 558 of file player.h.

Referenced by adv_best_government(), assess_danger(), and cm_find_best_solution().

◆ 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 1238 of file player.cpp.

Referenced by can_build_extra_base(), and dai_choose_attacker_air().

◆ 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 1867 of file player.cpp.

Referenced by dai_effect_value(), get_city_dialog_culture_text(), get_city_dialog_illness_text(), get_city_dialog_output_text(), 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 1879 of file player.cpp.

Referenced by multipler_rates_dialog::multipler_rates_dialog().

◆ 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 1856 of file player.cpp.

Referenced by dai_adjust_policies(), 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 816 of file player.cpp.

Referenced by adv_data_get(), 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_from_great_wonder(), city_from_wonder(), city_name_suggestion(), civil_war(), civil_war_triggered(), cmp_name(), col_name(), conn_description(), connection_detach(), create_barbarian_player(), 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(), delegate_command(), delegate_player_str(), detach_command(), diplo_log_prefix(), do_spaceship_place(), do_tech_parasite_effect(), do_unit_change_homecity(), end_turn(), establish_new_connection(), explain_why_no_action_enabled(), 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_explicit(), 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_save(), init_new_game(), log_civ_score_now(), make_contact(), map_change_seen(), map_hide_tile(), map_show_tile(), observe_command(), package_player_common(), place_starting_unit(), player_balance_treasury_units(), player_balance_treasury_units_and_buildings(), player_limit_to_max_rates(), player_name_by_number(), player_nation_defaults(), player_tech_upkeep(), playercolor_command(), playername_accessor(), playernation_command(), rank_users(), really_diplomacy_cancel_meeting(), remove_player_command(), remove_shared_vision(), research_name_translation(), research_rule_name(), research_tech_lost(), ruler_title_for_player(), sell_random_building(), sell_random_unit(), send_delegation_info(), send_to_metaserver(), server_player_name_is_allowed(), server_remove_unit_full(), set_ai_level(), set_ai_level_direct(), sg_load_map_owner(), sg_load_players(), sg_load_players_basic(), sg_load_sanitycheck(), sg_save_player_main(), sg_save_treaties(), show_colors(), show_delegations(), show_players(), show_teams(), shuffled_player(), spy_poison(), page_pregame::start_page_menu(), surrender_command(), take_command(), team_command(), team_remove_player(), tech_log_prefix(), plr_report::toggle_ai_mode(), toggle_ai_player_direct(), try_summon_barbarians(), unit_conquer_city(), unit_do_destroy_city(), update_diplomatics(), update_dumb_city(), endgame_report::update_report(), update_revolution(), page_pregame::update_start_page(), and war_countdown().

◆ player_new()

struct player* player_new ( struct player_slot pslot)

Creates a new player for the slot.

If slot is nullptr, it will lookup to a free slot. If the slot already used, then just return the player.

Definition at line 442 of file player.cpp.

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 756 of file player.cpp.

Referenced by api_methods_player_number(), begin_phase(), check_leaving_edit_mode(), city_from_great_wonder(), city_from_wonder(), clear_old_treaty(), client_player_number(), cmp_love(), create_barbarian_player(), dai_diplomacy_actions(), dai_diplomacy_suggest(), dai_go_to_war(), dai_treaty_evaluate(), diplo_wdg::dbl_click(), editor_grab_applied_player(), fill_tile_edit_packet(), diplo_wdg::give_embassy(), diplo_wdg::give_shared_vision(), handle_diplomacy_accept_treaty_req(), handle_diplomacy_cancel_pact_explicit(), handle_diplomacy_create_clause_req(), handle_diplomacy_init_meeting_req(), 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(), img_save(), initialize_globals(), is_player_phase(), log_civ_score_now(), map_change_seen(), races_dialog::ok_pressed(), package_city(), package_conn_info(), package_dumb_city(), package_player_common(), package_short_unit(), package_unit(), diplo_wdg::pact_allianze(), 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(), plr_report::plr_cancel_threaty(), plr_report::plr_withdraw_vision(), races_dialog::random_pressed(), really_diplomacy_cancel_meeting(), reject_all_treaties(), report_final_scores(), plr_report::req_meeeting(), research_get(), diplo_wdg::response_accept(), diplo_wdg::response_cancel(), 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_cities(), sg_load_player_city(), sg_load_player_main(), sg_load_player_unit(), sg_load_player_units(), sg_load_player_units_transport(), sg_load_player_vision(), 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(), page_pregame::slot_pregame_start(), srv_ready(), start_command(), team_add_player(), team_remove_player(), texai_city_update(), texai_unit_update(), update_diplomatics(), 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 227 of file player.cpp.

Referenced by calc_civ_score(), and really_handle_city_buy().

◆ player_primary_capital()

struct city* player_primary_capital ( const struct player pplayer)

◆ 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 673 of file player.cpp.

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 1846 of file player.cpp.

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 nullptr in pregame.

Definition at line 598 of file player.cpp.

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 nullptr).

Returns TRUE iff there was a change. Doesn't check if the nation is legal wrt nationset.

Definition at line 780 of file player.cpp.

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(), and sg_load_players().

◆ player_slot_by_number()

struct player_slot* player_slot_by_number ( int  player_id)

◆ player_slot_first()

struct player_slot* player_slot_first ( )

Returns the first player slot.

Definition at line 358 of file player.cpp.

◆ player_slot_get_player()

◆ player_slot_index()

◆ 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 395 of file player.cpp.

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

◆ player_slot_max_used_number()

int player_slot_max_used_number ( )

Return the highest used player slot index.

Definition at line 423 of file player.cpp.

Referenced by 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 363 of file player.cpp.

◆ player_slots_free()

void player_slots_free ( )

Remove all player slots.

Definition at line 346 of file player.cpp.

Referenced by game_free().

◆ player_slots_init()

void player_slots_init ( )

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

Definition at line 324 of file player.cpp.

Referenced by game_init().

◆ player_slots_initialised()

bool player_slots_initialised ( )

Return whether player slots are already initialized.

Definition at line 341 of file player.cpp.

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

◆ 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 nullptr. Uses fast idex_lookup_city.

pplayer may be nullptr 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 1139 of file player.cpp.

Referenced by api_find_unit(), auto_settler_setup_work(), diplomat_bribe(), do_disband_alternative(), execute_orders(), find_something_to_kill(), 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_real(), handle_unit_orders(), handle_unit_packet_common(), handle_unit_server_side_agent_set(), handle_unit_sscs_set(), settler_evaluate_city_requests(), settler_evaluate_improvements(), sg_load_player_units_transport(), and unit_perform_action().

◆ 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 1371 of file player.cpp.

Referenced by player_can_invade_tile().

◆ players_on_same_team()

◆ 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 58 of file player.cpp.

Referenced by dai_go_to_war(), handle_diplomacy_cancel_pact_explicit(), 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 true iff p1 can make given treaty with p2.

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 123 of file player.cpp.

Referenced by handle_diplomacy_accept_treaty_req(), 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 1334 of file player.cpp.

Referenced by adv_danger_at(), adv_data_phase_init(), amphibious_move_scope(), api_edit_create_unit_full(), api_edit_unit_teleport(), api_methods_enemy_tile(), calculate_want_for_paratrooper(), 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(), does_foreign_trade_param_allow(), explorer_tb(), find_best_tile_to_paradrop_to(), find_city_to_diplomat(), find_nearest_safe_city(), get_allied_with_enemy_player(), handle_diplomacy_cancel_pact_explicit(), handle_edit_unit_create(), is_allied_city_tile(), is_allied_unit_tile(), is_friendly_city_near(), is_my_zoc(), is_non_allied_city_tile(), is_non_allied_unit_tile(), is_valid_alliance(), maybe_cancel_patrol_due_to_enemy(), overview_tile_color(), player_can_trust_tile_has_no_units(), players_in_same_range(), reinforcements_cost_and_value(), sg_load_players(), throw_units_from_illegal_cities(), transfer_city_units(), unit_being_aggressive(), unit_bombard(), update_diplomatics(), wakeup_neighbor_sentries(), and war_countdown().

◆ pplayers_at_war()

◆ 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 1355 of file player.cpp.

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 
)