Crossfire Server, Trunk  R20513
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_STYLE 0x8
99 #define MAP_OVERLAY 0x10
101 
102 
110 #define SAVE_FLAG_SAVE_UNPAID 1
111 #define SAVE_FLAG_NO_REMOVE 2
113 
114 
120 #define SAVE_MODE_NORMAL 0
121 #define SAVE_MODE_INPLACE 1
122 #define SAVE_MODE_OVERLAY 2
124 
125 
130 #define MAP_IN_MEMORY 1
131 #define MAP_SWAPPED 2
132 #define MAP_LOADING 3
133 #define MAP_SAVING 4
135 
136 
143 #define SAVE_ERROR_OK 0
144 #define SAVE_ERROR_RCREATION -1
145 #define SAVE_ERROR_UCREATION -2
146 #define SAVE_ERROR_WRITE -3
147 #define SAVE_ERROR_NO_PATH -4
148 #define SAVE_ERROR_URENAME -5
149 #define SAVE_ERROR_CLOSE -6
150 #define SAVE_ERROR_RRENAME -7
151 #define SAVE_ERROR_NOT_IN_MEMORY -10
152 #define SAVE_ERROR_PLAYER -11
154 
155 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should
156  * really be used, as it is multi tile aware. However, there are some cases
157  * where it is known the map is not tiled or the values are known
158  * consistent (eg, op->map, op->x, op->y)
159  */
161 #define GET_MAP_FLAGS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].flags)
162 
163 #define SET_MAP_FLAGS(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
164 
165 #define GET_MAP_LIGHT(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].light)
166 
167 #define SET_MAP_LIGHT(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].light = L)
168 #define GET_MAP_PLAYER(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].pl)
169 #define SET_MAP_PLAYER(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].pl = C)
170 
172 #define GET_MAP_OB(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].bottom)
173 
174 #define GET_MAP_TOP(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].top)
175 
177 #define SET_MAP_OB(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
178 
179 #define SET_MAP_TOP(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))
180 
182 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
183 
184 #define GET_MAP_FACE_OBJ(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
185 
189 #define GET_MAP_FACE_OBJS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
190 
192 #define GET_MAP_MOVE_BLOCK(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_block)
193 
194 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
195 
197 #define GET_MAP_MOVE_SLOW(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
198 
199 #define SET_MAP_MOVE_SLOW(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
200 
202 #define GET_MAP_MOVE_ON(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_on)
203 
204 #define SET_MAP_MOVE_ON(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
205 
207 #define GET_MAP_MOVE_OFF(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_off)
208 
209 #define SET_MAP_MOVE_OFF(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
210 
217 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
218 
226 #define P_BLOCKSVIEW 0x01
227 #define P_NO_MAGIC 0x02
229 /* AB_NO_PASS is used for arch_blocked() return value. It needs
230  * to be here to make sure the bits don't match with anything.
231  * Changed name to have AB_ prefix just to make sure no one
232  * is using the P_NO_PASS. AB_.. should only be used for
233  * arch_blocked and functions that examine the return value.
234  */
235 #define AB_NO_PASS 0x04
236 #define P_PLAYER 0x08
237 #define P_IS_ALIVE 0x10
238 #define P_NO_CLERIC 0x20
239 #define P_NEED_UPDATE 0x40
240 #define P_NO_ERROR 0x80
243 /* The following two values are not stored in the MapLook flags, but instead
244  * used in the get_map_flags value - that function is used to return
245  * the flag value, as well as other conditions - using a more general
246  * function that does more of the work can hopefully be used to replace
247  * lots of duplicate checks currently in the code.
248  */
249 #define P_OUT_OF_MAP 0x100
250 #define P_NEW_MAP 0x200
253 
256 typedef struct MapSpace {
257  object *bottom;
258  object *top;
266  object *pl;
274 typedef struct regiondef {
275  struct regiondef *next;
276  char *name;
277  char *parent_name;
284  struct regiondef *parent;
289  char *longname;
291  char *msg;
292  uint32_t counter;
295  char *jailmap;
296  int16_t jailx, jaily;
303 typedef struct shopitem {
304  const char *name;
305  const char *name_pl;
306  int typenum;
307  int8_t strength;
309  int index;
310 } shopitems;
323 typedef struct mapdef {
324  struct mapdef *next;
325  char *tmpname;
326  char *name;
327  struct regiondef *region;
330  uint32_t reset_time;
331  uint32_t reset_timeout;
333  uint32_t fixed_resettime:1;
335  uint32_t unique:1;
336  uint32_t is_template:1;
337  uint32_t nosmooth:1;
338  uint32_t outdoor:1;
339  int32_t timeout;
340  int32_t swap_time;
341  uint16_t difficulty;
342  int16_t players;
343  uint32_t in_memory;
344  uint8_t darkness;
345  uint16_t width, height;
346  int16_t enter_x, enter_y;
352  oblinkpt *buttons;
353  MapSpace *spaces;
354  struct shopitem *shopitems;
355  char *shoprace;
356  double shopgreed;
357  uint64_t shopmin;
358  uint64_t shopmax;
359  char *msg;
360  char *maplore;
361  char *tile_path[4];
362  struct mapdef *tile_map[4];
363  char path[HUGE_BUF];
378 typedef struct rv_vector {
379  unsigned int distance;
380  int distance_x;
381  int distance_y;
382  int direction;
383  object *part;
387 
388 #endif /* MAP_H */
char path[HUGE_BUF]
Filename of the map.
Definition: map.h:365
object * bottom
Lowest object on this space.
Definition: map.h:259
struct mapdef mapstruct
This is a game-map.
int16_t jaily
The coodinates in jailmap to which the player should be sent.
Definition: map.h:298
This is used by get_rangevector to determine where the other creature is.
Definition: map.h:380
unsigned char uint8_t
Definition: win32.h:161
struct mapdef * tile_map[4]
Adjoining maps.
Definition: map.h:364
unsigned char MoveType
Typdef here to define type large enough to hold bitmask of all movement types.
Definition: define.h:432
#define HUGE_BUF
Used for messages - some can be quite long.
Definition: define.h:37
int8_t fallback
Whether, in the event of a region not existing, this should be the one we fall back on as the default...
Definition: map.h:295
MoveType move_on
What movement types are activated.
Definition: map.h:266
Used to link together several object links.
Definition: object.h:451
char * name
Name of map as given by its creator.
Definition: map.h:328
char * name
Shortend name of the region as maps refer to it.
Definition: map.h:278
object * faces_obj[MAP_LAYERS]
Face objects for the layers.
Definition: map.h:261
signed short int16_t
Definition: win32.h:160
struct regiondef * next
Pointer to next region, NULL for the last one.
Definition: map.h:277
This is a game region.
Definition: map.h:276
MoveType move_block
What movement types this space blocks.
Definition: map.h:264
#define MAP_LAYERS
Definition: map.h:32
char * parent_name
So that parent and child regions can be defined in any order, we keep hold of the parent_name during ...
Definition: map.h:279
int8_t light
How much light this space provides.
Definition: map.h:263
uint32_t counter
A generic counter for holding temporary data.
Definition: map.h:294
MoveType move_slow
What movement types this space slows.
Definition: map.h:265
object * pl
Player who is on this space, may be NULL.
Definition: map.h:268
long last_reset_time
A timestamp of the last original map loading.
Definition: map.h:366
struct shopitem shopitems
Shop-related information for a map.
struct MapSpace MapSpace
This structure contains all information related to one map square.
unsigned __int64 uint64_t
Definition: win32.h:167
struct regiondef * parent
Pointer to the region that is a parent of the current region, if a value isn&#39;t defined in the current...
Definition: map.h:286
struct rv_vector rv_vector
This is used by get_rangevector to determine where the other creature is.
uint32_t map_size(mapstruct *m)
Calculate map size without intermediate sign extension.
Definition: map.c:830
int16_t jailx
Definition: map.h:298
unsigned short uint16_t
Definition: win32.h:163
char * tmpname
Name of temporary file.
Definition: map.h:327
unsigned int uint32_t
Definition: win32.h:162
This structure contains all information related to one map square.
Definition: map.h:258
signed char int8_t
Type definitions for fixed-size integer types.
Definition: win32.h:158
char * jailmap
Where a player that is arrested in this region should be imprisoned.
Definition: map.h:297
Shop-related information for a map.
Definition: map.h:305
signed int int32_t
Definition: win32.h:159
char * msg
The description of the region.
Definition: map.h:293
uint8_t flags
Flags about this space (see the P_ values above).
Definition: map.h:262
MoveType move_off
What movement types are activated.
Definition: map.h:267
struct mapdef * next
Next map, linked list.
Definition: map.h:326
This is a game-map.
Definition: map.h:325
char * background_music
Background music to use for this map.
Definition: map.h:367
const char *const map_layer_name[MAP_LAYERS]
These correspond to the layer names in map.h - since some of the types can be on multiple layers...
Definition: map.c:46
char * longname
Official title of the region, this might be defined to be the same as name.
Definition: map.h:291
struct regiondef region
This is a game region.
object * top
Highest object on this space.
Definition: map.h:260