~ubuntu-branches/debian/sid/freeciv/sid

« back to all changes in this revision

Viewing changes to common/player.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2010-02-23 22:09:02 UTC
  • mfrom: (7.1.5 sid)
  • Revision ID: james.westby@ubuntu.com-20100223220902-s3spqi1x4e190y0t
[ Karl Goetz ]
* Remove civserver files in /etc/ggzd/ (Closes: 523772, 517787)
* Adding ${misc:Depends} to all binary packages (lintian warnings)

[ Clint Adams ]
* New upstream version.
  - Drop data_dsc_use_bindir.diff (binary pathnames have changed).

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 
18
18
#include "city.h"
19
19
#include "connection.h"
20
 
#include "improvement.h"        /* Impr_Status */
21
20
#include "nation.h"
22
21
#include "shared.h"
23
22
#include "spaceship.h"
24
23
#include "tech.h"
25
 
#include "unit.h"
 
24
#include "unitlist.h"
 
25
#include "vision.h"
26
26
 
27
27
#define PLAYER_DEFAULT_TAX_RATE 0
28
28
#define PLAYER_DEFAULT_SCIENCE_RATE 100
31
31
#define ANON_PLAYER_NAME "noname"
32
32
#define ANON_USER_NAME "Unassigned"
33
33
 
34
 
/*
35
 
 * pplayer->ai.barbarian_type uses this enum. Note that the values
36
 
 * have to stay since they are used in savegames.
37
 
 */
38
 
enum barbarian_type {
39
 
  NOT_A_BARBARIAN = 0,
40
 
  LAND_BARBARIAN = 1,
41
 
  SEA_BARBARIAN = 2
42
 
};
43
 
 
44
34
enum handicap_type {
45
 
  H_NONE = 0,         /* No handicaps */
46
 
  H_DIPLOMAT = 1,     /* Can't build offensive diplomats */
47
 
  H_AWAY = 2,         /* Away mode */
48
 
  H_LIMITEDHUTS = 4,  /* Can get only 25 gold and barbs from huts */
49
 
  H_DEFENSIVE = 8,    /* Build defensive buildings without calculating need */
50
 
  H_EXPERIMENTAL = 16,/* Enable experimental AI features (for testing) */
51
 
  H_RATES = 32,       /* Can't set its rates beyond government limits */
52
 
  H_TARGETS = 64,     /* Can't target anything it doesn't know exists */
53
 
  H_HUTS = 128,       /* Doesn't know which unseen tiles have huts on them */
54
 
  H_FOG = 256,        /* Can't see through fog of war */
55
 
  H_NOPLANES = 512,   /* Doesn't build air units */
56
 
  H_MAP = 1024,       /* Only knows map_is_known tiles */
57
 
  H_DIPLOMACY = 2048, /* Not very good at diplomacy */
58
 
  H_REVOLUTION = 4096, /* Cannot skip anarchy */
59
 
  H_EXPANSION = 8192, /* Don't like being much larger than human */
60
 
  H_DANGER = 16384    /* Always thinks its city is in danger */
 
35
  H_DIPLOMAT = 0,     /* Can't build offensive diplomats */
 
36
  H_AWAY,             /* Away mode */
 
37
  H_LIMITEDHUTS,      /* Can get only 25 gold and barbs from huts */
 
38
  H_DEFENSIVE,        /* Build defensive buildings without calculating need */
 
39
  H_EXPERIMENTAL,     /* Enable experimental AI features (for testing) */
 
40
  H_RATES,            /* Can't set its rates beyond government limits */
 
41
  H_TARGETS,          /* Can't target anything it doesn't know exists */
 
42
  H_HUTS,             /* Doesn't know which unseen tiles have huts on them */
 
43
  H_FOG,              /* Can't see through fog of war */
 
44
  H_NOPLANES,         /* Doesn't build air units */
 
45
  H_MAP,              /* Only knows map_is_known tiles */
 
46
  H_DIPLOMACY,        /* Not very good at diplomacy */
 
47
  H_REVOLUTION,       /* Cannot skip anarchy */
 
48
  H_EXPANSION,        /* Don't like being much larger than human */
 
49
  H_DANGER,           /* Always thinks its city is in danger */
 
50
  H_LAST
61
51
};
62
52
 
63
53
BV_DEFINE(bv_player, MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS);
64
54
 
 
55
BV_DEFINE(bv_handicap, H_LAST);
 
56
 
65
57
struct player_economic {
66
58
  int gold;
67
59
  int tax;
104
96
  int est_upkeep; /* estimated upkeep of buildings in cities */
105
97
  /* The units of tech_want seem to be shields */
106
98
  int tech_want[A_LAST+1];
107
 
  int handicap;                 /* sum of enum handicap_type */
108
 
  int skill_level;              /* 0-10 value for save/load/display */
 
99
  bv_handicap handicaps;        /* sum of enum handicap_type */
 
100
  enum ai_level skill_level;    /* 0-10 value for save/load/display */
109
101
  int fuzzy;                    /* chance in 1000 to mis-decide */
110
102
  int expand;                   /* percentage factor to value new cities */
111
103
  int science_cost;             /* Cost in bulbs to get new tech, relative
163
155
#define MAX_ATTRIBUTE_BLOCK     (256*1024)      /* largest attribute block */
164
156
};
165
157
 
 
158
struct ai_type;
 
159
 
166
160
struct player {
167
 
  int player_no;
 
161
  bool used;
168
162
  char name[MAX_LEN_NAME];
169
163
  char username[MAX_LEN_NAME];
170
164
  char ranked_username[MAX_LEN_NAME]; /* the user who will be ranked */
179
173
  int nturns_idle;
180
174
  bool is_alive;
181
175
  bool is_dying; /* set once the player is in the process of dying */
 
176
  bool is_winner; /* This player is winner in scenario game */
182
177
  bool surrendered; /* has indicated willingness to surrender */
183
178
 
184
179
  /* Turn in which the player's revolution is over; see update_revolution. */
185
180
  int revolution_finishes;
186
181
 
187
182
  bool capital; /* used to give player init_buildings in first city. */
188
 
  bv_player embassy;
 
183
  bv_player real_embassy;
189
184
  struct player_diplstate diplstates[MAX_NUM_PLAYERS + MAX_NUM_BARBARIANS];
190
185
  int city_style;
 
186
  struct city_list *cities;
191
187
  struct unit_list *units;
192
 
  struct city_list *cities;
193
188
  struct player_score score;
194
189
  struct player_economic economic;
195
190
 
196
191
  int bulbs_last_turn;    /* # bulbs researched last turn only */
197
192
  struct player_spaceship spaceship;
198
 
  struct player_ai ai;
 
193
  struct player_ai ai_data;
 
194
  struct ai_type *ai;
199
195
  bool was_created;                    /* if the player was /created */
200
196
  bool is_connected;
201
197
  struct connection *current_conn;     /* non-null while handling packet */
202
198
  struct conn_list *connections;       /* will replace conn */
203
 
  struct worklist worklists[MAX_NUM_WORKLISTS];
204
199
  struct player_tile *private_map;
205
200
  unsigned int gives_shared_vision; /* bitvector those that give you shared vision */
206
201
  unsigned int really_gives_vision; /* takes into account that p3 may see what p1 has via p2 */
207
 
  int small_wonders[B_LAST];              /* contains city id's */
208
 
         /* wonders[] may also be (-1), or the id of a city
209
 
            which no longer exists, if the wonder has been destroyed */
210
 
 
 
202
  int wonders[B_LAST];              /* contains city id's or WONDER_NOT_BUILT */
211
203
  struct attribute_block_s attribute_block;
212
204
  struct attribute_block_s attribute_block_buffer;
213
205
  bv_debug debug;
214
206
};
215
207
 
 
208
/* A slot is a possibly uninitialized player. */
 
209
int player_slot_count(void);
 
210
bool player_slot_is_used(const struct player *pslot);
 
211
void player_slot_set_used(struct player *pslot, bool used);
 
212
struct player *player_slot_by_number(int player_id);
 
213
 
216
214
/* General player accessor functions. */
217
215
int player_count(void);
 
216
void set_player_count(int count);
 
217
 
218
218
int player_index(const struct player *pplayer);
219
219
int player_number(const struct player *pplayer);
220
220
 
229
229
 
230
230
bool player_set_nation(struct player *pplayer, struct nation_type *pnation);
231
231
void player_set_unit_focus_status(struct player *pplayer);
 
232
 
232
233
bool player_has_embassy(const struct player *pplayer,
233
 
                        const struct player *pplayer2);
 
234
                        const struct player *pplayer2);
 
235
bool player_has_real_embassy(const struct player *pplayer,
 
236
                             const struct player *pplayer2);
 
237
bool player_has_embassy_from_effect(const struct player *pplayer,
 
238
                                    const struct player *pplayer2);
234
239
 
235
240
bool can_player_see_unit(const struct player *pplayer,
236
241
                         const struct unit *punit);
303
308
 
304
309
struct player_research *get_player_research(const struct player *p1);
305
310
 
 
311
void player_set_winner(struct player *plr);
 
312
 
306
313
/* Initialization and iteration */
307
314
void player_init(struct player *plr);
308
315
 
309
 
#define players_iterate(PI_player)                                            \
310
 
{                                                                             \
311
 
  struct player *PI_player;                                                   \
312
 
  int PI_p_itr;                                                               \
313
 
  for (PI_p_itr = 0; PI_p_itr < game.info.nplayers; PI_p_itr++) {            \
314
 
    PI_player = get_player(PI_p_itr);
315
 
 
316
 
#define players_iterate_end                                                   \
317
 
  }                                                                           \
318
 
}
 
316
#define player_slots_iterate(NAME_pslot)\
 
317
do {\
 
318
  struct player *NAME_pslot;\
 
319
  int MY_i;\
 
320
  for (MY_i = 0; MY_i < player_slot_count(); MY_i++) {\
 
321
    NAME_pslot = player_slot_by_number(MY_i);\
 
322
    if (NAME_pslot != NULL) {\
 
323
 
 
324
#define player_slots_iterate_end\
 
325
    }\
 
326
  }\
 
327
} while (0)
 
328
 
 
329
/* NB!!! This will only iterate over players for
 
330
 * which player_slot_is_used() returns TRUE. */
 
331
#define players_iterate(NAME_pplayer)\
 
332
do {\
 
333
  player_slots_iterate(NAME_pplayer) {\
 
334
    if (player_slot_is_used(NAME_pplayer)) {
 
335
 
 
336
#define players_iterate_end\
 
337
    }\
 
338
  } player_slots_iterate_end;\
 
339
} while (0)
319
340
 
320
341
/* ai love values should be in range [-MAX_AI_LOVE..MAX_AI_LOVE] */
321
342
#define MAX_AI_LOVE 1000
324
345
/* User functions. */
325
346
bool is_valid_username(const char *name);
326
347
 
 
348
enum ai_level find_ai_level_by_name(const char *name);
 
349
const char *ai_level_name(enum ai_level level);
 
350
const char *ai_level_cmd(enum ai_level level);
 
351
bool is_settable_ai_level(enum ai_level level);
 
352
int number_of_ai_levels(void);
327
353
 
328
354
#endif  /* FC__PLAYER_H */