Freeciv-3.1
Loading...
Searching...
No Matches
plrhand.h
Go to the documentation of this file.
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.
7
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
15
16struct connection;
17struct conn_list;
18struct nation_type;
19struct player;
20struct rgbcolor;
21struct section_file;
22struct unit_list;
23
25
26struct player *server_create_player(int player_id, const char *ai_tname,
27 struct rgbcolor *prgbcolor,
28 bool allow_ai_type_fallbacking);
29const struct rgbcolor *player_preferred_color(struct player *pplayer);
30bool player_color_changeable(const struct player *pplayer, const char **reason);
31void assign_player_colors(void);
32void server_player_set_color(struct player *pplayer,
33 const struct rgbcolor *prgbcolor);
34const char *player_color_ftstr(struct player *pplayer);
35void server_player_init(struct player *pplayer, bool initmap,
36 bool needs_team);
37void give_midgame_initial_units(struct player *pplayer, struct tile *ptile);
38void server_remove_player(struct player *pplayer);
39void kill_player(struct player *pplayer);
40void update_revolution(struct player *pplayer);
41void government_change(struct player *pplayer, struct government *gov,
42 bool revolution_finished);
43int revolution_length(struct government *gov, struct player *plr);
44void update_capital(struct player *pplayer);
45
46void player_limit_to_max_rates(struct player *pplayer);
47
48void server_player_set_name(struct player *pplayer, const char *name);
49bool server_player_set_name_full(const struct connection *caller,
50 struct player *pplayer,
51 const struct nation_type *pnation,
52 const char *name,
53 char *error_buf, size_t error_buf_len);
54
55struct nation_type *pick_a_nation(const struct nation_list *choices,
56 bool ignore_conflicts,
57 bool needs_startpos,
58 enum barbarian_type barb_type);
59bool nation_is_in_current_set(const struct nation_type *pnation);
60bool client_can_pick_nation(const struct nation_type *nation);
61void count_playable_nations(void);
62void send_nation_availability(struct conn_list *dest, bool nationset_change);
64
65/* Iterate over nations in the currently selected set.
66 * Does not filter on playability or anything else. */
67#define allowed_nations_iterate(pnation) \
68 nations_iterate(pnation) { \
69 if (nation_is_in_current_set(pnation)) {
70
71#define allowed_nations_iterate_end \
72 } \
73 } nations_iterate_end
74
75void check_player_max_rates(struct player *pplayer);
76void make_contact(struct player *pplayer1, struct player *pplayer2,
77 struct tile *ptile);
78void maybe_make_contact(struct tile *ptile, struct player *pplayer);
79void enter_war(struct player *pplayer, struct player *pplayer2);
80void player_update_last_war_action(struct player *pplayer);
81
82void player_info_freeze(void);
83void player_info_thaw(void);
84
85void send_player_all_c(struct player *src, struct conn_list *dest);
86void send_player_info_c(struct player *src, struct conn_list *dest);
87void send_player_diplstate_c(struct player *src, struct conn_list *dest);
88
89struct conn_list *player_reply_dest(struct player *pplayer);
90
91void shuffle_players(void);
92void set_shuffled_players(int *shuffled_players);
93struct player *shuffled_player(int i);
94void reset_all_start_commands(bool plrchange);
95
96#define shuffled_players_iterate(NAME_pplayer)\
97do {\
98 int MY_i;\
99 struct player *NAME_pplayer;\
100 log_debug("shuffled_players_iterate @ %s line %d",\
101 __FILE__, __FC_LINE__);\
102 for (MY_i = 0; MY_i < player_slot_count(); MY_i++) {\
103 NAME_pplayer = shuffled_player(MY_i);\
104 if (NAME_pplayer != NULL) {\
105
106#define shuffled_players_iterate_end\
107 }\
108 }\
109} while (FALSE)
110
111#define phase_players_iterate(pplayer)\
112do {\
113 shuffled_players_iterate(pplayer) {\
114 if (is_player_phase(pplayer, game.info.phase)) {
115
116#define phase_players_iterate_end\
117 }\
118 } shuffled_players_iterate_end;\
119} while (FALSE);
120
121#define alive_phase_players_iterate(pplayer) \
122do { \
123 phase_players_iterate(pplayer) { \
124 if (pplayer->is_alive) {
125
126#define alive_phase_players_iterate_end \
127 } \
128 } phase_players_iterate_end \
129} while (FALSE);
130
131bool civil_war_possible(struct player *pplayer, bool conquering_city,
132 bool honour_server_option);
133bool civil_war_triggered(struct player *pplayer);
134struct player *civil_war(struct player *pplayer);
135
137 struct player *pplayer2,
138 const struct unit_list
139 *pplayer_seen_units,
140 const struct unit_list
141 *pplayer2_seen_units);
142
143/* Player counts, total player_count() is in common/player.c */
144int barbarian_count(void);
145int normal_player_count(void);
146
147void player_status_add(struct player *plr, enum player_status status);
148bool player_status_check(struct player *plr, enum player_status status);
149void player_status_reset(struct player *plr);
150
151const char *player_delegation_get(const struct player *pplayer);
152void player_delegation_set(struct player *pplayer, const char *username);
153bool player_delegation_active(const struct player *pplayer);
154
155void send_delegation_info(const struct connection *pconn);
156
157struct player *player_by_user_delegated(const char *name);
158
159/* player colors */
160void playercolor_init(void);
161void playercolor_free(void);
162
163int playercolor_count(void);
164void playercolor_add(struct rgbcolor *prgbcolor);
165struct rgbcolor *playercolor_get(int id);
166
167void player_set_to_ai_mode(struct player *pplayer,
168 enum ai_level skill_level);
169void player_set_under_human_control(struct player *pplayer);
170
171#endif /* FC__PLRHAND_H */
const char * name
Definition inputfile.c:127
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Definition plrhand.c:2471
void server_player_set_name(struct player *pplayer, const char *name)
Definition plrhand.c:2097
int barbarian_count(void)
Definition plrhand.c:3026
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:983
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1723
bool client_can_pick_nation(const struct nation_type *nation)
Definition plrhand.c:2443
const struct rgbcolor * player_preferred_color(struct player *pplayer)
Definition plrhand.c:1503
void player_update_last_war_action(struct player *pplayer)
Definition plrhand.c:746
int normal_player_count(void)
Definition plrhand.c:3034
void player_set_under_human_control(struct player *pplayer)
Definition plrhand.c:3281
void playercolor_free(void)
Definition plrhand.c:3171
bool player_status_check(struct player *plr, enum player_status status)
Definition plrhand.c:3050
void give_midgame_initial_units(struct player *pplayer, struct tile *ptile)
Definition plrhand.c:1699
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:1886
bool civil_war_triggered(struct player *pplayer)
Definition plrhand.c:2785
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Definition plrhand.c:1652
void player_set_to_ai_mode(struct player *pplayer, enum ai_level skill_level)
Definition plrhand.c:3259
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)
Definition plrhand.c:1997
bool player_delegation_active(const struct player *pplayer)
Definition plrhand.c:3096
void player_info_thaw(void)
Definition plrhand.c:964
void player_info_freeze(void)
Definition plrhand.c:955
struct player * player_by_user_delegated(const char *name)
Definition plrhand.c:3147
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
Definition plrhand.c:2191
struct nation_type * pick_a_nation(const struct nation_list *choices, bool ignore_conflicts, bool needs_startpos, enum barbarian_type barb_type)
Definition plrhand.c:2282
void playercolor_init(void)
Definition plrhand.c:3162
void check_player_max_rates(struct player *pplayer)
Definition plrhand.c:657
void kill_player(struct player *pplayer)
Definition plrhand.c:125
const char * player_color_ftstr(struct player *pplayer)
Definition plrhand.c:1672
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1000
void set_shuffled_players(int *shuffled_players)
Definition plrhand.c:2232
struct player * civil_war(struct player *pplayer)
Definition plrhand.c:2835
void player_status_reset(struct player *plr)
Definition plrhand.c:3058
void send_delegation_info(const struct connection *pconn)
Definition plrhand.c:3104
struct conn_list * player_reply_dest(struct player *pplayer)
Definition plrhand.c:1425
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)
Definition plrhand.c:685
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Definition plrhand.c:2738
struct rgbcolor * playercolor_get(int id)
Definition plrhand.c:3200
void player_delegation_set(struct player *pplayer, const char *username)
Definition plrhand.c:3080
plr_info_level
Definition plrhand.h:24
@ INFO_MEETING
Definition plrhand.h:24
@ INFO_MINIMUM
Definition plrhand.h:24
@ INFO_EMBASSY
Definition plrhand.h:24
@ INFO_FULL
Definition plrhand.h:24
int playercolor_count(void)
Definition plrhand.c:3210
void shuffle_players(void)
Definition plrhand.c:2207
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1772
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Definition plrhand.c:336
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1450
void make_contact(struct player *pplayer1, struct player *pplayer2, struct tile *ptile)
Definition plrhand.c:2132
void player_status_add(struct player *plr, enum player_status status)
Definition plrhand.c:3042
void playercolor_add(struct rgbcolor *prgbcolor)
Definition plrhand.c:3190
void update_capital(struct player *pplayer)
Definition plrhand.c:612
void count_playable_nations(void)
Definition plrhand.c:2428
bool player_color_changeable(const struct player *pplayer, const char **reason)
Definition plrhand.c:1546
void assign_player_colors(void)
Definition plrhand.c:1563
void send_player_diplstate_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1059
struct player * shuffled_player(int i)
Definition plrhand.c:2250
const char * player_delegation_get(const struct player *pplayer)
Definition plrhand.c:3067
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2419
void enter_war(struct player *pplayer, struct player *pplayer2)
Definition plrhand.c:729
int revolution_length(struct government *gov, struct player *plr)
Definition plrhand.c:438
void fit_nationset_to_players(void)
Definition plrhand.c:2488
void reset_all_start_commands(bool plrchange)
Definition plrhand.c:2553
void update_revolution(struct player *pplayer)
Definition plrhand.c:553
enum barbarian_type barb_type
Definition nation.h:109
bv_pstatus status
Definition player.h:318
char username[MAX_LEN_NAME]
Definition player.h:252
Definition tile.h:49