25 bool allow_ai_type_fallbacking);
40 bool revolution_finished);
50 const char *
name,
char *error_buf,
51 size_t error_buf_len);
54 bool ignore_conflicts,
bool needs_startpos,
83 #define shuffled_players_iterate(NAME_pplayer) \
86 struct player *NAME_pplayer; \
87 log_debug("shuffled_players_iterate @ %s line %d", __FILE__, \
89 for (MY_i = 0; MY_i < MAX_NUM_PLAYER_SLOTS; MY_i++) { \
90 NAME_pplayer = shuffled_player(MY_i); \
91 if (NAME_pplayer != nullptr) {
93 #define shuffled_players_iterate_end \
99 #define phase_players_iterate(pplayer) \
101 shuffled_players_iterate(pplayer) \
103 if (is_player_phase(pplayer, game.info.phase)) {
105 #define phase_players_iterate_end \
108 shuffled_players_iterate_end; \
113 #define alive_phase_players_iterate(pplayer) \
115 phase_players_iterate(pplayer) \
117 if (pplayer->is_alive) {
119 #define alive_phase_players_iterate_end \
122 phase_players_iterate_end \
128 bool honour_server_option);
134 const struct unit_list *pplayer_seen_units,
135 const struct unit_list *pplayer2_seen_units);
153 enum clause_type clause,
154 bool protect_alliances);
165 enum ai_level skill_level);
struct conn_list * player_reply_dest(struct player *pplayer)
Convenience function to return "reply" destination connection list for player: pplayer->current_conn ...
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Tell clients which nations can be picked given current server settings.
void server_player_set_name(struct player *pplayer, const char *name)
Try to set the player name to 'name'.
void send_player_all_c(struct player *src, struct conn_list *dest)
Send all information about a player (player_info and all player_diplstates) to the given connections.
bool client_can_pick_nation(const struct nation_type *nation)
Return whether a nation is "pickable" – whether players can select it at game start.
void player_update_last_war_action(struct player *pplayer)
Update last war action timestamp (affects player mood).
struct player * civil_war(struct player *pplayer)
Capturing a nation's primary capital is a devastating blow.
void playercolor_init()
Initialise the player colors.
void player_set_under_human_control(struct player *pplayer)
Toggle player under human control.
void count_playable_nations()
Update the server's cached number of playable nations.
bool player_status_check(struct player *plr, enum player_status status)
Check player status flag.
void playercolor_free()
Free the memory allocated for the player color.
void give_midgame_initial_units(struct player *pplayer, struct tile *ptile)
Gives units that every player should have.
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Creates a new, uninitialized, used player slot.
bool civil_war_triggered(struct player *pplayer)
civil_war_triggered: The capture of a primary capital is not a sure fire way to throw and empire into...
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Set the player's color.
void player_set_to_ai_mode(struct player *pplayer, enum ai_level skill_level)
Toggle player to AI mode.
bool server_player_set_name_full(const struct connection *caller, struct player *pplayer, const struct nation_type *pnation, const char *name, char *error_buf, size_t error_buf_len)
Try to set the player name to 'name'.
bool player_delegation_active(const struct player *pplayer)
Returns TRUE if a delegation is active.
struct player * player_by_user_delegated(const char *name)
For a given user, if there is some player that the user originally controlled but is currently delega...
void assign_player_colors()
Permanently assign colors to any players that don't already have them.
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
Check if we make contact with anyone.
struct rgbcolor * playercolor_get(int id)
Get the player color with the index 'id'.
void check_player_max_rates(struct player *pplayer)
The following checks that government rates are acceptable for the present form of government.
void kill_player(struct player *pplayer)
Murder a player in cold blood.
void send_player_info_c(struct player *src, struct conn_list *dest)
Send information about player slot 'src', or all valid (i.e.
void set_shuffled_players(int *shuffled_players)
Initialize the shuffled players list (as from a loaded savegame).
void player_status_reset(struct player *plr)
Reset player status to 'normal'.
void send_delegation_info(const struct connection *pconn)
Send information about delegations to reconnecting users.
void update_players_after_alliance_breakup(struct player *pplayer, struct player *pplayer2, const struct unit_list *pplayer_seen_units, const struct unit_list *pplayer2_seen_units)
After the alliance is breaken, we need to do two things:
void handle_diplomacy_cancel_pact_explicit(struct player *pplayer, int other_player_id, enum clause_type clause, bool protect_alliances)
A variant of handle_diplomacy_cancel_pact that allows the caller to explicitely control if war declar...
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Check if civil war is possible for a player.
void player_delegation_set(struct player *pplayer, const char *username)
Define a delegation.
void fit_nationset_to_players()
Try to select a nation set that fits the current players' nations, or failing that,...
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
This function returns a random-ish nation that is suitable for 'barb_type' and is usable (not already...
void server_remove_player(struct player *pplayer)
This function does not close any connections attached to this player.
void player_info_freeze()
Do not compute and send PACKET_PLAYER_INFO or PACKET_NATION_AVAILABILITY until a call to player_info_...
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Finish the revolution and set the player's government.
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Initialize ANY newly-created player on the server.
int normal_player_count()
Return the number of non-barbarian players.
void make_contact(struct player *pplayer1, struct player *pplayer2, struct tile *ptile)
Update contact info.
void player_status_add(struct player *plr, enum player_status status)
Add a status flag to a player.
void playercolor_add(struct rgbcolor *prgbcolor)
Add a color to the list of all available player colors.
void update_capital(struct player *pplayer)
Recalculate what city is the named capital.
struct player_economic player_limit_to_max_rates(struct player *pplayer)
The following limits a player's rates to those that are acceptable for the present form of government...
void player_info_thaw()
If the frozen level is back to 0, send all players' infos, and nation availability,...
bool player_color_changeable(const struct player *pplayer, const char **reason)
Return whether a player's color can currently be set with the '/playercolor' command.
void shuffle_players()
Shuffle or reshuffle the player order, storing in static variables above.
int playercolor_count()
Number of player colors defined.
struct player * shuffled_player(int i)
Returns the i'th shuffled player, or nullptr.
const struct rgbcolor * player_preferred_color(struct player *pplayer)
If a player's color will be predictable when colors are assigned (or assignment has already happened)...
const char * player_delegation_get(const struct player *pplayer)
Returns the username that control of the player is delegated to, if any.
void send_player_diplstate_c(struct player *src, struct conn_list *dest)
Identical to send_player_info_c(), but sends the diplstate of the player.
bool nation_is_in_current_set(const struct nation_type *pnation)
Is the nation in the currently selected nationset? If not, it's not allowed to appear in the game.
void enter_war(struct player *pplayer, struct player *pplayer2)
Two players enter war.
int revolution_length(struct government *gov, struct player *plr)
Get length of a revolution.
const char * player_color_ftstr(struct player *pplayer)
Return the player color as featured text string.
void reset_all_start_commands(bool plrchange)
Called when something is changed; this resets everyone's readiness.
void update_revolution(struct player *pplayer)
See if the player has finished their revolution.
enum barbarian_type barb_type
char username[MAX_LEN_NAME]