Crossfire Server, Branch 1.12
R12190
|
00001 /* 00002 * static char *rcsid_define_h = 00003 * "$Id: map.h 11578 2009-02-23 22:02:27Z lalo $"; 00004 */ 00005 00006 /* 00007 CrossFire, A Multiplayer game for X-windows 00008 00009 Copyright (C) 2002-2005 Mark Wedel & Crossfire Development Team 00010 Copyright (C) 1992 Frank Tore Johansen 00011 00012 This program is free software; you can redistribute it and/or modify 00013 it under the terms of the GNU General Public License as published by 00014 the Free Software Foundation; either version 2 of the License, or 00015 (at your option) any later version. 00016 00017 This program is distributed in the hope that it will be useful, 00018 but WITHOUT ANY WARRANTY; without even the implied warranty of 00019 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00020 GNU General Public License for more details. 00021 00022 You should have received a copy of the GNU General Public License 00023 along with this program; if not, write to the Free Software 00024 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00025 00026 The authors can be reached via e-mail at crossfire-devel@real-time.com 00027 */ 00028 00034 /* 00035 * The mapstruct is allocated each time a new map is opened. 00036 * It contains pointers (very indirectly) to all objects on the map. 00037 */ 00038 00039 #ifndef MAP_H 00040 #define MAP_H 00041 00042 /* We set this size - this is to make magic map work properly on 00043 * tiled maps. There is no requirement that this matches the 00044 * tiled maps size - it just seemed like a reasonable value. 00045 * Magic map code now always starts out putting the player in the 00046 * center of the map - this makes the most sense when dealing 00047 * with tiled maps. 00048 * We also figure out the magicmap color to use as we process the 00049 * spaces - this is more efficient as we already have up to date 00050 * map pointers. 00051 */ 00052 #define MAGIC_MAP_SIZE 50 00053 #define MAGIC_MAP_HALF MAGIC_MAP_SIZE/2 00054 00055 /* This correspondes to the map layers in the map2 protocol. 00056 * The MAP_LAYER_... correspond to what goes on what layer - 00057 * this removes the need for hardcoding, and also makes sure 00058 * we don't overstep the number of layers. 00059 */ 00060 #define MAP_LAYERS 10 00061 00062 extern const char *map_layer_name[MAP_LAYERS]; 00063 00068 #define MAP_LAYER_FLOOR 0 00069 #define MAP_LAYER_NO_PICK1 1 00070 #define MAP_LAYER_NO_PICK2 2 00071 #define MAP_LAYER_ITEM1 3 00072 #define MAP_LAYER_ITEM2 4 00073 #define MAP_LAYER_ITEM3 5 00074 #define MAP_LAYER_LIVING1 6 00075 #define MAP_LAYER_LIVING2 7 00076 #define MAP_LAYER_FLY1 8 00077 #define MAP_LAYER_FLY2 9 00079 00080 00081 #define MAP_WHEN_RESET(m) ((m)->reset_time) 00082 00083 #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout) 00084 #define MAP_DIFFICULTY(m) ((m)->difficulty) 00085 #define MAP_TIMEOUT(m) ((m)->timeout) 00086 #define MAP_SWAP_TIME(m) ((m)->swap_time) 00087 #define MAP_OUTDOORS(m) ((m)->outdoor) 00088 00094 #define MAP_DARKNESS(m) (m)->darkness 00095 00097 #define MAP_WIDTH(m) (m)->width 00098 00099 #define MAP_HEIGHT(m) (m)->height 00100 00101 #define MAP_SIZE(m) ((m)->width*(m)->height) 00102 00104 #define MAP_ENTER_X(m) (m)->enter_x 00105 00106 #define MAP_ENTER_Y(m) (m)->enter_y 00107 00108 #define MAP_NOSMOOTH(m) (m)->nosmooth 00109 00116 #define MAP_FLUSH 0x1 00117 #define MAP_PLAYER_UNIQUE 0x2 00118 #define MAP_BLOCK 0x4 00119 #define MAP_STYLE 0x8 00120 #define MAP_OVERLAY 0x10 00122 00123 00131 #define SAVE_FLAG_SAVE_UNPAID 1 00132 #define SAVE_FLAG_NO_REMOVE 2 00134 00135 00141 #define SAVE_MODE_NORMAL 0 00142 #define SAVE_MODE_INPLACE 1 00143 #define SAVE_MODE_OVERLAY 2 00145 00146 00151 #define MAP_IN_MEMORY 1 00152 #define MAP_SWAPPED 2 00153 #define MAP_LOADING 3 00154 #define MAP_SAVING 4 00156 00157 00164 #define SAVE_ERROR_OK 0 00165 #define SAVE_ERROR_RCREATION -1 00166 #define SAVE_ERROR_UCREATION -2 00167 #define SAVE_ERROR_WRITE -3 00168 #define SAVE_ERROR_NO_PATH -4 00169 #define SAVE_ERROR_URENAME -5 00170 #define SAVE_ERROR_CLOSE -6 00171 #define SAVE_ERROR_RRENAME -7 00172 #define SAVE_ERROR_NOT_IN_MEMORY -10 00173 #define SAVE_ERROR_PLAYER -11 00175 00176 /* GET_MAP_FLAGS really shouldn't be used very often - get_map_flags should 00177 * really be used, as it is multi tile aware. However, there are some cases 00178 * where it is known the map is not tiled or the values are known 00179 * consistent (eg, op->map, op->x, op->y) 00180 */ 00182 #define GET_MAP_FLAGS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].flags) 00183 00184 #define SET_MAP_FLAGS(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].flags = C) 00185 00186 #define GET_MAP_LIGHT(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].light) 00187 00188 #define SET_MAP_LIGHT(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].light = L) 00189 #define GET_MAP_PLAYER(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].pl) 00190 #define SET_MAP_PLAYER(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].pl = C) 00191 00193 #define GET_MAP_OB(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].bottom) 00194 00195 #define GET_MAP_TOP(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].top) 00196 00198 #define SET_MAP_OB(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp)) 00199 00200 #define SET_MAP_TOP(M, X, Y, tmp) ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp)) 00201 00203 #define SET_MAP_FACE_OBJ(M, X, Y, C, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C) 00204 00205 #define GET_MAP_FACE_OBJ(M, X, Y, L) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L]) 00206 00210 #define GET_MAP_FACE_OBJS(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].faces_obj) 00211 00213 #define GET_MAP_MOVE_BLOCK(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_block) 00214 00215 #define SET_MAP_MOVE_BLOCK(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_block = C) 00216 00218 #define GET_MAP_MOVE_SLOW(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_slow) 00219 00220 #define SET_MAP_MOVE_SLOW(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C) 00221 00223 #define GET_MAP_MOVE_ON(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_on) 00224 00225 #define SET_MAP_MOVE_ON(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_on = C) 00226 00228 #define GET_MAP_MOVE_OFF(M, X, Y) ((M)->spaces[(X)+(M)->width*(Y)].move_off) 00229 00230 #define SET_MAP_MOVE_OFF(M, X, Y, C) ((M)->spaces[(X)+(M)->width*(Y)].move_off = C) 00231 00238 #define OUT_OF_REAL_MAP(M, X, Y) ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height) 00239 00247 #define P_BLOCKSVIEW 0x01 00248 #define P_NO_MAGIC 0x02 00250 /* AB_NO_PASS is used for arch_blocked() return value. It needs 00251 * to be here to make sure the bits don't match with anything. 00252 * Changed name to have AB_ prefix just to make sure no one 00253 * is using the P_NO_PASS. AB_.. should only be used for 00254 * arch_blocked and functions that examine the return value. 00255 */ 00256 #define AB_NO_PASS 0x04 00257 #define P_PLAYER 0x08 00258 #define P_IS_ALIVE 0x10 00259 #define P_NO_CLERIC 0x20 00260 #define P_NEED_UPDATE 0x40 00261 #define P_NO_ERROR 0x80 00264 /* The following two values are not stored in the MapLook flags, but instead 00265 * used in the get_map_flags value - that function is used to return 00266 * the flag value, as well as other conditions - using a more general 00267 * function that does more of the work can hopefully be used to replace 00268 * lots of duplicate checks currently in the code. 00269 */ 00270 #define P_OUT_OF_MAP 0x100 00271 #define P_NEW_MAP 0x200 00273 00274 00277 typedef struct MapSpace { 00278 object *bottom; 00279 object *top; 00280 object *faces_obj[MAP_LAYERS]; 00281 uint8 flags; 00282 sint8 light; 00283 MoveType move_block; 00284 MoveType move_slow; 00285 MoveType move_on; 00286 MoveType move_off; 00287 object *pl; /* Player that is on this space */ 00288 } MapSpace; 00289 00295 typedef struct regiondef { 00296 struct regiondef *next; 00297 const char *name; 00298 const char *parent_name; 00305 struct regiondef *parent; 00310 const char *longname; 00312 const char *msg; 00313 uint32 counter; 00314 sint8 fallback; 00316 char *jailmap; 00317 sint16 jailx, jaily; 00318 } region; 00319 00324 typedef struct shopitem { 00325 const char *name; 00326 const char *name_pl; 00327 int typenum; 00328 sint8 strength; 00330 int index; 00331 } shopitems; 00332 00344 typedef struct mapdef { 00345 struct mapdef *next; 00346 char *tmpname; 00347 char *name; 00348 struct regiondef *region; 00351 uint32 reset_time; 00352 uint32 reset_timeout; 00354 uint32 fixed_resettime:1; 00356 uint32 unique:1; 00357 uint32 is_template:1; 00358 uint32 nosmooth:1; 00359 uint32 outdoor:1; 00360 sint32 timeout; 00361 sint32 swap_time; 00362 uint16 difficulty; 00363 sint16 players; 00364 uint32 in_memory; 00365 uint8 compressed; 00367 uint8 darkness; 00368 uint16 width, height; 00369 uint16 enter_x; 00370 uint16 enter_y; 00371 oblinkpt *buttons; 00372 MapSpace *spaces; 00373 struct shopitem *shopitems; 00374 char *shoprace; 00375 double shopgreed; 00376 uint64 shopmin; 00377 uint64 shopmax; 00378 char *msg; 00379 char *maplore; 00380 char *tile_path[4]; 00381 struct mapdef *tile_map[4]; 00382 char path[HUGE_BUF]; 00383 struct timeval last_reset_time; 00384 char *background_music; 00385 } mapstruct; 00386 00397 typedef struct rv_vector { 00398 unsigned int distance; 00399 int distance_x; 00400 int distance_y; 00401 int direction; 00402 object *part; 00403 } rv_vector; 00404 00405 #endif /* MAP_H */