Atrinik Server 2.5
Data Structures | Defines | Typedefs | Variables
include/map.h File Reference

Go to the source code of this file.

Data Structures

struct  MapSpace_s
struct  regiondef
struct  map_event
struct  mapdef
struct  rv_vector_s

Defines

#define MAX_DARKNESS   7
#define MAP_PLAYER_MAP   1
#define LAYER_SYS   0
#define LAYER_FLOOR   1
#define LAYER_FMASK   2
#define LAYER_ITEM   3
#define LAYER_ITEM2   4
#define LAYER_WALL   5
#define LAYER_LIVING   6
#define LAYER_EFFECT   7
#define NUM_LAYERS   7
#define MAP_WHEN_RESET(m)   ((m)->reset_time)
#define MAP_RESET_TIMEOUT(m)   ((m)->reset_timeout)
#define MAP_DIFFICULTY(m)   ((m)->difficulty)
#define MAP_TIMEOUT(m)   ((m)->timeout)
#define MAP_SWAP_TIME(m)   ((m)->swap_time)
#define MAP_OUTDOORS(m)   ((m)->map_flags & MAP_FLAG_OUTDOOR)
#define MAP_UNIQUE(m)   ((m)->map_flags & MAP_FLAG_UNIQUE)
#define MAP_FIXED_RESETTIME(m)   ((m)->map_flags & MAP_FLAG_FIXED_RTIME)
#define MAP_NOSAVE(m)   ((m)->map_flags & MAP_FLAG_NO_SAVE)
#define MAP_NOMAGIC(m)   ((m)->map_flags & MAP_FLAG_NOMAGIC)
#define MAP_NOPRIEST(m)   ((m)->map_flags & MAP_FLAG_NOPRIEST)
#define MAP_NOHARM(m)   ((m)->map_flags & MAP_FLAG_NOHARM)
#define MAP_NOSUMMON(m)   ((m)->map_flags & MAP_FLAG_NOSUMMON)
#define MAP_FIXEDLOGIN(m)   ((m)->map_flags & MAP_FLAG_FIXED_LOGIN)
#define MAP_PLAYER_NO_SAVE(m)   ((m)->map_flags & MAP_FLAG_PLAYER_NO_SAVE)
#define MAP_PVP(m)   ((m)->map_flags & MAP_FLAG_PVP)
#define MAP_DARKNESS(m)   (m)->darkness
#define MAP_WIDTH(m)   (m)->width
#define MAP_HEIGHT(m)   (m)->height
#define MAP_SIZE(m)   ((m)->width * (m)->height)
#define MAP_ENTER_X(m)   (m)->enter_x
#define MAP_ENTER_Y(m)   (m)->enter_y
#define MAP_FLUSH   0x1
#define MAP_PLAYER_UNIQUE   0x2
#define MAP_BLOCK   0x4
#define MAP_STYLE   0x8
#define MAP_ARTIFACT   0x20
#define MAP_NAME_SHARED   0x40
#define MAP_ORIGINAL   0x80
#define MAP_IN_MEMORY   1
#define MAP_SWAPPED   2
#define MAP_LOADING   3
#define MAP_SAVING   4
#define GET_MAP_SPACE_PTR(M_, X_, Y_)   (&((M_)->spaces[(X_) + (M_)->width * (Y_)]))
#define GET_MAP_SPACE_FIRST(M_)   ((M_)->first)
#define GET_MAP_SPACE_LAST(M_)   ((M_)->last)
#define GET_MAP_SPACE_LAYER(M_, L_)   ((M_)->layer[L_])
#define SET_MAP_SPACE_FIRST(M_, O_)   ((M_)->first = (O_))
#define SET_MAP_SPACE_LAST(M_, O_)   ((M_)->last = (O_))
#define SET_MAP_SPACE_LAYER(M_, L_, O_)   ((M_)->layer[L_] = (O_))
#define GET_MAP_UPDATE_COUNTER(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].update_tile)
#define INC_MAP_UPDATE_COUNTER(M, X, Y)   ((M)->spaces[((X) + (M)->width * (Y))].update_tile++)
#define GET_MAP_MOVE_FLAGS(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].move_flags)
#define SET_MAP_MOVE_FLAGS(M, X, Y, C)   ((M)->spaces[(X) + (M)->width * (Y)].move_flags = C)
#define GET_MAP_FLAGS(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].flags)
#define SET_MAP_FLAGS(M, X, Y, C)   ((M)->spaces[(X) + (M)->width * (Y)].flags = C)
#define GET_MAP_LIGHT(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].light)
#define SET_MAP_LIGHT(M, X, Y, L)   ((M)->spaces[(X) + (M)->width * (Y)].light = (sint8) L)
#define GET_MAP_OB(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].first)
#define GET_MAP_OB_LAST(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].last)
#define GET_MAP_OB_LAYER(_M_, _X_, _Y_, _Z_)   ((_M_)->spaces[(_X_) + (_M_)->width * (_Y_)].layer[_Z_])
#define get_map_ob   GET_MAP_OB
#define SET_MAP_OB(M, X, Y, tmp)   ((M)->spaces[(X) + (M)->width * (Y)].first = (tmp))
#define SET_MAP_OB_LAST(M, X, Y, tmp)   ((M)->spaces[(X) + (M)->width * (Y)].last = (tmp))
#define SET_MAP_OB_LAYER(_M_, _X_, _Y_, _Z_, tmp)   ((_M_)->spaces[(_X_) + (_M_)->width * (_Y_)].layer[_Z_] = (tmp))
#define set_map_ob   SET_MAP_OB
#define SET_MAP_DAMAGE(M, X, Y, tmp)   ((M)->spaces[(X) + (M)->width * (Y)].last_damage = (uint16) (tmp))
#define GET_MAP_DAMAGE(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].last_damage)
#define SET_MAP_RTAG(M, X, Y, tmp)   ((M)->spaces[(X) + (M)->width * (Y)].round_tag = (uint32) (tmp))
#define GET_MAP_RTAG(M, X, Y)   ((M)->spaces[(X) + (M)->width * (Y)].round_tag)
#define GET_BOTTOM_MAP_OB(O)   ((O)->map ? GET_MAP_OB((O)->map, (O)->x, (O)->y) : NULL)
#define FFLAG_SLEEP   0x01
#define FFLAG_CONFUSED   0x02
#define FFLAG_PARALYZED   0x04
#define FFLAG_SCARED   0x08
#define FFLAG_BLINDED   0x10
#define FFLAG_INVISIBLE   0x20
#define FFLAG_ETHEREAL   0x40
#define FFLAG_PROBE   0x80
#define OUT_OF_REAL_MAP(M, X, Y)   ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
#define P_BLOCKSVIEW   0x01
#define P_NO_MAGIC   0x02
#define P_NO_PASS   0x04
#define P_IS_PLAYER   0x08
#define P_IS_ALIVE   0x10
#define P_NO_CLERIC   0x20
#define P_PLAYER_ONLY   0x40
#define P_DOOR_CLOSED   0x80
#define P_CHECK_INV   0x100
#define P_NO_PVP   0x200
#define P_PASS_THRU   0x400
#define P_MAGIC_EAR   0x800
#define P_WALK_ON   0x1000
#define P_WALK_OFF   0x2000
#define P_FLY_OFF   0x4000
#define P_FLY_ON   0x8000
#define P_MAGIC_MIRROR   0x10000
#define P_OUTDOOR   0x20000
#define P_OUT_OF_MAP   0x4000000
#define P_FLAGS_ONLY   0x8000000
#define P_FLAGS_UPDATE   0x10000000
#define P_NEED_UPDATE   0x20000000
#define P_NO_ERROR   0x40000000
#define P_NO_TERRAIN   0x80000000
#define MSP_EXTRA_NO_HARM   1
#define MSP_EXTRA_NO_PVP   2
#define MSP_EXTRA_NO_MAGIC   4
#define MSP_EXTRA_NO_CLERIC   8
#define MAP_FLAG_OUTDOOR   1
#define MAP_FLAG_UNIQUE   2
#define MAP_FLAG_FIXED_RTIME   4
#define MAP_FLAG_NOMAGIC   8
#define MAP_FLAG_NOPRIEST   16
#define MAP_FLAG_NOHARM   32
#define MAP_FLAG_NOSUMMON   64
#define MAP_FLAG_FIXED_LOGIN   128
#define MAP_FLAG_PLAYER_NO_SAVE   256
#define MAP_FLAG_UNUSED2   1024
#define MAP_FLAG_UNUSED3   2048
#define MAP_FLAG_PVP   4096
#define MAP_FLAG_NO_SAVE   8192
#define MAP_DEFAULT_DARKNESS   0
#define SET_MAP_TILE_VISITED(m, x, y, id)
#define QUERY_MAP_TILE_VISITED(m, x, y, id)   ((m)->pathfinding_id == (id) && ((m)->bitmap[(x) / 32 + ((MAP_WIDTH(m) + 31) / 32) * (y)] & (1U << ((x) % 32))))
#define RV_IGNORE_MULTIPART   0x01
#define RV_RECURSIVE_SEARCH   0x02
#define RV_MANHATTAN_DISTANCE   0x00
#define RV_EUCLIDIAN_DISTANCE   0x04
#define RV_DIAGONAL_DISTANCE   0x08
#define RV_NO_DISTANCE   (0x08 | 0x04)
#define NORTH   1
#define NORTHEAST   2
#define EAST   3
#define SOUTHEAST   4
#define SOUTH   5
#define SOUTHWEST   6
#define WEST   7
#define NORTHWEST   8
#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)

Typedefs

typedef struct MapSpace_s MapSpace
typedef struct regiondef region
typedef struct map_event map_event
typedef struct mapdef mapstruct
typedef struct rv_vector_s rv_vector

Variables

int global_darkness_table [MAX_DARKNESS+1]
int map_tiled_reverse [TILED_MAPS]
regionfirst_region

Detailed Description

The mapstruct is allocated each time a new map is opened. It contains pointers (very indirectly) to all objects on the map.

Definition in file map.h.


Define Documentation

#define MAP_PLAYER_MAP   1

For exit objects: this is a player unique map

Definition at line 41 of file map.h.

#define MAX_DARKNESS   7

Number of darkness level. Add +1 for "total dark"

Definition at line 35 of file map.h.

#define NUM_LAYERS   7

The number of object layers.

Definition at line 67 of file map.h.

#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)

Check if 'pl' cannot see 'ob' due to it being hidden by plugin.

Definition at line 731 of file map.h.

#define OUT_OF_REAL_MAP (   M,
  X,
 
)    ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)

You should really know what you are doing before using this - you should almost always be using get_map_from_coord() instead, which takes into account map tiling.

Definition at line 260 of file map.h.

#define SET_MAP_TILE_VISITED (   m,
  x,
  y,
  id 
)
Value:
{                                                                                            \
    if ((m)->pathfinding_id != (id))                                                         \
    {                                                                                        \
        (m)->pathfinding_id = (id);                                                          \
        memset((m)->bitmap, 0, ((MAP_WIDTH(m) + 31) / 32) * MAP_HEIGHT(m) * sizeof(uint32)); \
    }                                                                                        \
                                                                                             \
    (m)->bitmap[(x) / 32 + ((MAP_WIDTH(m) + 31) / 32) * (y)] |= (1U << ((x) % 32));          \
}

Definition at line 458 of file map.h.


Typedef Documentation

typedef struct map_event map_event

A single map event, holding a pointer to map event object on map.

typedef struct MapSpace_s MapSpace

Single tile on a map

typedef struct mapdef mapstruct

In general, code should always use the macros above (or functions in map.c) to access many of the values in the map structure. Failure to do this will almost certainly break various features.

You may think it is safe to look at width and height values directly (or even through the macros), but doing so will completely break map tiling.

typedef struct regiondef region

This is a game region.

Each map is in a given region of the game world and links to a region definition.

typedef struct rv_vector_s rv_vector

This is used by get_rangevector() to determine where the other creature is.