22 #define PLAYER_DEFAULT_TAX_RATE 0
23 #define PLAYER_DEFAULT_SCIENCE_RATE 100
24 #define PLAYER_DEFAULT_LUXURY_RATE 0
26 #define ANON_PLAYER_NAME "noname"
31 #define ANON_USER_NAME N_("Unassigned")
41 #define SPECENUM_NAME plr_flag_id
42 #define SPECENUM_VALUE0 PLRF_AI
43 #define SPECENUM_VALUE0NAME "ai"
44 #define SPECENUM_VALUE1 PLRF_SCENARIO_RESERVED
45 #define SPECENUM_VALUE1NAME "ScenarioReserved"
46 #define SPECENUM_COUNT PLRF_COUNT
47 #define SPECENUM_BITVECTOR bv_plr_flags
48 #include "specenum_gen.h"
60 #define SPECENUM_NAME player_status
62 #define SPECENUM_VALUE0 PSTATUS_NORMAL
64 #define SPECENUM_VALUE1 PSTATUS_DYING
66 #define SPECENUM_VALUE2 PSTATUS_WINNER
68 #define SPECENUM_VALUE3 PSTATUS_SURRENDER
70 #define SPECENUM_COUNT PSTATUS_COUNT
71 #include "specenum_gen.h"
129 #define SPECENUM_NAME diplstate_type
130 #define SPECENUM_VALUE0 DS_ARMISTICE
131 #define SPECENUM_VALUE0NAME N_("?diplomatic_state:Armistice")
132 #define SPECENUM_VALUE1 DS_WAR
133 #define SPECENUM_VALUE1NAME N_("?diplomatic_state:War")
134 #define SPECENUM_VALUE2 DS_CEASEFIRE
135 #define SPECENUM_VALUE2NAME N_("?diplomatic_state:Cease-fire")
136 #define SPECENUM_VALUE3 DS_PEACE
137 #define SPECENUM_VALUE3NAME N_("?diplomatic_state:Peace")
138 #define SPECENUM_VALUE4 DS_ALLIANCE
139 #define SPECENUM_VALUE4NAME N_("?diplomatic_state:Alliance")
140 #define SPECENUM_VALUE5 DS_NO_CONTACT
141 #define SPECENUM_VALUE5NAME N_("?diplomatic_state:Never met")
142 #define SPECENUM_VALUE6 DS_TEAM
143 #define SPECENUM_VALUE6NAME N_("?diplomatic_state:Team")
146 #define SPECENUM_COUNT DS_LAST
147 #include "specenum_gen.h"
155 #define SPECENUM_NAME diplrel_other
156 #define SPECENUM_VALUE7 DRO_GIVES_SHARED_VISION
157 #define SPECENUM_VALUE7NAME N_("Gives shared vision")
158 #define SPECENUM_VALUE8 DRO_RECEIVES_SHARED_VISION
159 #define SPECENUM_VALUE8NAME N_("Receives shared vision")
160 #define SPECENUM_VALUE9 DRO_HOSTS_EMBASSY
161 #define SPECENUM_VALUE9NAME N_("Hosts embassy")
162 #define SPECENUM_VALUE10 DRO_HAS_EMBASSY
163 #define SPECENUM_VALUE10NAME N_("Has embassy")
164 #define SPECENUM_VALUE11 DRO_HOSTS_REAL_EMBASSY
165 #define SPECENUM_VALUE11NAME N_("Hosts real embassy")
166 #define SPECENUM_VALUE12 DRO_HAS_REAL_EMBASSY
167 #define SPECENUM_VALUE12NAME N_("Has real embassy")
168 #define SPECENUM_VALUE13 DRO_HAS_CASUS_BELLI
169 #define SPECENUM_VALUE13NAME N_("Has Casus Belli")
170 #define SPECENUM_VALUE14 DRO_PROVIDED_CASUS_BELLI
171 #define SPECENUM_VALUE14NAME N_("Provided Casus Belli")
172 #define SPECENUM_VALUE15 DRO_FOREIGN
173 #define SPECENUM_VALUE15NAME N_("Foreign")
174 #define SPECENUM_VALUE16 DRO_HAS_CONTACT
175 #define SPECENUM_VALUE16NAME N_("Has Contact")
176 #define SPECENUM_COUNT DRO_LAST
177 #include "specenum_gen.h"
181 ((DRO_LAST - 1) * 2) * REQ_RANGE_COUNT + 2);
193 enum diplstate_type
type;
219 #define MAX_ATTRIBUTE_BLOCK (256 * 1024)
226 #define is_human(plr) !player_has_flag((plr), PLRF_AI)
227 #define is_ai(plr) player_has_flag((plr), PLRF_AI)
228 #define set_as_human(plr) BV_CLR((plr)->flags, PLRF_AI)
229 #define set_as_ai(plr) BV_SET((plr)->flags, PLRF_AI)
324 void *
ais[FREECIV_AI_MOD_LAST];
399 const struct player *pplayer2);
401 const struct player *pplayer2);
403 const struct player *pplayer2);
408 const struct tile *ptile);
410 const struct tile *ptile);
412 const struct unit *punit);
414 const struct unit *punit,
415 const struct tile *ptile,
bool is_transported);
418 const struct city *pcity);
420 const struct city *pcity);
422 const struct city *target_city);
425 const struct city *pcity);
427 const struct tile *ptile);
435 const struct tile *ptile);
437 enum tech_flag_id flag);
439 enum tech_flag_id flag);
450 const struct player *plr2);
453 enum diplstate_type treaty);
457 const struct player *pplayer2);
459 const struct player *pplayer2);
461 const struct player *pplayer2);
463 const struct player *pplayer2);
465 const struct player *pplayer2);
467 const struct player *pplayer2);
469 const struct player *pplayer2);
483 const struct player *player2,
int diplrel);
490 const struct player *tgt_plr,
491 const enum effect_type outcome,
492 const struct action *paction,
493 const struct tile *tgt_tile);
505 #define player_slots_iterate(_pslot) \
506 if (player_slots_initialised()) { \
507 struct player_slot *_pslot = player_slot_first(); \
508 for (; nullptr != _pslot; _pslot = player_slot_next(_pslot)) {
509 #define player_slots_iterate_end \
514 #define players_iterate(_pplayer) \
515 player_slots_iterate(_pslot##_pplayer) \
517 struct player *_pplayer = player_slot_get_player(_pslot##_pplayer); \
518 if (_pplayer != nullptr) {
520 #define players_iterate_end \
523 player_slots_iterate_end;
526 #define players_iterate_alive(_pplayer) \
527 players_iterate(_pplayer) \
529 if (!_pplayer->is_alive) { \
532 #define players_iterate_alive_end \
537 #define SPECLIST_TAG player
538 #define SPECLIST_TYPE struct player
541 #define player_list_iterate(playerlist, pplayer) \
542 TYPED_LIST_ITERATE(struct player, playerlist, pplayer)
543 #define player_list_iterate_end LIST_ITERATE_END
546 #define MAX_AI_LOVE 1000
551 #define ai_level_cmd(_level_) ai_level_name(_level_)
#define MAX_NUM_PLAYER_SLOTS
#define MAX_NUM_MULTIPLIERS
bool is_settable_ai_level(enum ai_level level)
Return is AI can be set to given level.
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).
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.
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 u...
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.
struct player_slot * player_slot_by_number(int player_id)
Return the possibly unused and uninitialized player slot.
@ DIPL_ALLIANCE_PROBLEM_THEM
@ DIPL_ALLIANCE_PROBLEM_US
bool player_slot_is_used(const struct player_slot *pslot)
Returns TRUE is this slot is "used" i.e.
bv_diplrel_all_reqs diplrel_req_contradicts(const struct requirement *req)
Get the DiplRel requirements that are known to contradict the specified DiplRel requirement.
struct player * player_by_name(const char *name)
Find player by given name.
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.
bool is_valid_username(const char *name)
Returns whether this is a valid username.
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...
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...
int diplrel_by_rule_name(const char *value)
Return the diplomatic relation that has the given (untranslated) rule name.
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.
bool players_on_same_team(const struct player *pplayer1, const struct player *pplayer2)
Return TRUE if players are in the same team.
bool player_slots_initialised()
Return whether player slots are already initialized.
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).
enum diplstate_type cancel_pact_result(enum diplstate_type oldstate)
Return the diplomatic state that cancelling a pact will end up in.
int player_multiplier_value(const struct player *pplayer, const struct multiplier *pmul)
Return the multiplier value currently in effect for pplayer (in display units).
void * player_ai_data(const struct player *pplayer, const struct ai_type *ai)
Return pointer to ai data of given player and ai type.
struct player * player_by_number(const int player_id)
Return struct player pointer for the given player index.
const char * diplrel_name_translation(int value)
Return the translated name of the given diplomatic relation.
int player_get_expected_income(const struct player *pplayer)
Return the expected net income of the player this turn.
int player_number(const struct player *pplayer)
Return the player index/number/id.
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.
struct player * player_by_name_prefix(const char *name, enum m_pre_result *result)
Find player by its name prefix.
bool is_diplrel_to_other(const struct player *pplayer, int diplrel)
Return TRUE iff pplayer has the diplomatic relation to any living player.
static bool is_barbarian(const struct player *pplayer)
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.
int player_count()
Return the number of players.
bool pplayers_at_war(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players can attack each other.
std::vector< city * > player_gov_centers(const struct player *pplayer)
Locate the player's government centers.
BV_DEFINE(bv_pstatus, PSTATUS_COUNT)
void player_set_ai_data(struct player *pplayer, const struct ai_type *ai, void *data)
Attach ai data to player.
const char * love_text(const int love)
Return a text describing an AI's love for you.
void player_ruleset_close(struct player *pplayer)
Clear the ruleset dependent pointers of the player structure.
void player_clear(struct player *pplayer, bool full)
Clear all player data.
int player_slot_index(const struct player_slot *pslot)
Returns the index of the player slot.
struct player_slot * player_slot_first()
Returns the first player slot.
bool player_has_flag(const struct player *pplayer, enum plr_flag_id flag)
Check if player has given flag.
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,...
void player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Set the player's color.
int player_slot_max_used_number()
Return the highest used player slot index.
void player_slots_free()
Remove all player slots.
int player_index(const struct player *pplayer)
Return the player index.
void diplrel_mess_close()
Free diplrel_mess.
struct city * player_primary_capital(const struct player *pplayer)
Locate the player's primary capital city, (nullptr Otherwise)
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 pplay...
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.
bool is_diplrel_between(const struct player *player1, const struct player *player2, int diplrel)
Return TRUE iff player1 has the diplomatic relation to player2.
static bool player_is_cpuhog(const struct player *pplayer)
struct player * player_slot_get_player(const struct player_slot *pslot)
Returns the team corresponding to the slot.
bool player_set_nation(struct player *pplayer, struct nation_type *pnation)
Set the player's nation to the given nation (may be nullptr).
void player_slots_init()
Initialise all player slots (= pointer to player pointers).
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.
const char * player_name(const struct player *pplayer)
Return the leader name of the player.
int player_age(const struct player *pplayer)
"Age" of the player: number of turns spent alive since created.
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.
bool pplayers_allied(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied.
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.
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.
bool players_non_invade(const struct player *pplayer1, const struct player *pplayer2)
Returns TRUE if players can't enter each others' territory.
bool pplayers_non_attack(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players have peace, cease-fire, or armistice.
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.
struct player_slot * player_slot_next(struct player_slot *pslot)
Returns the next slot.
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.
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.
struct player * player_new(struct player_slot *pslot)
Creates a new player for the slot.
bool player_has_embassy(const struct player *pplayer, const struct player *pplayer2)
Check if pplayer has an embassy with pplayer2.
bool gives_shared_vision(const struct player *me, const struct player *them)
Return TRUE iff the player me gives shared vision to player them.
bool player_owns_city(const struct player *pplayer, const struct city *pcity)
Return TRUE iff the given player owns the city.
void player_destroy(struct player *pplayer)
Destroys and remove a player from the game.
const char * diplrel_rule_name(int value)
Return the (untranslated) rule name of the given diplomatic relation.
struct player * player_by_user(const char *name)
Find player by its user name (not player/leader name)
bool pplayers_in_peace(const struct player *pplayer, const struct player *pplayer2)
Returns true iff players are allied or at peace.
struct player_diplstate * player_diplstate_get(const struct player *plr1, const struct player *plr2)
Returns diplomatic state type between two players.
struct setting_list * level[OLEVELS_NUM]
enum ai_level skill_level
std::vector< ai_trait > traits
enum barbarian_type barbarian_type
int love[MAX_NUM_PLAYER_SLOTS]
enum diplstate_type max_state
struct city_list * cities
bv_intel_visible visible
Which information is actually visible to the client (and can thus be trusted)
QByteArray attribute_block
struct player_ai ai_common
struct player::@65::@68 client
const struct player_diplstate ** diplstates
struct government * target_government
char username[MAX_LEN_NAME]
void * ais[FREECIV_AI_MOD_LAST]
struct player::@65::@67 server
struct government * government
struct connection * current_conn
char * savegame_ai_type_name
QByteArray attribute_block_buffer
const struct ai_type * ai
QBitArray * tile_vision[V_COUNT]
int wonder_build_turn[B_LAST]
char ranked_username[MAX_LEN_NAME]
struct conn_list * connections
struct player_economic economic
char delegate_to[MAX_LEN_NAME]
struct player_spaceship spaceship
bv_player gives_shared_vision
struct player_score score
int multipliers[MAX_NUM_MULTIPLIERS]
struct player_tile * private_map
bv_player really_gives_vision
struct nation_type * nation
struct nation_style * style
int multipliers_target[MAX_NUM_MULTIPLIERS]
struct player_slot * slot
char orig_username[MAX_LEN_NAME]