|
Atrinik Server 2.5
|
00001 /************************************************************************ 00002 * Atrinik, a Multiplayer Online Role Playing Game * 00003 * * 00004 * Copyright (C) 2009-2011 Alex Tokar and Atrinik Development Team * 00005 * * 00006 * Fork from Daimonin (Massive Multiplayer Online Role Playing Game) * 00007 * and Crossfire (Multiplayer game for X-windows). * 00008 * * 00009 * This program is free software; you can redistribute it and/or modify * 00010 * it under the terms of the GNU General Public License as published by * 00011 * the Free Software Foundation; either version 2 of the License, or * 00012 * (at your option) any later version. * 00013 * * 00014 * This program is distributed in the hope that it will be useful, * 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of * 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * 00017 * GNU General Public License for more details. * 00018 * * 00019 * You should have received a copy of the GNU General Public License * 00020 * along with this program; if not, write to the Free Software * 00021 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * 00022 * * 00023 * The author can be reached at admin@atrinik.org * 00024 ************************************************************************/ 00025 00031 #ifndef MAP_H 00032 #define MAP_H 00033 00035 #define MAX_DARKNESS 7 00036 00037 int global_darkness_table[MAX_DARKNESS + 1]; 00038 int map_tiled_reverse[TILED_MAPS]; 00039 00041 #define MAP_PLAYER_MAP 1 00042 00048 #define LAYER_SYS 0 00049 00050 #define LAYER_FLOOR 1 00051 00052 #define LAYER_FMASK 2 00053 00054 #define LAYER_ITEM 3 00055 00056 #define LAYER_ITEM2 4 00057 00058 #define LAYER_WALL 5 00059 00060 #define LAYER_LIVING 6 00061 00062 #define LAYER_EFFECT 7 00063 00067 #define NUM_LAYERS 7 00068 00076 #define MAP_WHEN_RESET(m) ((m)->reset_time) 00077 00078 #define MAP_RESET_TIMEOUT(m) ((m)->reset_timeout) 00079 00080 #define MAP_DIFFICULTY(m) ((m)->difficulty) 00081 00082 #define MAP_TIMEOUT(m) ((m)->timeout) 00083 00084 #define MAP_SWAP_TIME(m) ((m)->swap_time) 00085 00086 #define MAP_OUTDOORS(m) ((m)->map_flags & MAP_FLAG_OUTDOOR) 00087 00088 #define MAP_UNIQUE(m) ((m)->map_flags & MAP_FLAG_UNIQUE) 00089 00090 #define MAP_FIXED_RESETTIME(m) ((m)->map_flags & MAP_FLAG_FIXED_RTIME) 00091 00092 #define MAP_NOSAVE(m) ((m)->map_flags & MAP_FLAG_NO_SAVE) 00093 00094 #define MAP_NOMAGIC(m) ((m)->map_flags & MAP_FLAG_NOMAGIC) 00095 00096 #define MAP_NOPRIEST(m) ((m)->map_flags & MAP_FLAG_NOPRIEST) 00097 00098 #define MAP_NOHARM(m) ((m)->map_flags & MAP_FLAG_NOHARM) 00099 00100 #define MAP_NOSUMMON(m) ((m)->map_flags & MAP_FLAG_NOSUMMON) 00101 00102 #define MAP_FIXEDLOGIN(m) ((m)->map_flags & MAP_FLAG_FIXED_LOGIN) 00103 00104 #define MAP_PLAYER_NO_SAVE(m) ((m)->map_flags & MAP_FLAG_PLAYER_NO_SAVE) 00105 00106 #define MAP_PVP(m) ((m)->map_flags & MAP_FLAG_PVP) 00107 00108 #define MAP_DARKNESS(m) (m)->darkness 00109 00110 #define MAP_WIDTH(m) (m)->width 00111 00112 #define MAP_HEIGHT(m) (m)->height 00113 00116 #define MAP_SIZE(m) ((m)->width * (m)->height) 00117 00118 #define MAP_ENTER_X(m) (m)->enter_x 00119 00120 #define MAP_ENTER_Y(m) (m)->enter_y 00121 00132 #define MAP_FLUSH 0x1 00133 00136 #define MAP_PLAYER_UNIQUE 0x2 00137 00138 #define MAP_BLOCK 0x4 00139 00140 #define MAP_STYLE 0x8 00141 00142 #define MAP_ARTIFACT 0x20 00143 00144 #define MAP_NAME_SHARED 0x40 00145 00146 #define MAP_ORIGINAL 0x80 00147 00155 #define MAP_IN_MEMORY 1 00156 00157 #define MAP_SWAPPED 2 00158 00159 #define MAP_LOADING 3 00160 00161 #define MAP_SAVING 4 00162 00164 /* new macros for map layer system */ 00165 #define GET_MAP_SPACE_PTR(M_, X_, Y_) \ 00166 (&((M_)->spaces[(X_) + (M_)->width * (Y_)])) 00167 00168 #define GET_MAP_SPACE_FIRST(M_) \ 00169 ((M_)->first) 00170 #define GET_MAP_SPACE_LAST(M_) \ 00171 ((M_)->last) 00172 #define GET_MAP_SPACE_LAYER(M_, L_) \ 00173 ((M_)->layer[L_]) 00174 00175 #define SET_MAP_SPACE_FIRST(M_, O_) \ 00176 ((M_)->first = (O_)) 00177 #define SET_MAP_SPACE_LAST(M_, O_) \ 00178 ((M_)->last = (O_)) 00179 #define SET_MAP_SPACE_LAYER(M_, L_, O_) \ 00180 ((M_)->layer[L_] = (O_)) 00181 00182 #define GET_MAP_UPDATE_COUNTER(M, X, Y) \ 00183 ((M)->spaces[(X) + (M)->width * (Y)].update_tile) 00184 00185 #define INC_MAP_UPDATE_COUNTER(M, X, Y) \ 00186 ((M)->spaces[((X) + (M)->width * (Y))].update_tile++) 00187 00188 #define GET_MAP_MOVE_FLAGS(M, X, Y) \ 00189 ((M)->spaces[(X) + (M)->width * (Y)].move_flags) 00190 #define SET_MAP_MOVE_FLAGS(M, X, Y, C) \ 00191 ((M)->spaces[(X) + (M)->width * (Y)].move_flags = C) 00192 #define GET_MAP_FLAGS(M, X, Y) \ 00193 ((M)->spaces[(X) + (M)->width * (Y)].flags) 00194 #define SET_MAP_FLAGS(M, X, Y, C) \ 00195 ((M)->spaces[(X) + (M)->width * (Y)].flags = C) 00196 #define GET_MAP_LIGHT(M, X, Y) \ 00197 ((M)->spaces[(X) + (M)->width * (Y)].light) 00198 #define SET_MAP_LIGHT(M, X, Y, L) \ 00199 ((M)->spaces[(X) + (M)->width * (Y)].light = (sint8) L) 00200 00201 #define GET_MAP_OB(M, X, Y) \ 00202 ((M)->spaces[(X) + (M)->width * (Y)].first) 00203 #define GET_MAP_OB_LAST(M, X, Y) \ 00204 ((M)->spaces[(X) + (M)->width * (Y)].last) 00205 #define GET_MAP_OB_LAYER(_M_, _X_, _Y_, _Z_) \ 00206 ((_M_)->spaces[(_X_) + (_M_)->width * (_Y_)].layer[_Z_]) 00207 #define get_map_ob GET_MAP_OB 00208 00209 #define SET_MAP_OB(M, X, Y, tmp) \ 00210 ((M)->spaces[(X) + (M)->width * (Y)].first = (tmp)) 00211 #define SET_MAP_OB_LAST(M, X, Y, tmp) \ 00212 ((M)->spaces[(X) + (M)->width * (Y)].last = (tmp)) 00213 #define SET_MAP_OB_LAYER(_M_, _X_, _Y_, _Z_, tmp) \ 00214 ((_M_)->spaces[(_X_) + (_M_)->width * (_Y_)].layer[_Z_] = (tmp)) 00215 #define set_map_ob SET_MAP_OB 00216 00217 #define SET_MAP_DAMAGE(M, X, Y, tmp) \ 00218 ((M)->spaces[(X) + (M)->width * (Y)].last_damage = (uint16) (tmp)) 00219 #define GET_MAP_DAMAGE(M, X, Y) \ 00220 ((M)->spaces[(X) + (M)->width * (Y)].last_damage) 00221 00222 #define SET_MAP_RTAG(M, X, Y, tmp) \ 00223 ((M)->spaces[(X) + (M)->width * (Y)].round_tag = (uint32) (tmp)) 00224 #define GET_MAP_RTAG(M, X, Y) \ 00225 ((M)->spaces[(X) + (M)->width * (Y)].round_tag) 00226 00227 #define GET_BOTTOM_MAP_OB(O) ((O)->map ? GET_MAP_OB((O)->map, (O)->x, (O)->y) : NULL) 00228 00239 #define FFLAG_SLEEP 0x01 00240 00241 #define FFLAG_CONFUSED 0x02 00242 00243 #define FFLAG_PARALYZED 0x04 00244 00245 #define FFLAG_SCARED 0x08 00246 00247 #define FFLAG_BLINDED 0x10 00248 00249 #define FFLAG_INVISIBLE 0x20 00250 00251 #define FFLAG_ETHEREAL 0x40 00252 00253 #define FFLAG_PROBE 0x80 00254 00260 #define OUT_OF_REAL_MAP(M, X, Y) \ 00261 ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height) 00262 00270 #define P_BLOCKSVIEW 0x01 00271 00272 #define P_NO_MAGIC 0x02 00273 00274 #define P_NO_PASS 0x04 00275 00276 #define P_IS_PLAYER 0x08 00277 00278 #define P_IS_ALIVE 0x10 00279 00280 #define P_NO_CLERIC 0x20 00281 00286 #define P_PLAYER_ONLY 0x40 00287 00290 #define P_DOOR_CLOSED 0x80 00291 00293 #define P_CHECK_INV 0x100 00294 00296 #define P_NO_PVP 0x200 00297 00303 #define P_PASS_THRU 0x400 00304 00308 #define P_MAGIC_EAR 0x800 00309 00310 #define P_WALK_ON 0x1000 00311 00312 #define P_WALK_OFF 0x2000 00313 00314 #define P_FLY_OFF 0x4000 00315 00316 #define P_FLY_ON 0x8000 00317 00318 #define P_MAGIC_MIRROR 0x10000 00319 00320 #define P_OUTDOOR 0x20000 00321 00324 #define P_OUT_OF_MAP 0x4000000 00325 00326 #define P_FLAGS_ONLY 0x8000000 00327 00328 #define P_FLAGS_UPDATE 0x10000000 00329 00330 #define P_NEED_UPDATE 0x20000000 00331 00334 #define P_NO_ERROR 0x40000000 00335 00338 #define P_NO_TERRAIN 0x80000000 00339 00346 #define MSP_EXTRA_NO_HARM 1 00347 00348 #define MSP_EXTRA_NO_PVP 2 00349 00350 #define MSP_EXTRA_NO_MAGIC 4 00351 00352 #define MSP_EXTRA_NO_CLERIC 8 00353 00356 typedef struct MapSpace_s 00357 { 00359 object *first; 00360 00362 object *layer[NUM_LAYERS * 2]; 00363 00365 object *last; 00366 00368 object *map_info; 00369 00371 struct MapSpace_s *prev_light; 00372 00374 struct MapSpace_s *next_light; 00375 00377 uint32 round_tag; 00378 00380 tag_t map_info_count; 00381 00383 uint32 update_tile; 00384 00386 sint32 light_source; 00387 00391 sint32 light_value; 00392 00396 int flags; 00397 00399 uint16 last_damage; 00400 00402 uint16 move_flags; 00403 00405 uint8 light; 00406 00408 uint8 extra_flags; 00409 } MapSpace; 00410 00416 #define MAP_FLAG_OUTDOOR 1 00417 00418 #define MAP_FLAG_UNIQUE 2 00419 00422 #define MAP_FLAG_FIXED_RTIME 4 00423 00424 #define MAP_FLAG_NOMAGIC 8 00425 00426 #define MAP_FLAG_NOPRIEST 16 00427 00428 #define MAP_FLAG_NOHARM 32 00429 00431 #define MAP_FLAG_NOSUMMON 64 00432 00436 #define MAP_FLAG_FIXED_LOGIN 128 00437 00438 #define MAP_FLAG_PLAYER_NO_SAVE 256 00439 00440 #define MAP_FLAG_UNUSED2 1024 00441 00442 #define MAP_FLAG_UNUSED3 2048 00443 00444 #define MAP_FLAG_PVP 4096 00445 00446 #define MAP_FLAG_NO_SAVE 8192 00447 00455 #define MAP_DEFAULT_DARKNESS 0 00456 00458 #define SET_MAP_TILE_VISITED(m, x, y, id) \ 00459 { \ 00460 if ((m)->pathfinding_id != (id)) \ 00461 { \ 00462 (m)->pathfinding_id = (id); \ 00463 memset((m)->bitmap, 0, ((MAP_WIDTH(m) + 31) / 32) * MAP_HEIGHT(m) * sizeof(uint32)); \ 00464 } \ 00465 \ 00466 (m)->bitmap[(x) / 32 + ((MAP_WIDTH(m) + 31) / 32) * (y)] |= (1U << ((x) % 32)); \ 00467 } 00468 00469 #define QUERY_MAP_TILE_VISITED(m, x, y, id) \ 00470 ((m)->pathfinding_id == (id) && ((m)->bitmap[(x) / 32 + ((MAP_WIDTH(m) + 31) / 32) * (y)] & (1U << ((x) % 32)))) 00471 00477 typedef struct regiondef 00478 { 00480 struct regiondef *next; 00481 00486 struct regiondef *parent; 00487 00489 char *name; 00490 00497 char *parent_name; 00498 00502 char *longname; 00503 00505 char *msg; 00506 00508 char *jailmap; 00509 00511 char *map_first; 00512 00514 char *map_bg; 00515 00517 sint16 jailx; 00518 00520 sint16 jaily; 00521 } region; 00522 00525 typedef struct map_event 00526 { 00528 struct map_event *next; 00529 00531 object *event; 00532 00535 struct atrinik_plugin *plugin; 00536 } map_event; 00537 00546 typedef struct mapdef 00547 { 00549 struct mapdef *previous; 00550 00552 struct mapdef *next; 00553 00555 struct mapdef *tile_map[TILED_MAPS]; 00556 00558 char *name; 00559 00561 char *bg_music; 00562 00564 char *weather; 00565 00567 char *tmpname; 00568 00570 char *msg; 00571 00573 shstr *path; 00574 00576 shstr *tile_path[TILED_MAPS]; 00577 00579 MapSpace *spaces; 00580 00582 MapSpace *first_light; 00583 00585 struct regiondef *region; 00586 00588 struct map_event *events; 00589 00591 objectlink *buttons; 00592 00594 object *player_first; 00595 00597 uint32 *bitmap; 00598 00600 uint32 pathfinding_id; 00601 00603 uint32 map_flags; 00604 00606 uint32 reset_time; 00607 00611 uint32 reset_timeout; 00612 00614 sint32 timeout; 00615 00617 uint32 swap_time; 00618 00623 uint32 in_memory; 00624 00626 uint32 traversed; 00627 00633 int darkness; 00634 00638 int light_value; 00639 00643 int difficulty; 00644 00646 int height; 00647 00649 int width; 00650 00658 int enter_x; 00659 00667 int enter_y; 00668 00670 int compressed; 00671 } mapstruct; 00672 00676 typedef struct rv_vector_s 00677 { 00679 unsigned int distance; 00680 00682 int distance_x; 00683 00685 int distance_y; 00686 00688 int direction; 00689 00691 object *part; 00692 } rv_vector; 00693 00699 #define RV_IGNORE_MULTIPART 0x01 00700 #define RV_RECURSIVE_SEARCH 0x02 00701 00702 #define RV_MANHATTAN_DISTANCE 0x00 00703 #define RV_EUCLIDIAN_DISTANCE 0x04 00704 #define RV_DIAGONAL_DISTANCE 0x08 00705 #define RV_NO_DISTANCE (0x08 | 0x04) 00706 00713 #define NORTH 1 00714 00715 #define NORTHEAST 2 00716 00717 #define EAST 3 00718 00719 #define SOUTHEAST 4 00720 00721 #define SOUTH 5 00722 00723 #define SOUTHWEST 6 00724 00725 #define WEST 7 00726 00727 #define NORTHWEST 8 00728 00731 #define OBJECT_IS_HIDDEN(pl, ob) (HAS_EVENT((ob), EVENT_ASK_SHOW) && trigger_event(EVENT_ASK_SHOW, (pl), (ob), NULL, NULL, 0, 0, 0, 0) == 1) 00732 00733 region *first_region; 00734 00735 #endif
1.7.4