Freeciv-3.3
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 != nullptr) {
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:76
const char * name
Definition inputfile.c:127
void send_nation_availability(struct conn_list *dest, bool nationset_change)
Definition plrhand.c:2647
void server_player_set_name(struct player *pplayer, const char *name)
Definition plrhand.c:2270
int barbarian_count(void)
Definition plrhand.c:3201
void send_player_all_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1131
struct player * server_create_player(int player_id, const char *ai_tname, struct rgbcolor *prgbcolor, bool allow_ai_type_fallbacking)
Definition plrhand.c:1896
bool client_can_pick_nation(const struct nation_type *nation)
Definition plrhand.c:2619
const struct rgbcolor * player_preferred_color(struct player *pplayer)
Definition plrhand.c:1675
void player_update_last_war_action(struct player *pplayer)
Definition plrhand.c:865
int normal_player_count(void)
Definition plrhand.c:3209
void player_set_under_human_control(struct player *pplayer)
Definition plrhand.c:3458
void playercolor_free(void)
Definition plrhand.c:3348
bool player_status_check(struct player *plr, enum player_status status)
Definition plrhand.c:3225
void give_midgame_initial_units(struct player *pplayer, struct tile *ptile)
Definition plrhand.c:1872
void player_limit_to_max_rates(struct player *pplayer)
Definition plrhand.c:2059
bool civil_war_triggered(struct player *pplayer)
Definition plrhand.c:2963
void server_player_set_color(struct player *pplayer, const struct rgbcolor *prgbcolor)
Definition plrhand.c:1825
void player_set_to_ai_mode(struct player *pplayer, enum ai_level skill_level)
Definition plrhand.c:3436
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:2170
bool player_delegation_active(const struct player *pplayer)
Definition plrhand.c:3271
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:3323
void maybe_make_contact(struct tile *ptile, struct player *pplayer)
Definition plrhand.c:2364
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:2458
void playercolor_init(void)
Definition plrhand.c:3338
void check_player_max_rates(struct player *pplayer)
Definition plrhand.c:776
void kill_player(struct player *pplayer)
Definition plrhand.c:125
const char * player_color_ftstr(struct player *pplayer)
Definition plrhand.c:1845
void send_player_info_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1148
void set_shuffled_players(int *shuffled_players)
Definition plrhand.c:2408
struct player * civil_war(struct player *pplayer)
Definition plrhand.c:3008
void player_status_reset(struct player *plr)
Definition plrhand.c:3233
void send_delegation_info(const struct connection *pconn)
Definition plrhand.c:3279
void update_national_activities(struct player *pplayer, int old_gold)
Definition plrhand.c:3478
struct conn_list * player_reply_dest(struct player *pplayer)
Definition plrhand.c:1595
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:2915
struct rgbcolor * playercolor_get(int id)
Definition plrhand.c:3377
void player_delegation_set(struct player *pplayer, const char *username)
Definition plrhand.c:3255
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:3387
void shuffle_players(void)
Definition plrhand.c:2383
void server_remove_player(struct player *pplayer)
Definition plrhand.c:1945
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:1620
void make_contact(struct player *pplayer1, struct player *pplayer2, struct tile *ptile)
Definition plrhand.c:2305
void player_status_add(struct player *plr, enum player_status status)
Definition plrhand.c:3217
void playercolor_add(struct rgbcolor *prgbcolor)
Definition plrhand.c:3367
void update_capital(struct player *pplayer)
Definition plrhand.c:731
void count_playable_nations(void)
Definition plrhand.c:2604
bool player_color_changeable(const struct player *pplayer, const char **reason)
Definition plrhand.c:1718
void assign_player_colors(void)
Definition plrhand.c:1736
void send_player_diplstate_c(struct player *src, struct conn_list *dest)
Definition plrhand.c:1214
struct player * shuffled_player(int i)
Definition plrhand.c:2426
void player_loot_player(struct player *pvictor, struct player *pvictim)
Definition plrhand.c:410
const char * player_delegation_get(const struct player *pplayer)
Definition plrhand.c:3242
bool nation_is_in_current_set(const struct nation_type *pnation)
Definition plrhand.c:2595
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:549
void fit_nationset_to_players(void)
Definition plrhand.c:2664
void reset_all_start_commands(bool plrchange)
Definition plrhand.c:2729
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:322
char username[MAX_LEN_NAME]
Definition player.h:252
Definition tile.h:50