~cody.smith/ubuntu/precise/freeciv/lp.202327

« back to all changes in this revision

Viewing changes to common/terrain.h

  • Committer: Package Import Robot
  • Author(s): Clint Adams, Karl Goetz, Clint Adams
  • Date: 2011-08-28 22:40:00 UTC
  • mfrom: (17.1.3 sid)
  • Revision ID: package-import@ubuntu.com-20110828224000-itma4s7fttxl4hdq
Tags: 2.3.0-1
[ Karl Goetz ]
* New upstream version.
* Fix themes_sdl_use_system_fonts.diff to apply cleanly on 2.3.0
* Massage work_around_unity_induced_breakage.diff to get it
  applying to the new codebase (The patch assumes commits made
  after 2.3.0 was tagged upstream).

[ Clint Adams ]
* Fudge build system to think there is no libtool mismatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
13
13
#ifndef FC__TERRAIN_H
14
14
#define FC__TERRAIN_H
15
15
 
 
16
/* utility */
 
17
#include "bitvector.h"
16
18
#include "shared.h"
17
19
 
 
20
/* common */
18
21
#include "fc_types.h"
19
 
 
 
22
#include "name_translation.h"
20
23
#include "unittype.h"
21
24
 
22
25
struct base_type;
 
26
struct strvec;          /* Actually defined in "utility/string_vector.h". */
23
27
 
24
28
enum special_river_move {
25
29
  RMV_NORMAL = 0,
94
98
/* Reflect reality; but theoretically could be larger than terrains! */
95
99
#define MAX_NUM_RESOURCES (MAX_NUM_TERRAINS/2)
96
100
 
97
 
enum terrain_class {
98
 
  TC_LAND,
99
 
  TC_OCEAN,
100
 
  TC_LAST
101
 
};
102
 
 
103
 
/* Must match with find_terrain_flag_by_rule_name in terrain.c. */
104
 
enum terrain_flag_id {
105
 
  TER_NO_BARBS, /* No barbarians summoned on this terrain. */
106
 
  TER_NO_POLLUTION, /* This terrain cannot be polluted. */
107
 
  TER_NO_CITIES, /* No cities on this terrain. */
108
 
  TER_STARTER, /* Players will start on this terrain type. */
109
 
  TER_CAN_HAVE_RIVER, /* Terrains with this type can have S_RIVER on them. */
110
 
  TER_UNSAFE_COAST,/*this tile is not safe as coast, (all ocean / ice) */ 
111
 
  TER_OCEANIC,     /* This is an water terrain. */
112
 
  TER_FRESHWATER,  /* Fresh water terrain */
113
 
  TER_LAST
114
 
};
115
 
#define TER_FIRST (TER_NO_BARBS)
116
 
#define TER_COUNT (TER_LAST)
117
 
#define TER_MAX 64 /* Changing this breaks network compatability. */
118
 
 
119
 
BV_DEFINE(bv_terrain_flags, TER_MAX);
120
 
 
121
 
enum mapgen_terrain_property {
122
 
  MG_MOUNTAINOUS,
123
 
  MG_GREEN,
124
 
  MG_FOLIAGE,
125
 
 
126
 
  MG_TROPICAL,
127
 
  MG_TEMPERATE,
128
 
  MG_COLD,
129
 
  MG_FROZEN,
130
 
 
131
 
  MG_WET,
132
 
  MG_DRY,
133
 
 
134
 
  MG_OCEAN_DEPTH,
135
 
 
136
 
  MG_LAST
137
 
};
 
101
#define SPECENUM_NAME terrain_class
 
102
#define SPECENUM_VALUE0 TC_LAND
 
103
/* TRANS: terrain class: used adjectivally */
 
104
#define SPECENUM_VALUE0NAME N_("Land")
 
105
#define SPECENUM_VALUE1 TC_OCEAN
 
106
/* TRANS: terrain class: used adjectivally */
 
107
#define SPECENUM_VALUE1NAME N_("Oceanic")
 
108
#include "specenum_gen.h"
138
109
 
139
110
/* Types of alterations available to terrain.
140
111
 * This enum is only used in the effects system; the relevant information
141
112
 * is encoded in other members of the terrain structure. */
142
 
enum terrain_alteration {
143
 
  TA_CAN_IRRIGATE,      /* Can build irrigation without changing terrain */
144
 
  TA_CAN_MINE,          /* Can build mine without changing terrain */
145
 
  TA_CAN_ROAD,          /* Can build roads and/or railroads */
146
 
  TA_LAST
147
 
};
 
113
#define SPECENUM_NAME terrain_alteration
 
114
/* Can build irrigation without changing terrain */
 
115
#define SPECENUM_VALUE0 TA_CAN_IRRIGATE
 
116
#define SPECENUM_VALUE0NAME "CanIrrigate"
 
117
/* Can build mine without changing terrain */
 
118
#define SPECENUM_VALUE1 TA_CAN_MINE
 
119
#define SPECENUM_VALUE1NAME "CanMine"
 
120
/* Can build roads and/or railroads */
 
121
#define SPECENUM_VALUE2 TA_CAN_ROAD
 
122
#define SPECENUM_VALUE2NAME "CanRoad"
 
123
#include "specenum_gen.h"
 
124
 
 
125
#define SPECENUM_NAME terrain_flag_id
 
126
/* No barbarians summoned on this terrain. */
 
127
#define SPECENUM_VALUE0 TER_NO_BARBS
 
128
#define SPECENUM_VALUE0NAME "NoBarbs"
 
129
/* This terrain cannot be polluted. */
 
130
#define SPECENUM_VALUE1 TER_NO_POLLUTION
 
131
#define SPECENUM_VALUE1NAME "NoPollution"
 
132
/* No cities on this terrain. */
 
133
#define SPECENUM_VALUE2 TER_NO_CITIES
 
134
#define SPECENUM_VALUE2NAME "NoCities"
 
135
/* Players will start on this terrain type. */
 
136
#define SPECENUM_VALUE3 TER_STARTER
 
137
#define SPECENUM_VALUE3NAME "Starter"
 
138
/* Terrains with this type can have S_RIVER on them. */
 
139
#define SPECENUM_VALUE4 TER_CAN_HAVE_RIVER
 
140
#define SPECENUM_VALUE4NAME "CanHaveRiver"
 
141
/*this tile is not safe as coast, (all ocean / ice) */
 
142
#define SPECENUM_VALUE5 TER_UNSAFE_COAST
 
143
#define SPECENUM_VALUE5NAME "UnsafeCoast"
 
144
/* This is an water terrain. */
 
145
#define SPECENUM_VALUE6 TER_OCEANIC
 
146
#define SPECENUM_VALUE6NAME "Oceanic"
 
147
/* Fresh water terrain */
 
148
#define SPECENUM_VALUE7 TER_FRESHWATER
 
149
#define SPECENUM_VALUE7NAME "FreshWater"
 
150
#include "specenum_gen.h"
 
151
 
 
152
#define TER_MAX 64 /* Changing this breaks network compatability. */
 
153
 
 
154
BV_DEFINE(bv_terrain_flags, TER_MAX);
 
155
 
 
156
#define SPECENUM_NAME mapgen_terrain_property
 
157
#define SPECENUM_VALUE0 MG_MOUNTAINOUS
 
158
#define SPECENUM_VALUE0NAME "mountainous"
 
159
#define SPECENUM_VALUE1 MG_GREEN
 
160
#define SPECENUM_VALUE1NAME "green"
 
161
#define SPECENUM_VALUE2 MG_FOLIAGE
 
162
#define SPECENUM_VALUE2NAME "foliage"
 
163
#define SPECENUM_VALUE3 MG_TROPICAL
 
164
#define SPECENUM_VALUE3NAME "tropical"
 
165
#define SPECENUM_VALUE4 MG_TEMPERATE
 
166
#define SPECENUM_VALUE4NAME "temperate"
 
167
#define SPECENUM_VALUE5 MG_COLD
 
168
#define SPECENUM_VALUE5NAME "cold"
 
169
#define SPECENUM_VALUE6 MG_FROZEN
 
170
#define SPECENUM_VALUE6NAME "frozen"
 
171
#define SPECENUM_VALUE7 MG_WET
 
172
#define SPECENUM_VALUE7NAME "wet"
 
173
#define SPECENUM_VALUE8 MG_DRY
 
174
#define SPECENUM_VALUE8NAME "dry"
 
175
#define SPECENUM_VALUE9 MG_OCEAN_DEPTH
 
176
#define SPECENUM_VALUE9NAME "ocean_depth"
 
177
#define SPECENUM_COUNT MG_COUNT
 
178
#include "specenum_gen.h"
148
179
 
149
180
/*
150
181
 * This struct gives data about each terrain type.  There are many ways
198
229
   * Ocean_depth is different.  Instead of a percentage, the depth of the
199
230
   * tile in the range 0 (never chosen) to 100 (deepest) is used.
200
231
   */
201
 
  int property[MG_LAST];
 
232
  int property[MG_COUNT];
202
233
#define TERRAIN_OCEAN_DEPTH_MINIMUM (1)
203
234
#define TERRAIN_OCEAN_DEPTH_MAXIMUM (100)
204
235
 
206
237
 
207
238
  bv_terrain_flags flags;
208
239
 
209
 
  char *helptext;
 
240
  struct strvec *helptext;
210
241
};
211
242
 
212
243
/* General terrain accessor functions. */
216
247
 
217
248
struct terrain *terrain_by_number(const Terrain_type_id type);
218
249
 
219
 
struct terrain *find_terrain_by_identifier(const char identifier);
220
 
struct terrain *find_terrain_by_rule_name(const char *name);
221
 
struct terrain *find_terrain_by_translated_name(const char *name);
 
250
struct terrain *terrain_by_identifier(const char identifier);
 
251
struct terrain *terrain_by_rule_name(const char *name);
 
252
struct terrain *terrain_by_translated_name(const char *name);
222
253
struct terrain *rand_terrain_by_flag(enum terrain_flag_id flag);
223
254
 
224
255
char terrain_identifier(const struct terrain *pterrain);
225
256
const char *terrain_rule_name(const struct terrain *pterrain);
226
 
const char *terrain_name_translation(struct terrain *pterrain);
 
257
const char *terrain_name_translation(const struct terrain *pterrain);
227
258
 
228
259
/* Functions to operate on a terrain flag. */
229
 
enum terrain_flag_id find_terrain_flag_by_rule_name(const char *s);
230
260
#define terrain_has_flag(terr, flag) BV_ISSET((terr)->flags, flag)
231
261
 
232
262
int terrains_by_flag(enum terrain_flag_id flag, struct terrain **buffer, int bufsize);
267
297
Resource_type_id resource_number(const struct resource *presource);
268
298
 
269
299
struct resource *resource_by_number(const Resource_type_id id);
270
 
struct resource *find_resource_by_identifier(const char identifier);
271
 
struct resource *find_resource_by_rule_name(const char *name);
 
300
struct resource *resource_by_identifier(const char identifier);
 
301
struct resource *resource_by_rule_name(const char *name);
272
302
 
273
303
const char *resource_rule_name(const struct resource *presource);
274
 
const char *resource_name_translation(struct resource *presource);
 
304
const char *resource_name_translation(const struct resource *presource);
275
305
 
276
306
/* General special accessor functions. */
277
 
enum tile_special_type find_special_by_rule_name(const char *name);
 
307
enum tile_special_type special_by_rule_name(const char *name);
278
308
const char *special_rule_name(enum tile_special_type type);
279
309
const char *special_name_translation(enum tile_special_type type);
280
310
 
305
335
                            enum tile_special_type spe);
306
336
 
307
337
/* Functions to operate on a terrain class. */
308
 
enum terrain_class find_terrain_class_by_rule_name(const char *name);
309
 
const char *terrain_class_rule_name(enum terrain_class tclass);
310
338
const char *terrain_class_name_translation(enum terrain_class tclass);
311
339
 
312
340
bool terrain_belongs_to_class(const struct terrain *pterrain,
314
342
bool is_terrain_class_near_tile(const struct tile *ptile, enum terrain_class tclass);
315
343
 
316
344
/* Functions to deal with possible terrain alterations. */
317
 
enum terrain_alteration find_terrain_alteration_by_rule_name(const char *name);
318
 
const char *terrain_alteration_rule_name(enum terrain_alteration talter);
319
345
const char *terrain_alteration_name_translation(enum terrain_alteration talter);
320
346
bool terrain_can_support_alteration(const struct terrain *pterrain,
321
347
                                    enum terrain_alteration talter);