Freeciv-3.2
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_list;
19struct nation_type;
20struct player;
21struct rgbcolor;
22struct section_file;
23struct unit_list;
24
26
27struct player *server_create_player(int player_id, const char *ai_tname,
28 struct rgbcolor *prgbcolor,
30const struct rgbcolor *player_preferred_color(struct player *pplayer);
31bool player_color_changeable(const struct player *pplayer, const char **reason);
32void assign_player_colors(void);
33void server_player_set_color(struct player *pplayer,
34 const struct rgbcolor *prgbcolor);
35const char *player_color_ftstr(struct player *pplayer);
36void server_player_init(struct player *pplayer, bool initmap,
37 bool needs_team);
38void give_midgame_initial_units(struct player *pplayer, struct tile *ptile);
39void server_remove_player(struct player *pplayer);
40void kill_player(struct player *pplayer);
41void update_revolution(struct player *pplayer);
42void government_change(struct player *pplayer, struct government *gov,
44void player_loot_player(struct player *pvictor, struct player *pvictim);
45int revolution_length(struct government *gov, struct player *plr);
46void update_capital(struct player *pplayer);
47
48void player_limit_to_max_rates(struct player *pplayer);
49
50void server_player_set_name(struct player *pplayer, const char *name);
51bool server_player_set_name_full(const struct connection *caller,
52 struct player *pplayer,
53 const struct nation_type *pnation,
54 const char *name,
55 char *error_buf, size_t error_buf_len);
56
57struct nation_type *pick_a_nation(const struct nation_list *choices,
59 bool needs_startpos,
60 enum barbarian_type barb_type);
61bool nation_is_in_current_set(const struct nation_type *pnation);
62bool client_can_pick_nation(const struct nation_type *nation);
63void count_playable_nations(void);
64void send_nation_availability(struct conn_list *dest, bool nationset_change);
66
67/* Iterate over nations in the currently selected set.
68 * Does not filter on playability or anything else. */
69#define allowed_nations_iterate(pnation) \
70 nations_iterate(pnation) { \
71 if (nation_is_in_current_set(pnation)) {
72
73#define allowed_nations_iterate_end \
74 } \
75 } nations_iterate_end
76
77void check_player_max_rates(struct player *pplayer);
78void make_contact(struct player *pplayer1, struct player *pplayer2,
79 struct tile *ptile);
80void maybe_make_contact(struct tile *ptile, struct player *pplayer);
81void enter_war(struct player *pplayer, struct player *pplayer2);
82void player_update_last_war_action(struct player *pplayer);
83
84void player_info_freeze(void);
85void player_info_thaw(void);
86
87void send_player_all_c(struct player *src, struct conn_list *dest);
88void send_player_info_c(struct player *src, struct conn_list *dest);
89void send_player_diplstate_c(struct player *src, struct conn_list *dest);
90
91struct conn_list *player_reply_dest(struct player *pplayer);
92
93void shuffle_players(void);
95struct player *shuffled_player(int i);
97
98#define shuffled_players_iterate(NAME_pplayer)\
99do {\
100 int MY_i;\
101 struct player *NAME_pplayer;\
102 log_debug("shuffled_players_iterate @ %s line %d",\
103 __FILE__, __FC_LINE__);\
104 for (MY_i = 0; MY_i < player_slot_count(); MY_i++) {\
105 NAME_pplayer = shuffled_player(MY_i);\
106 if (NAME_pplayer != NULL) {\
107
108#define shuffled_players_iterate_end\
109 }\
110 }\
111} while (FALSE)
112
113#define phase_players_iterate(pplayer)\
114do {\
115 shuffled_players_iterate(pplayer) {\
116 if (is_player_phase(pplayer, game.info.phase)) {
117
118#define phase_players_iterate_end\
119 }\
120 } shuffled_players_iterate_end;\
121} while (FALSE);
122
123#define alive_phase_players_iterate(pplayer) \
124do { \
125 phase_players_iterate(pplayer) { \
126 if (pplayer->is_alive) {
127
128#define alive_phase_players_iterate_end \
129 } \
130 } phase_players_iterate_end \
131} while (FALSE);
132
133bool civil_war_possible(struct player *pplayer, bool conquering_city,
135bool civil_war_triggered(struct player *pplayer);
136struct player *civil_war(struct player *pplayer);
137
139 struct player *pplayer2,
140 const struct unit_list
142 const struct unit_list
144
145/* Player counts, total player_count() is in common/player.c */
146int barbarian_count(void);
147int normal_player_count(void);
148
149void player_status_add(struct player *plr, enum player_status status);
150bool player_status_check(struct player *plr, enum player_status status);
151void player_status_reset(struct player *plr);
152
153const char *player_delegation_get(const struct player *pplayer);
154void player_delegation_set(struct player *pplayer, const char *username);
155bool player_delegation_active(const struct player *pplayer);
156
157void send_delegation_info(const struct connection *pconn);
158
159struct player *player_by_user_delegated(const char *name);
160
161/* player colors */
162void playercolor_init(void);
163void playercolor_free(void);
164
165int playercolor_count(void);
167struct rgbcolor *playercolor_get(int id);
168
169void player_set_to_ai_mode(struct player *pplayer,
170 enum ai_level skill_level);
171void player_set_under_human_control(struct player *pplayer);
172
173void update_national_activities(struct player *pplayer, int old_gold);
174
175#endif /* FC__PLRHAND_H */
char * incite_cost
Definition comments.c:75
const char * name
Definition inputfile.c:127
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Definition plrhand.c:2641
void server_player_set_name(struct player *pplayer, const char *name)
Definition plrhand.c:2267
int barbarian_count(void)
Definition plrhand.c:3196
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1129
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1893
bool client_can_pick_nation(const struct nation_type *nation)
Definition plrhand.c:2613
const struct rgbcolor * player_preferred_color(struct player *pplayer)
Definition plrhand.c:1673
void player_update_last_war_action(struct player *pplayer)
Definition plrhand.c:865
int normal_player_count(void)
Definition plrhand.c:3204
void player_set_under_human_control(struct player *pplayer)
Definition plrhand.c:3451
void playercolor_free(void)
Definition plrhand.c:3341
bool player_status_check(struct player *plr, enum player_status status)
Definition plrhand.c:3220
void give_midgame_initial_units(struct player *pplayer, struct tile *ptile)
Definition plrhand.c:1869
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:2056
bool civil_war_triggered(struct player *pplayer)
Definition plrhand.c:2955
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Definition plrhand.c:1822
void player_set_to_ai_mode(struct player *pplayer, enum ai_level skill_level)
Definition plrhand.c:3429
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:2167
bool player_delegation_active(const struct player *pplayer)
Definition plrhand.c:3266
void player_info_thaw(void)
Definition plrhand.c:1110
void player_info_freeze(void)
Definition plrhand.c:1101
struct player * player_by_user_delegated(const char *name)
Definition plrhand.c:3317
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
Definition plrhand.c:2361
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:2452
void playercolor_init(void)
Definition plrhand.c:3332
void check_player_max_rates(struct player *pplayer)
Definition plrhand.c:776
void kill_player(struct player *pplayer)
Definition plrhand.c:126
const char * player_color_ftstr(struct player *pplayer)
Definition plrhand.c:1842
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1146
void set_shuffled_players(int *shuffled_players)
Definition plrhand.c:2402
struct player * civil_war(struct player *pplayer)
Definition plrhand.c:3005
void player_status_reset(struct player *plr)
Definition plrhand.c:3228
void send_delegation_info(const struct connection *pconn)
Definition plrhand.c:3274
void update_national_activities(struct player *pplayer, int old_gold)
Definition plrhand.c:3471
struct conn_list * player_reply_dest(struct player *pplayer)
Definition plrhand.c:1593
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:804
bool civil_war_possible(struct player *pplayer, bool conquering_city, bool honour_server_option)
Definition plrhand.c:2908
struct rgbcolor * playercolor_get(int id)
Definition plrhand.c:3370
void player_delegation_set(struct player *pplayer, const char *username)
Definition plrhand.c:3250
plr_info_level
Definition plrhand.h:25
@ INFO_MEETING
Definition plrhand.h:25
@ INFO_MINIMUM
Definition plrhand.h:25
@ INFO_EMBASSY
Definition plrhand.h:25
@ INFO_FULL
Definition plrhand.h:25
int playercolor_count(void)
Definition plrhand.c:3380
void shuffle_players(void)
Definition plrhand.c:2377
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1942
void government_change(struct player *pplayer, struct government *gov, bool revolution_finished)
Definition plrhand.c:337
void server_player_init(struct player *pplayer, bool initmap, bool needs_team)
Definition plrhand.c:1618
void make_contact(struct player *pplayer1, struct player *pplayer2, struct tile *ptile)
Definition plrhand.c:2302
void player_status_add(struct player *plr, enum player_status status)
Definition plrhand.c:3212
void playercolor_add(struct rgbcolor *prgbcolor)
Definition plrhand.c:3360
void update_capital(struct player *pplayer)
Definition plrhand.c:731
void count_playable_nations(void)
Definition plrhand.c:2598
bool player_color_changeable(const struct player *pplayer, const char **reason)
Definition plrhand.c:1716
void assign_player_colors(void)
Definition plrhand.c:1733
void send_player_diplstate_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1212
struct player * shuffled_player(int i)
Definition plrhand.c:2420
void player_loot_player(struct player *pvictor, struct player *pvictim)
Definition plrhand.c:411
const char * player_delegation_get(const struct player *pplayer)
Definition plrhand.c:3237
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2589
void enter_war(struct player *pplayer, struct player *pplayer2)
Definition plrhand.c:848
int revolution_length(struct government *gov, struct player *plr)
Definition plrhand.c:550
void fit_nationset_to_players(void)
Definition plrhand.c:2658
void reset_all_start_commands(bool plrchange)
Definition plrhand.c:2723
void update_revolution(struct player *pplayer)
Definition plrhand.c:672
enum barbarian_type barb_type
Definition nation.h:110
bv_pstatus status
Definition player.h:320
char username[MAX_LEN_NAME]
Definition player.h:250
Definition tile.h:50