Crossfire Server, Branches 1.12  R18729
map.h
Go to the documentation of this file.
1 /*
2  * static char *rcsid_define_h =
3  * "$Id: map.h 11578 2009-02-23 22:02:27Z lalo $";
4  */
5 
6 /*
7  CrossFire, A Multiplayer game for X-windows
8 
9  Copyright (C) 2002-2005 Mark Wedel & Crossfire Development Team
10  Copyright (C) 1992 Frank Tore Johansen
11 
12  This program is free software; you can redistribute it and/or modify
13  it under the terms of the GNU General Public License as published by
14  the Free Software Foundation; either version 2 of the License, or
15  (at your option) any later version.
16 
17  This program is distributed in the hope that it will be useful,
18  but WITHOUT ANY WARRANTY; without even the implied warranty of
19  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20  GNU General Public License for more details.
21 
22  You should have received a copy of the GNU General Public License
23  along with this program; if not, write to the Free Software
24  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
25 
26  The authors can be reached via e-mail at crossfire-devel@real-time.com
27 */
28 
34 /*
35  * The mapstruct is allocated each time a new map is opened.
36  * It contains pointers (very indirectly) to all objects on the map.
37  */
38 
39 #ifndef MAP_H
40 #define MAP_H
41 
42 /* We set this size - this is to make magic map work properly on
43  * tiled maps. There is no requirement that this matches the
44  * tiled maps size - it just seemed like a reasonable value.
45  * Magic map code now always starts out putting the player in the
46  * center of the map - this makes the most sense when dealing
47  * with tiled maps.
48  * We also figure out the magicmap color to use as we process the
49  * spaces - this is more efficient as we already have up to date
50  * map pointers.
51  */
52 #define MAGIC_MAP_SIZE 50
53 #define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2
54 
55 /* This correspondes to the map layers in the map2 protocol.
56  * The MAP_LAYER_... correspond to what goes on what layer -
57  * this removes the need for hardcoding, and also makes sure
58  * we don't overstep the number of layers.
59  */
60 #define MAP_LAYERS 10
61 
62 extern const char *map_layer_name[MAP_LAYERS];
63 
68 #define MAP_LAYER_FLOOR 0
69 #define MAP_LAYER_NO_PICK1 1
70 #define MAP_LAYER_NO_PICK2 2
71 #define MAP_LAYER_ITEM1 3
72 #define MAP_LAYER_ITEM2 4
73 #define MAP_LAYER_ITEM3 5
74 #define MAP_LAYER_LIVING1 6
75 #define MAP_LAYER_LIVING2 7
76 #define MAP_LAYER_FLY1 8
77 #define MAP_LAYER_FLY2 9
79 
80 
81 #define MAP_WHEN_RESET(m) ((m)->reset_time)
82 
83 #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout)
84 #define MAP_DIFFICULTY(m) ((m)->difficulty)
85 #define MAP_TIMEOUT(m) ((m)->timeout)
86 #define MAP_SWAP_TIME(m) ((m)->swap_time)
87 #define MAP_OUTDOORS(m) ((m)->outdoor)
88 
94 #define MAP_DARKNESS(m) (m)->darkness
95 
97 #define MAP_WIDTH(m) (m)->width
98 
99 #define MAP_HEIGHT(m) (m)->height
100 
101 #define MAP_SIZE(m) ((m)->width*(m)->height)
102 
104 #define MAP_ENTER_X(m) (m)->enter_x
105 
106 #define MAP_ENTER_Y(m) (m)->enter_y
107 
108 #define MAP_NOSMOOTH(m) (m)->nosmooth
109 
116 #define MAP_FLUSH 0x1
117 #define MAP_PLAYER_UNIQUE 0x2
118 #define MAP_BLOCK 0x4
119 #define MAP_STYLE 0x8
120 #define MAP_OVERLAY 0x10
122 
123 
131 #define SAVE_FLAG_SAVE_UNPAID 1
132 #define SAVE_FLAG_NO_REMOVE 2
134 
135 
141 #define SAVE_MODE_NORMAL 0
142 #define SAVE_MODE_INPLACE 1
143 #define SAVE_MODE_OVERLAY 2
145 
146 
151 #define MAP_IN_MEMORY 1
152 #define MAP_SWAPPED 2
153 #define MAP_LOADING 3
154 #define MAP_SAVING 4
156 
157 
164 #define SAVE_ERROR_OK 0
165 #define SAVE_ERROR_RCREATION -1
166 #define SAVE_ERROR_UCREATION -2
167 #define SAVE_ERROR_WRITE -3
168 #define SAVE_ERROR_NO_PATH -4
169 #define SAVE_ERROR_URENAME -5
170 #define SAVE_ERROR_CLOSE -6
171 #define SAVE_ERROR_RRENAME -7
172 #define SAVE_ERROR_NOT_IN_MEMORY -10
173 #define SAVE_ERROR_PLAYER -11
175 
176 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should
177  * really be used, as it is multi tile aware. However, there are some cases
178  * where it is known the map is not tiled or the values are known
179  * consistent (eg, op->map, op->x, op->y)
180  */
182 #define GET_MAP_FLAGS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].flags)
183 
184 #define SET_MAP_FLAGS(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
185 
186 #define GET_MAP_LIGHT(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].light)
187 
188 #define SET_MAP_LIGHT(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].light = L)
189 #define GET_MAP_PLAYER(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].pl)
190 #define SET_MAP_PLAYER(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].pl = C)
191 
193 #define GET_MAP_OB(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].bottom)
194 
195 #define GET_MAP_TOP(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].top)
196 
198 #define SET_MAP_OB(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
199 
200 #define SET_MAP_TOP(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))
201 
203 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
204 
205 #define GET_MAP_FACE_OBJ(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
206 
210 #define GET_MAP_FACE_OBJS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
211 
213 #define GET_MAP_MOVE_BLOCK(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_block)
214 
215 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
216 
218 #define GET_MAP_MOVE_SLOW(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
219 
220 #define SET_MAP_MOVE_SLOW(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
221 
223 #define GET_MAP_MOVE_ON(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_on)
224 
225 #define SET_MAP_MOVE_ON(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
226 
228 #define GET_MAP_MOVE_OFF(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_off)
229 
230 #define SET_MAP_MOVE_OFF(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
231 
238 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
239 
247 #define P_BLOCKSVIEW 0x01
248 #define P_NO_MAGIC 0x02
250 /* AB_NO_PASS is used for arch_blocked() return value. It needs
251  * to be here to make sure the bits don't match with anything.
252  * Changed name to have AB_ prefix just to make sure no one
253  * is using the P_NO_PASS. AB_.. should only be used for
254  * arch_blocked and functions that examine the return value.
255  */
256 #define AB_NO_PASS 0x04
257 #define P_PLAYER 0x08
258 #define P_IS_ALIVE 0x10
259 #define P_NO_CLERIC 0x20
260 #define P_NEED_UPDATE 0x40
261 #define P_NO_ERROR 0x80
264 /* The following two values are not stored in the MapLook flags, but instead
265  * used in the get_map_flags value - that function is used to return
266  * the flag value, as well as other conditions - using a more general
267  * function that does more of the work can hopefully be used to replace
268  * lots of duplicate checks currently in the code.
269  */
270 #define P_OUT_OF_MAP 0x100
271 #define P_NEW_MAP 0x200
274 
277 typedef struct MapSpace {
278  object *bottom;
279  object *top;
287  object *pl; /* Player that is on this space */
295 typedef struct regiondef {
296  struct regiondef *next;
297  const char *name;
298  const char *parent_name;
305  struct regiondef *parent;
310  const char *longname;
312  const char *msg;
313  uint32 counter;
316  char *jailmap;
317  sint16 jailx, jaily;
324 typedef struct shopitem {
325  const char *name;
326  const char *name_pl;
327  int typenum;
330  int index;
331 } shopitems;
344 typedef struct mapdef {
345  struct mapdef *next;
346  char *tmpname;
347  char *name;
348  struct regiondef *region;
357  uint32 is_template:1;
368  uint16 width, height;
373  struct shopitem *shopitems;
374  char *shoprace;
375  double shopgreed;
376  uint64 shopmin;
377  uint64 shopmax;
378  char *msg;
379  char *maplore;
380  char *tile_path[4];
381  struct mapdef *tile_map[4];
382  char path[HUGE_BUF];
383  struct timeval last_reset_time;
397 typedef struct rv_vector {
398  unsigned int distance;
401  int direction;
402  object *part;
405 #endif /* MAP_H */
char path[HUGE_BUF]
Definition: map.h:384
uint64 shopmax
Definition: map.h:379
signed char sint8
Definition: global.h:80
double shopgreed
Definition: map.h:377
MapSpace * spaces
Definition: map.h:374
object * bottom
Definition: map.h:280
sint16 jailx
Definition: map.h:319
struct mapdef mapstruct
signed short sint16
Definition: global.h:72
Definition: map.h:399
signed int sint32
Definition: global.h:64
object * part
Definition: map.h:404
struct mapdef * tile_map[4]
Definition: map.h:383
unsigned char MoveType
Definition: define.h:725
#define HUGE_BUF
Definition: define.h:83
sint16 players
Definition: map.h:365
MoveType move_on
Definition: map.h:287
sint8 fallback
Definition: map.h:316
uint32 in_memory
Definition: map.h:366
const char * name
Definition: map.h:327
char * maplore
Definition: map.h:381
const char * map_layer_name[MAP_LAYERS]
Definition: map.c:54
uint16 height
Definition: map.h:370
int distance_y
Definition: map.h:402
const char * parent_name
Definition: map.h:300
int typenum
Definition: map.h:329
sint32 timeout
Definition: map.h:362
const char * name
Definition: map.h:299
char * name
Definition: map.h:349
uint8 flags
Definition: map.h:283
int index
Definition: map.h:332
object * faces_obj[MAP_LAYERS]
Definition: map.h:282
struct regiondef * next
Definition: map.h:298
Definition: map.h:297
MoveType move_block
Definition: map.h:285
char * msg
Definition: map.h:380
#define MAP_LAYERS
Definition: map.h:60
struct timeval last_reset_time
Definition: map.h:385
uint32 reset_timeout
Definition: map.h:354
int distance_x
Definition: map.h:401
uint16 difficulty
Definition: map.h:364
char * tile_path[4]
Definition: map.h:382
MoveType move_slow
Definition: map.h:286
unsigned char uint8
Definition: global.h:75
object * pl
Definition: map.h:289
uint16 enter_y
Definition: map.h:372
sint8 strength
Definition: map.h:330
struct shopitem shopitems
struct MapSpace MapSpace
struct regiondef * parent
Definition: map.h:307
const char * longname
Definition: map.h:312
struct rv_vector rv_vector
oblinkpt * buttons
Definition: map.h:373
uint8 compressed
Definition: map.h:367
unsigned short uint16
Definition: global.h:67
char * tmpname
Definition: map.h:348
uint8 darkness
Definition: map.h:369
uint32 unique
Definition: map.h:358
uint32 is_template
Definition: map.h:359
Definition: map.h:279
uint16 width
Definition: map.h:370
const char * name_pl
Definition: map.h:328
char * jailmap
Definition: map.h:318
uint32 reset_time
Definition: map.h:353
uint32 fixed_resettime
Definition: map.h:356
unsigned int distance
Definition: map.h:400
int direction
Definition: map.h:403
Definition: map.h:326
const char * msg
Definition: map.h:314
sint32 swap_time
Definition: map.h:363
unsigned int uint32
Definition: global.h:58
MoveType move_off
Definition: map.h:288
struct shopitem * shopitems
Definition: map.h:375
struct mapdef * next
Definition: map.h:347
char * shoprace
Definition: map.h:376
uint64 shopmin
Definition: map.h:378
Definition: map.h:346
char * background_music
Definition: map.h:386
uint32 counter
Definition: map.h:315
sint16 jaily
Definition: map.h:319
struct regiondef * region
Definition: map.h:350
uint32 outdoor
Definition: map.h:361
uint32 nosmooth
Definition: map.h:360
struct regiondef region
uint16 enter_x
Definition: map.h:371
object * top
Definition: map.h:281
sint8 light
Definition: map.h:284