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_OUTDOORS(m) ((m)->outdoor)
68 
70 #define MAP_DARKNESS(m) (m)->darkness
71 
73 #define MAP_WIDTH(m) (m)->width
74 
75 #define MAP_HEIGHT(m) (m)->height
76 
77 #define MAP_SIZE(m) map_size(m)
78 
80 #define MAP_ENTER_X(m) (m)->enter_x
81 
82 #define MAP_ENTER_Y(m) (m)->enter_y
83 
84 #define MAP_NOSMOOTH(m) (m)->nosmooth
85 
91 #define MAP_FLUSH 0x1
92 #define MAP_PLAYER_UNIQUE 0x2
93 #define MAP_NO_DIFFICULTY 0x4
94 #define MAP_STYLE 0x8
95 #define MAP_OVERLAY 0x10
97 
98 
106 #define SAVE_FLAG_SAVE_UNPAID 1
107 #define SAVE_FLAG_NO_REMOVE 2
109 
110 
116 #define SAVE_MODE_NORMAL 0
117 #define SAVE_MODE_INPLACE 1
118 #define SAVE_MODE_OVERLAY 2
120 
121 
126 #define MAP_IN_MEMORY 1
127 #define MAP_SWAPPED 2
128 #define MAP_LOADING 3
129 #define MAP_SAVING 4
131 
132 
139 #define SAVE_ERROR_OK 0
140 #define SAVE_ERROR_RCREATION -1
141 #define SAVE_ERROR_UCREATION -2
142 #define SAVE_ERROR_WRITE -3
143 #define SAVE_ERROR_NO_PATH -4
144 #define SAVE_ERROR_URENAME -5
145 #define SAVE_ERROR_CLOSE -6
146 /* -7 (no longer used) */
147 #define SAVE_ERROR_NOT_IN_MEMORY -10
148 #define SAVE_ERROR_PLAYER -11
150 
151 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should
152  * really be used, as it is multi tile aware. However, there are some cases
153  * where it is known the map is not tiled or the values are known
154  * consistent (eg, op->map, op->x, op->y)
155  */
157 #define GET_MAP_FLAGS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].flags)
158 
159 #define SET_MAP_FLAGS(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
160 
162 #define GET_MAP_LIGHT(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].light)
163 
164 #define SET_MAP_LIGHT(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].light = L)
165 
166 #define GET_MAP_PLAYER(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].pl)
167 #define SET_MAP_PLAYER(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].pl = C)
168 
170 #define GET_MAP_OB(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].bottom)
171 
172 #define GET_MAP_TOP(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].top)
173 
175 #define SET_MAP_OB(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
176 
177 #define SET_MAP_TOP(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))
178 
180 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
181 
182 #define GET_MAP_FACE_OBJ(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
183 
187 #define GET_MAP_FACE_OBJS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
188 
190 #define GET_MAP_MOVE_BLOCK(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_block)
191 
192 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
193 
195 #define GET_MAP_MOVE_SLOW(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
196 
197 #define SET_MAP_MOVE_SLOW(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
198 
200 #define GET_MAP_MOVE_ON(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_on)
201 
202 #define SET_MAP_MOVE_ON(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
203 
205 #define GET_MAP_MOVE_OFF(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_off)
206 
207 #define SET_MAP_MOVE_OFF(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
208 
215 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
216 
224 #define P_BLOCKSVIEW 0x01
225 #define P_NO_MAGIC 0x02
227 /* AB_NO_PASS is used for arch_blocked() return value. It needs
228  * to be here to make sure the bits don't match with anything.
229  * Changed name to have AB_ prefix just to make sure no one
230  * is using the P_NO_PASS. AB_.. should only be used for
231  * arch_blocked and functions that examine the return value.
232  */
233 #define AB_NO_PASS 0x04
234 #define P_PLAYER 0x08
235 #define P_IS_ALIVE 0x10
236 #define P_NO_CLERIC 0x20
237 #define P_NEED_UPDATE 0x40
238 #define P_NO_ERROR 0x80
241 /* The following two values are not stored in the MapLook flags, but instead
242  * used in the get_map_flags value - that function is used to return
243  * the flag value, as well as other conditions - using a more general
244  * function that does more of the work can hopefully be used to replace
245  * lots of duplicate checks currently in the code.
246  */
247 #define P_OUT_OF_MAP 0x100
248 #define P_NEW_MAP 0x200
250 
251 
254 struct MapSpace {
255  object *bottom;
256  object *top;
258  uint8_t flags;
259  int8_t light;
264  object *pl;
265 };
266 
272 struct region {
273  char *name;
279  char *longname;
281  char *msg;
282  uint32_t counter;
283  int8_t fallback;
285  char *jailmap;
286  int16_t jailx, jaily;
287 };
288 
293 struct shopitems {
294  const char *name;
295  const char *name_pl;
296  int typenum;
297  int8_t strength;
299  int index;
300 };
301 
313 struct mapstruct {
315  char *tmpname;
316  char *name;
317  struct region *region;
320  uint32_t reset_time;
321  uint32_t reset_timeout;
323  uint32_t fixed_resettime:1;
326  uint32_t unique:1;
327  uint32_t is_template:1;
328  uint32_t nosmooth:1;
329  uint32_t outdoor:1;
330  int32_t timeout;
331  uint16_t difficulty;
332  int16_t players;
333  uint32_t in_memory;
334  uint8_t darkness;
335  uint16_t width, height;
336  int16_t enter_x, enter_y;
345  char *shoprace;
346  double shopgreed;
347  uint64_t shopmin;
348  uint64_t shopmax;
349  char *msg;
350  char *maplore;
351  char *tile_path[4];
353  char path[HUGE_BUF];
356 };
357 
368 struct rv_vector {
369  unsigned int distance;
372  int direction;
373  object *part;
374 };
375 
376 uint32_t map_size(mapstruct *m);
377 
378 #endif /* MAP_H */
mapstruct::shopgreed
double shopgreed
Definition: map.h:346
mapstruct::tile_path
char * tile_path[4]
Definition: map.h:351
MapSpace::move_on
MoveType move_on
Definition: map.h:262
shopitems::strength
int8_t strength
Definition: map.h:297
mapstruct::region
struct region * region
Definition: map.h:317
MapSpace::light
int8_t light
Definition: map.h:259
mapstruct::difficulty
uint16_t difficulty
Definition: map.h:331
region::fallback
int8_t fallback
Definition: map.h:283
mapstruct::outdoor
uint32_t outdoor
Definition: map.h:329
map_layer_name
const char *const map_layer_name[MAP_LAYERS]
Definition: map.cpp:46
mapstruct::shopmin
uint64_t shopmin
Definition: map.h:347
mapstruct::buttons
oblinkpt * buttons
Definition: map.h:342
mapstruct::players
int16_t players
Definition: map.h:332
mapstruct::tmpname
char * tmpname
Definition: map.h:315
MapSpace::move_off
MoveType move_off
Definition: map.h:263
MoveType
unsigned char MoveType
Definition: define.h:417
shopitems::index
int index
Definition: map.h:299
mapstruct::height
uint16_t height
Definition: map.h:335
MAP_LAYERS
#define MAP_LAYERS
Definition: map.h:32
oblinkpt
Definition: object.h:467
region::name
char * name
Definition: map.h:273
rv_vector::part
object * part
Definition: map.h:373
mapstruct::is_template
uint32_t is_template
Definition: map.h:327
mapstruct::path
char path[HUGE_BUF]
Definition: map.h:353
HUGE_BUF
#define HUGE_BUF
Definition: define.h:37
mapstruct::width
uint16_t width
Definition: map.h:335
MapSpace::bottom
object * bottom
Definition: map.h:255
region::longname
char * longname
Definition: map.h:279
rv_vector::distance_y
int distance_y
Definition: map.h:371
mapstruct::shopitems
struct shopitems * shopitems
Definition: map.h:344
m
static event_registration m
Definition: citylife.cpp:425
rv_vector::distance_x
int distance_x
Definition: map.h:370
MapSpace::top
object * top
Definition: map.h:256
mapstruct::shoprace
char * shoprace
Definition: map.h:345
region::parent
region * parent
Definition: map.h:274
region::msg
char * msg
Definition: map.h:281
region::jailmap
char * jailmap
Definition: map.h:285
shopitems::name_pl
const char * name_pl
Definition: map.h:295
mapstruct::reset_group
sstring reset_group
Definition: map.h:325
MapSpace
Definition: map.h:254
mapstruct::last_reset_time
long last_reset_time
Definition: map.h:354
mapstruct::maplore
char * maplore
Definition: map.h:350
shopitems::typenum
int typenum
Definition: map.h:296
mapstruct::shopmax
uint64_t shopmax
Definition: map.h:348
region
Definition: map.h:272
MapSpace::move_block
MoveType move_block
Definition: map.h:260
mapstruct::background_music
char * background_music
Definition: map.h:355
shopitems::name
const char * name
Definition: map.h:294
mapstruct::reset_timeout
uint32_t reset_timeout
Definition: map.h:321
mapstruct
Definition: map.h:313
sstring
const typedef char * sstring
Definition: sstring.h:2
mapstruct::nosmooth
uint32_t nosmooth
Definition: map.h:328
MapSpace::flags
uint8_t flags
Definition: map.h:258
mapstruct::name
char * name
Definition: map.h:316
mapstruct::enter_x
int16_t enter_x
Definition: map.h:336
mapstruct::in_memory
uint32_t in_memory
Definition: map.h:333
rv_vector
Definition: map.h:368
shopitems
Definition: map.h:293
mapstruct::timeout
int32_t timeout
Definition: map.h:330
MapSpace::pl
object * pl
Definition: map.h:264
mapstruct::tile_map
mapstruct * tile_map[4]
Definition: map.h:352
mapstruct::spaces
MapSpace * spaces
Definition: map.h:343
mapstruct::msg
char * msg
Definition: map.h:349
region::counter
uint32_t counter
Definition: map.h:282
map_size
uint32_t map_size(mapstruct *m)
Definition: map.cpp:799
MapSpace::faces_obj
object * faces_obj[MAP_LAYERS]
Definition: map.h:257
mapstruct::enter_y
int16_t enter_y
Definition: map.h:336
mapstruct::unique
uint32_t unique
Definition: map.h:326
mapstruct::next
mapstruct * next
Definition: map.h:314
mapstruct::reset_time
uint32_t reset_time
Definition: map.h:320
mapstruct::darkness
uint8_t darkness
Definition: map.h:334
rv_vector::direction
int direction
Definition: map.h:372
mapstruct::fixed_resettime
uint32_t fixed_resettime
Definition: map.h:323
rv_vector::distance
unsigned int distance
Definition: map.h:369
MapSpace::move_slow
MoveType move_slow
Definition: map.h:261
region::jaily
int16_t jaily
Definition: map.h:286
region::jailx
int16_t jailx
Definition: map.h:286