1 /**********************************************************************
2 Freeciv - Copyright (C) 1996 - A Kjeldberg, L Gregersen, P Unold
3 This program is free software; you can redistribute it and/or modify
4 it under the terms of the GNU General Public License as published by
5 the Free Software Foundation; either version 2, or (at your option)
8 This program is distributed in the hope that it will be useful,
9 but WITHOUT ANY WARRANTY; without even the implied warranty of
10 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 GNU General Public License for more details.
12 ***********************************************************************/
24 enum plr_info_level
{ INFO_MINIMUM
, INFO_MEETING
, INFO_EMBASSY
, INFO_FULL
};
26 struct player
*server_create_player(int player_id
, const char *ai_type
,
27 struct rgbcolor
*prgbcolor
);
28 const struct rgbcolor
*player_preferred_color(struct player
*pplayer
);
29 void assign_player_colors(void);
30 void server_player_set_color(struct player
*pplayer
,
31 const struct rgbcolor
*prgbcolor
);
32 const char *player_color_ftstr(struct player
*pplayer
);
33 void server_player_init(struct player
*pplayer
, bool initmap
,
35 void give_midgame_initial_units(struct player
*pplayer
, struct tile
*ptile
);
36 void server_remove_player(struct player
*pplayer
);
37 void kill_player(struct player
*pplayer
);
38 void update_revolution(struct player
*pplayer
);
40 struct player_economic
player_limit_to_max_rates(struct player
*pplayer
);
42 void server_player_set_name(struct player
*pplayer
, const char *name
);
43 bool server_player_set_name_full(const struct connection
*caller
,
44 struct player
*pplayer
,
45 const struct nation_type
*pnation
,
47 char *error_buf
, size_t error_buf_len
);
49 struct nation_type
*pick_a_nation(const struct nation_list
*choices
,
50 bool ignore_conflicts
,
52 enum barbarian_type barb_type
);
53 bool nation_is_in_current_set(const struct nation_type
*pnation
);
54 bool client_can_pick_nation(const struct nation_type
*nation
);
55 void count_playable_nations(void);
56 void send_nation_availability(struct conn_list
*dest
, bool nationset_change
);
57 void fit_nationset_to_players(void);
59 /* Iterate over nations in the currently selected set.
60 * Does not filter on playability or anything else. */
61 #define allowed_nations_iterate(pnation) \
62 nations_iterate(pnation) { \
63 if (nation_is_in_current_set(pnation)) {
65 #define allowed_nations_iterate_end \
69 void check_player_max_rates(struct player
*pplayer
);
70 void make_contact(struct player
*pplayer1
, struct player
*pplayer2
,
72 void maybe_make_contact(struct tile
*ptile
, struct player
*pplayer
);
73 void enter_war(struct player
*pplayer
, struct player
*pplayer2
);
75 void player_info_freeze(void);
76 void player_info_thaw(void);
78 void send_player_all_c(struct player
*src
, struct conn_list
*dest
);
79 void send_player_info_c(struct player
*src
, struct conn_list
*dest
);
80 void send_player_diplstate_c(struct player
*src
, struct conn_list
*dest
);
82 struct conn_list
*player_reply_dest(struct player
*pplayer
);
84 void shuffle_players(void);
85 void set_shuffled_players(int *shuffled_players
);
86 struct player
*shuffled_player(int i
);
87 void reset_all_start_commands(void);
89 #define shuffled_players_iterate(NAME_pplayer)\
92 struct player *NAME_pplayer;\
93 log_debug("shuffled_players_iterate @ %s line %d",\
94 __FILE__, __FC_LINE__);\
95 for (MY_i = 0; MY_i < player_slot_count(); MY_i++) {\
96 NAME_pplayer = shuffled_player(MY_i);\
97 if (NAME_pplayer != NULL) {\
99 #define shuffled_players_iterate_end\
104 #define phase_players_iterate(pplayer)\
106 shuffled_players_iterate(pplayer) {\
107 if (is_player_phase(pplayer, game.info.phase)) {
109 #define phase_players_iterate_end\
111 } shuffled_players_iterate_end;\
114 bool civil_war_possible(struct player
*pplayer
, bool conquering_city
,
115 bool honour_server_option
);
116 bool civil_war_triggered(struct player
*pplayer
);
117 struct player
*civil_war(struct player
*pplayer
);
119 void update_players_after_alliance_breakup(struct player
*pplayer
,
120 struct player
*pplayer2
,
121 const struct unit_list
123 const struct unit_list
124 *pplayer2_seen_units
);
126 /* Player counts, total player_count() is in common/player.c */
127 int barbarian_count(void);
128 int normal_player_count(void);
130 void player_status_add(struct player
*plr
, enum player_status status
);
131 bool player_status_check(struct player
*plr
, enum player_status status
);
132 void player_status_reset(struct player
*plr
);
134 const char *player_delegation_get(const struct player
*pplayer
);
135 void player_delegation_set(struct player
*pplayer
, const char *username
);
136 bool player_delegation_active(const struct player
*pplayer
);
138 void send_delegation_info(const struct connection
*pconn
);
140 struct player
*player_by_user_delegated(const char *name
);
143 void playercolor_init(void);
144 void playercolor_free(void);
146 int playercolor_count(void);
147 void playercolor_add(struct rgbcolor
*prgbcolor
);
148 struct rgbcolor
*playercolor_get(int id
);
150 void player_set_to_ai_mode(struct player
*pplayer
,
151 enum ai_level skill_level
);
152 void player_set_under_human_control(struct player
*pplayer
);
154 #endif /* FC__PLRHAND_H */