Crossfire Server, Trunk
map.h
Go to the documentation of this file.
1 
6 /*
7  * The mapstruct is allocated each time a new map is opened.
8  * It contains pointers (very indirectly) to all objects on the map.
9  */
10 
11 #ifndef MAP_H
12 #define MAP_H
13 
14 /* We set this size - this is to make magic map work properly on
15  * tiled maps. There is no requirement that this matches the
16  * tiled maps size - it just seemed like a reasonable value.
17  * Magic map code now always starts out putting the player in the
18  * center of the map - this makes the most sense when dealing
19  * with tiled maps.
20  * We also figure out the magicmap color to use as we process the
21  * spaces - this is more efficient as we already have up to date
22  * map pointers.
23  */
24 #define MAGIC_MAP_SIZE 50
25 #define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2
26 
27 /* This correspondes to the map layers in the map2 protocol.
28  * The MAP_LAYER_... correspond to what goes on what layer -
29  * this removes the need for hardcoding, and also makes sure
30  * we don't overstep the number of layers.
31  */
32 #define MAP_LAYERS 10
33 
34 extern const char *const map_layer_name[MAP_LAYERS];
35 
40 #define MAP_LAYER_FLOOR 0
41 #define MAP_LAYER_NO_PICK1 1
42 #define MAP_LAYER_NO_PICK2 2
43 #define MAP_LAYER_ITEM1 3
44 #define MAP_LAYER_ITEM2 4
45 #define MAP_LAYER_ITEM3 5
46 #define MAP_LAYER_LIVING1 6
47 #define MAP_LAYER_LIVING2 7
48 #define MAP_LAYER_FLY1 8
49 #define MAP_LAYER_FLY2 9
51 
52 
57 #define MAP_TYPE_LEGACY 1
58 #define MAP_TYPE_DEFAULT 2
59 #define MAP_TYPE_CHOICE 3
62 #define MAP_WHEN_RESET(m) ((m)->reset_time)
63 
64 #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout)
65 #define MAP_DIFFICULTY(m) ((m)->difficulty)
66 #define MAP_TIMEOUT(m) ((m)->timeout)
67 #define MAP_SWAP_TIME(m) ((m)->swap_time)
68 #define MAP_OUTDOORS(m) ((m)->outdoor)
69 
75 #define MAP_DARKNESS(m) (m)->darkness
76 
78 #define MAP_WIDTH(m) (m)->width
79 
80 #define MAP_HEIGHT(m) (m)->height
81 
82 #define MAP_SIZE(m) map_size(m)
83 
85 #define MAP_ENTER_X(m) (m)->enter_x
86 
87 #define MAP_ENTER_Y(m) (m)->enter_y
88 
89 #define MAP_NOSMOOTH(m) (m)->nosmooth
90 
96 #define MAP_FLUSH 0x1
97 #define MAP_PLAYER_UNIQUE 0x2
98 #define MAP_NO_DIFFICULTY 0x4
99 #define MAP_STYLE 0x8
100 #define MAP_OVERLAY 0x10
102 
103 
111 #define SAVE_FLAG_SAVE_UNPAID 1
112 #define SAVE_FLAG_NO_REMOVE 2
114 
115 
121 #define SAVE_MODE_NORMAL 0
122 #define SAVE_MODE_INPLACE 1
123 #define SAVE_MODE_OVERLAY 2
125 
126 
131 #define MAP_IN_MEMORY 1
132 #define MAP_SWAPPED 2
133 #define MAP_LOADING 3
134 #define MAP_SAVING 4
136 
137 
144 #define SAVE_ERROR_OK 0
145 #define SAVE_ERROR_RCREATION -1
146 #define SAVE_ERROR_UCREATION -2
147 #define SAVE_ERROR_WRITE -3
148 #define SAVE_ERROR_NO_PATH -4
149 #define SAVE_ERROR_URENAME -5
150 #define SAVE_ERROR_CLOSE -6
151 /* -7 (no longer used) */
152 #define SAVE_ERROR_NOT_IN_MEMORY -10
153 #define SAVE_ERROR_PLAYER -11
155 
156 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should
157  * really be used, as it is multi tile aware. However, there are some cases
158  * where it is known the map is not tiled or the values are known
159  * consistent (eg, op->map, op->x, op->y)
160  */
162 #define GET_MAP_FLAGS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].flags)
163 
164 #define SET_MAP_FLAGS(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
165 
166 #define GET_MAP_LIGHT(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].light)
167 
168 #define SET_MAP_LIGHT(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].light = L)
169 #define GET_MAP_PLAYER(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].pl)
170 #define SET_MAP_PLAYER(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].pl = C)
171 
173 #define GET_MAP_OB(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].bottom)
174 
175 #define GET_MAP_TOP(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].top)
176 
178 #define SET_MAP_OB(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
179 
180 #define SET_MAP_TOP(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))
181 
183 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
184 
185 #define GET_MAP_FACE_OBJ(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
186 
190 #define GET_MAP_FACE_OBJS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
191 
193 #define GET_MAP_MOVE_BLOCK(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_block)
194 
195 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
196 
198 #define GET_MAP_MOVE_SLOW(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
199 
200 #define SET_MAP_MOVE_SLOW(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
201 
203 #define GET_MAP_MOVE_ON(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_on)
204 
205 #define SET_MAP_MOVE_ON(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
206 
208 #define GET_MAP_MOVE_OFF(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_off)
209 
210 #define SET_MAP_MOVE_OFF(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
211 
218 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
219 
227 #define P_BLOCKSVIEW 0x01
228 #define P_NO_MAGIC 0x02
230 /* AB_NO_PASS is used for arch_blocked() return value. It needs
231  * to be here to make sure the bits don't match with anything.
232  * Changed name to have AB_ prefix just to make sure no one
233  * is using the P_NO_PASS. AB_.. should only be used for
234  * arch_blocked and functions that examine the return value.
235  */
236 #define AB_NO_PASS 0x04
237 #define P_PLAYER 0x08
238 #define P_IS_ALIVE 0x10
239 #define P_NO_CLERIC 0x20
240 #define P_NEED_UPDATE 0x40
241 #define P_NO_ERROR 0x80
244 /* The following two values are not stored in the MapLook flags, but instead
245  * used in the get_map_flags value - that function is used to return
246  * the flag value, as well as other conditions - using a more general
247  * function that does more of the work can hopefully be used to replace
248  * lots of duplicate checks currently in the code.
249  */
250 #define P_OUT_OF_MAP 0x100
251 #define P_NEW_MAP 0x200
253 
254 
257 typedef struct MapSpace {
258  object *bottom;
259  object *top;
261  uint8_t flags;
262  int8_t light;
267  object *pl;
268 } MapSpace;
269 
275 typedef struct regiondef {
276  struct regiondef *next;
277  char *name;
278  char *parent_name;
285  struct regiondef *parent;
290  char *longname;
292  char *msg;
293  uint32_t counter;
294  int8_t fallback;
296  char *jailmap;
297  int16_t jailx, jaily;
298 } region;
299 
304 typedef struct shopitem {
305  const char *name;
306  const char *name_pl;
307  int typenum;
308  int8_t strength;
310  int index;
311 } shopitems;
312 
324 typedef struct mapdef {
325  struct mapdef *next;
326  char *tmpname;
327  char *name;
328  struct regiondef *region;
331  uint32_t reset_time;
332  uint32_t reset_timeout;
334  uint32_t fixed_resettime:1;
336  uint32_t unique:1;
337  uint32_t is_template:1;
338  uint32_t nosmooth:1;
339  uint32_t outdoor:1;
340  int32_t timeout;
341  int32_t swap_time;
342  uint16_t difficulty;
343  int16_t players;
344  uint32_t in_memory;
345  uint8_t darkness;
346  uint16_t width, height;
347  int16_t enter_x, enter_y;
355  struct shopitem *shopitems;
356  char *shoprace;
357  double shopgreed;
358  uint64_t shopmin;
359  uint64_t shopmax;
360  char *msg;
361  char *maplore;
362  char *tile_path[4];
363  struct mapdef *tile_map[4];
364  char path[HUGE_BUF];
367 } mapstruct;
368 
379 typedef struct rv_vector {
380  unsigned int distance;
383  int direction;
384  object *part;
385 } rv_vector;
386 
387 uint32_t map_size(mapstruct *m);
388 
389 #endif /* MAP_H */
mapdef::height
uint16_t height
Definition: map.h:346
MapSpace::move_on
MoveType move_on
Definition: map.h:265
MapSpace::light
int8_t light
Definition: map.h:262
mapdef::outdoor
uint32_t outdoor
Definition: map.h:339
mapdef::msg
char * msg
Definition: map.h:360
shopitems
struct shopitem shopitems
map_layer_name
const char *const map_layer_name[MAP_LAYERS]
Definition: map.c:55
shopitem::name_pl
const char * name_pl
Definition: map.h:306
MapSpace::move_off
MoveType move_off
Definition: map.h:266
MoveType
unsigned char MoveType
Definition: define.h:417
mapdef::nosmooth
uint32_t nosmooth
Definition: map.h:338
regiondef::jailx
int16_t jailx
Definition: map.h:297
mapdef::in_memory
uint32_t in_memory
Definition: map.h:344
mapdef::last_reset_time
long last_reset_time
Definition: map.h:365
mapdef::background_music
char * background_music
Definition: map.h:366
MAP_LAYERS
#define MAP_LAYERS
Definition: map.h:32
mapdef::tile_map
struct mapdef * tile_map[4]
Definition: map.h:363
MapSpace
struct MapSpace MapSpace
shopitem::typenum
int typenum
Definition: map.h:307
oblinkpt
Definition: object.h:454
mapdef::buttons
oblinkpt * buttons
Definition: map.h:353
rv_vector::part
object * part
Definition: map.h:384
regiondef::parent_name
char * parent_name
Definition: map.h:278
HUGE_BUF
#define HUGE_BUF
Definition: define.h:37
MapSpace::bottom
object * bottom
Definition: map.h:258
mapdef::tile_path
char * tile_path[4]
Definition: map.h:362
rv_vector::distance_y
int distance_y
Definition: map.h:382
mapdef::shopmax
uint64_t shopmax
Definition: map.h:359
regiondef::next
struct regiondef * next
Definition: map.h:276
m
static event_registration m
Definition: citylife.cpp:425
rv_vector::distance_x
int distance_x
Definition: map.h:381
mapdef::players
int16_t players
Definition: map.h:343
mapdef::shopitems
struct shopitem * shopitems
Definition: map.h:355
mapdef::maplore
char * maplore
Definition: map.h:361
mapdef::enter_y
int16_t enter_y
Definition: map.h:347
regiondef::jaily
int16_t jaily
Definition: map.h:297
MapSpace::top
object * top
Definition: map.h:259
regiondef::counter
uint32_t counter
Definition: map.h:293
mapdef::difficulty
uint16_t difficulty
Definition: map.h:342
mapdef::tmpname
char * tmpname
Definition: map.h:326
regiondef::name
char * name
Definition: map.h:277
mapdef::enter_x
int16_t enter_x
Definition: map.h:347
mapdef::darkness
uint8_t darkness
Definition: map.h:345
mapdef::shoprace
char * shoprace
Definition: map.h:356
mapdef::timeout
int32_t timeout
Definition: map.h:340
mapdef::spaces
MapSpace * spaces
Definition: map.h:354
mapdef::reset_timeout
uint32_t reset_timeout
Definition: map.h:332
MapSpace
Definition: map.h:257
mapdef
Definition: map.h:324
mapdef::name
char * name
Definition: map.h:327
mapdef::is_template
uint32_t is_template
Definition: map.h:337
mapdef::shopgreed
double shopgreed
Definition: map.h:357
MapSpace::move_block
MoveType move_block
Definition: map.h:263
mapdef::swap_time
int32_t swap_time
Definition: map.h:341
regiondef::parent
struct regiondef * parent
Definition: map.h:285
regiondef::jailmap
char * jailmap
Definition: map.h:296
shopitem::name
const char * name
Definition: map.h:305
rv_vector
struct rv_vector rv_vector
MapSpace::flags
uint8_t flags
Definition: map.h:261
rv_vector
Definition: map.h:379
shopitem::index
int index
Definition: map.h:310
mapdef::reset_time
uint32_t reset_time
Definition: map.h:331
MapSpace::pl
object * pl
Definition: map.h:267
region
struct regiondef region
regiondef::fallback
int8_t fallback
Definition: map.h:294
map_size
uint32_t map_size(mapstruct *m)
Definition: map.c:823
MapSpace::faces_obj
object * faces_obj[MAP_LAYERS]
Definition: map.h:260
mapdef::path
char path[HUGE_BUF]
Definition: map.h:364
regiondef::msg
char * msg
Definition: map.h:292
mapdef::width
uint16_t width
Definition: map.h:346
rv_vector::direction
int direction
Definition: map.h:383
regiondef::longname
char * longname
Definition: map.h:290
shopitem::strength
int8_t strength
Definition: map.h:308
mapdef::next
struct mapdef * next
Definition: map.h:325
mapdef::fixed_resettime
uint32_t fixed_resettime
Definition: map.h:334
mapdef::shopmin
uint64_t shopmin
Definition: map.h:358
mapstruct
struct mapdef mapstruct
rv_vector::distance
unsigned int distance
Definition: map.h:380
shopitem
Definition: map.h:304
MapSpace::move_slow
MoveType move_slow
Definition: map.h:264
mapdef::unique
uint32_t unique
Definition: map.h:336
mapdef::region
struct regiondef * region
Definition: map.h:328
regiondef
Definition: map.h:275