Prevented building advisor from randomly building, and thus potentially just moving...
[freeciv.git] / server / plrhand.h
blob7e339da3b0e28314b19302f0404cbfe29a73fff3
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)
6 any later version.
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 ***********************************************************************/
13 #ifndef FC__PLRHAND_H
14 #define FC__PLRHAND_H
16 struct connection;
17 struct conn_list;
18 struct nation_type;
19 struct player;
20 struct rgbcolor;
21 struct section_file;
22 struct unit_list;
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_tname,
27 struct rgbcolor *prgbcolor,
28 bool allow_ai_type_fallbacking);
29 const struct rgbcolor *player_preferred_color(struct player *pplayer);
30 bool player_color_changeable(const struct player *pplayer, const char **reason);
31 void assign_player_colors(void);
32 void server_player_set_color(struct player *pplayer,
33 const struct rgbcolor *prgbcolor);
34 const char *player_color_ftstr(struct player *pplayer);
35 void server_player_init(struct player *pplayer, bool initmap,
36 bool needs_team);
37 void give_midgame_initial_units(struct player *pplayer, struct tile *ptile);
38 void server_remove_player(struct player *pplayer);
39 void kill_player(struct player *pplayer);
40 void update_revolution(struct player *pplayer);
41 void government_change(struct player *pplayer, struct government *gov,
42 bool revolution_finished);
43 int revolution_length(struct government *gov, struct player *plr);
45 struct player_economic player_limit_to_max_rates(struct player *pplayer);
47 void server_player_set_name(struct player *pplayer, const char *name);
48 bool server_player_set_name_full(const struct connection *caller,
49 struct player *pplayer,
50 const struct nation_type *pnation,
51 const char *name,
52 char *error_buf, size_t error_buf_len);
54 struct nation_type *pick_a_nation(const struct nation_list *choices,
55 bool ignore_conflicts,
56 bool needs_startpos,
57 enum barbarian_type barb_type);
58 bool nation_is_in_current_set(const struct nation_type *pnation);
59 bool client_can_pick_nation(const struct nation_type *nation);
60 void count_playable_nations(void);
61 void send_nation_availability(struct conn_list *dest, bool nationset_change);
62 void fit_nationset_to_players(void);
64 /* Iterate over nations in the currently selected set.
65 * Does not filter on playability or anything else. */
66 #define allowed_nations_iterate(pnation) \
67 nations_iterate(pnation) { \
68 if (nation_is_in_current_set(pnation)) {
70 #define allowed_nations_iterate_end \
71 } \
72 } nations_iterate_end
74 void check_player_max_rates(struct player *pplayer);
75 void make_contact(struct player *pplayer1, struct player *pplayer2,
76 struct tile *ptile);
77 void maybe_make_contact(struct tile *ptile, struct player *pplayer);
78 void enter_war(struct player *pplayer, struct player *pplayer2);
80 void player_info_freeze(void);
81 void player_info_thaw(void);
83 void send_player_all_c(struct player *src, struct conn_list *dest);
84 void send_player_info_c(struct player *src, struct conn_list *dest);
85 void send_player_diplstate_c(struct player *src, struct conn_list *dest);
87 struct conn_list *player_reply_dest(struct player *pplayer);
89 void shuffle_players(void);
90 void set_shuffled_players(int *shuffled_players);
91 struct player *shuffled_player(int i);
92 void reset_all_start_commands(bool plrchange);
94 #define shuffled_players_iterate(NAME_pplayer)\
95 do {\
96 int MY_i;\
97 struct player *NAME_pplayer;\
98 log_debug("shuffled_players_iterate @ %s line %d",\
99 __FILE__, __FC_LINE__);\
100 for (MY_i = 0; MY_i < player_slot_count(); MY_i++) {\
101 NAME_pplayer = shuffled_player(MY_i);\
102 if (NAME_pplayer != NULL) {\
104 #define shuffled_players_iterate_end\
107 } while (0)
109 #define phase_players_iterate(pplayer)\
110 do {\
111 shuffled_players_iterate(pplayer) {\
112 if (is_player_phase(pplayer, game.info.phase)) {
114 #define phase_players_iterate_end\
116 } shuffled_players_iterate_end;\
117 } while (FALSE);
119 #define alive_phase_players_iterate(pplayer) \
120 do { \
121 phase_players_iterate(pplayer) { \
122 if (pplayer->is_alive) {
124 #define alive_phase_players_iterate_end \
126 } phase_players_iterate_end \
127 } while (FALSE);
129 bool civil_war_possible(struct player *pplayer, bool conquering_city,
130 bool honour_server_option);
131 bool civil_war_triggered(struct player *pplayer);
132 struct player *civil_war(struct player *pplayer);
134 void update_players_after_alliance_breakup(struct player *pplayer,
135 struct player *pplayer2,
136 const struct unit_list
137 *pplayer_seen_units,
138 const struct unit_list
139 *pplayer2_seen_units);
141 /* Player counts, total player_count() is in common/player.c */
142 int barbarian_count(void);
143 int normal_player_count(void);
145 void player_status_add(struct player *plr, enum player_status status);
146 bool player_status_check(struct player *plr, enum player_status status);
147 void player_status_reset(struct player *plr);
149 const char *player_delegation_get(const struct player *pplayer);
150 void player_delegation_set(struct player *pplayer, const char *username);
151 bool player_delegation_active(const struct player *pplayer);
153 void send_delegation_info(const struct connection *pconn);
155 struct player *player_by_user_delegated(const char *name);
157 /* player colors */
158 void playercolor_init(void);
159 void playercolor_free(void);
161 int playercolor_count(void);
162 void playercolor_add(struct rgbcolor *prgbcolor);
163 struct rgbcolor *playercolor_get(int id);
165 void player_set_to_ai_mode(struct player *pplayer,
166 enum ai_level skill_level);
167 void player_set_under_human_control(struct player *pplayer);
169 #endif /* FC__PLRHAND_H */