Crossfire Server, Trunk  R22047
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 #define SAVE_ERROR_RRENAME -7
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
254 
257 typedef struct MapSpace {
258  object *bottom;
259  object *top;
267  object *pl;
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;
296  char *jailmap;
297  int16_t jailx, jaily;
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;
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;
353  oblinkpt *buttons;
354  MapSpace *spaces;
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];
379 typedef struct rv_vector {
380  unsigned int distance;
381  int distance_x;
382  int distance_y;
383  int direction;
384  object *part;
388 
389 #endif /* MAP_H */
char path[HUGE_BUF]
Definition: map.h:366
object * bottom
Definition: map.h:260
struct mapdef mapstruct
int16_t jaily
Definition: map.h:299
Definition: map.h:381
unsigned char uint8_t
Definition: win32.h:161
struct mapdef * tile_map[4]
Definition: map.h:365
unsigned char MoveType
Definition: define.h:432
#define HUGE_BUF
Definition: define.h:37
int8_t fallback
Definition: map.h:296
MoveType move_on
Definition: map.h:267
char * name
Definition: map.h:329
char * name
Definition: map.h:279
object * faces_obj[MAP_LAYERS]
Definition: map.h:262
signed short int16_t
Definition: win32.h:160
struct regiondef * next
Definition: map.h:278
Definition: map.h:277
MoveType move_block
Definition: map.h:265
#define MAP_LAYERS
Definition: map.h:32
char * parent_name
Definition: map.h:280
int8_t light
Definition: map.h:264
uint32_t counter
Definition: map.h:295
MoveType move_slow
Definition: map.h:266
object * pl
Definition: map.h:269
long last_reset_time
Definition: map.h:367
struct shopitem shopitems
struct MapSpace MapSpace
unsigned __int64 uint64_t
Definition: win32.h:167
struct regiondef * parent
Definition: map.h:287
struct rv_vector rv_vector
uint32_t map_size(mapstruct *m)
Definition: map.c:826
int16_t jailx
Definition: map.h:299
unsigned short uint16_t
Definition: win32.h:163
char * tmpname
Definition: map.h:328
unsigned int uint32_t
Definition: win32.h:162
Definition: map.h:259
signed char int8_t
Definition: win32.h:158
char * jailmap
Definition: map.h:298
Definition: map.h:306
signed int int32_t
Definition: win32.h:159
char * msg
Definition: map.h:294
uint8_t flags
Definition: map.h:263
MoveType move_off
Definition: map.h:268
struct mapdef * next
Definition: map.h:327
Definition: map.h:326
char * background_music
Definition: map.h:368
const char *const map_layer_name[MAP_LAYERS]
Definition: map.c:55
char * longname
Definition: map.h:292
struct regiondef region
object * top
Definition: map.h:261