Crossfire Server, Trunk
map.h File Reference
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mapdef
struct  MapSpace
struct  regiondef
struct  rv_vector
struct  shopitem


#define AB_NO_PASS   0x04
#define GET_MAP_FACE_OBJ(M, X, Y, L)   ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
#define GET_MAP_FACE_OBJS(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
#define GET_MAP_FLAGS(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].flags)
#define GET_MAP_LIGHT(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].light)
#define GET_MAP_MOVE_BLOCK(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_block)
#define GET_MAP_MOVE_OFF(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_off)
#define GET_MAP_MOVE_ON(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_on)
#define GET_MAP_MOVE_SLOW(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
#define GET_MAP_OB(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].bottom)
#define GET_MAP_PLAYER(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].pl)
#define GET_MAP_TOP(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].top)
#define MAGIC_MAP_SIZE   50
#define MAP_DARKNESS(m)   (m)->darkness
#define MAP_DIFFICULTY(m)   ((m)->difficulty)
#define MAP_ENTER_X(m)   (m)->enter_x
#define MAP_ENTER_Y(m)   (m)->enter_y
#define MAP_FLUSH   0x1
#define MAP_HEIGHT(m)   (m)->height
#define MAP_IN_MEMORY   1
#define MAP_LAYER_FLOOR   0
#define MAP_LAYER_FLY1   8
#define MAP_LAYER_FLY2   9
#define MAP_LAYER_ITEM1   3
#define MAP_LAYER_ITEM2   4
#define MAP_LAYER_ITEM3   5
#define MAP_LAYER_LIVING1   6
#define MAP_LAYER_LIVING2   7
#define MAP_LAYER_NO_PICK1   1
#define MAP_LAYER_NO_PICK2   2
#define MAP_LAYERS   10
#define MAP_LOADING   3
#define MAP_NO_DIFFICULTY   0x4
#define MAP_NOSMOOTH(m)   (m)->nosmooth
#define MAP_OUTDOORS(m)   ((m)->outdoor)
#define MAP_OVERLAY   0x10
#define MAP_PLAYER_UNIQUE   0x2
#define MAP_RESET_TIMEOUT(m)   ((m)->reset_timeout)
#define MAP_SAVING   4
#define MAP_SIZE(m)   map_size(m)
#define MAP_STYLE   0x8
#define MAP_SWAP_TIME(m)   ((m)->swap_time)
#define MAP_SWAPPED   2
#define MAP_TIMEOUT(m)   ((m)->timeout)
#define MAP_TYPE_CHOICE   3
#define MAP_TYPE_DEFAULT   2
#define MAP_TYPE_LEGACY   1
#define MAP_WHEN_RESET(m)   ((m)->reset_time)
#define MAP_WIDTH(m)   (m)->width
#define OUT_OF_REAL_MAP(M, X, Y)   ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
#define P_BLOCKSVIEW   0x01
#define P_IS_ALIVE   0x10
#define P_NEED_UPDATE   0x40
#define P_NEW_MAP   0x200
#define P_NO_CLERIC   0x20
#define P_NO_ERROR   0x80
#define P_NO_MAGIC   0x02
#define P_OUT_OF_MAP   0x100
#define P_PLAYER   0x08
#define SAVE_ERROR_CLOSE   -6
#define SAVE_ERROR_NO_PATH   -4
#define SAVE_ERROR_OK   0
#define SAVE_ERROR_PLAYER   -11
#define SAVE_ERROR_WRITE   -3
#define SAVE_MODE_NORMAL   0
#define SET_MAP_FACE_OBJ(M, X, Y, C, L)   ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
#define SET_MAP_FLAGS(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
#define SET_MAP_LIGHT(M, X, Y, L)   ((M)->spaces[(X)+(M)->width*(Y)].light = L)
#define SET_MAP_MOVE_BLOCK(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
#define SET_MAP_MOVE_OFF(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
#define SET_MAP_MOVE_ON(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
#define SET_MAP_MOVE_SLOW(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
#define SET_MAP_OB(M, X, Y, tmp)   ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
#define SET_MAP_PLAYER(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].pl = C)
#define SET_MAP_TOP(M, X, Y, tmp)   ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))


typedef struct MapSpace MapSpace
typedef struct mapdef mapstruct
typedef struct regiondef region
typedef struct rv_vector rv_vector
typedef struct shopitem shopitems


uint32_t map_size (mapstruct *m)


const char *const map_layer_name [MAP_LAYERS]

Detailed Description

This file contains basic map-related structures and macros.

Definition in file map.h.

Macro Definition Documentation


#define AB_NO_PASS   0x04

Definition at line 236 of file map.h.


#define GET_MAP_FACE_OBJ (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])

Gets the layer face of specified square. Not multitile aware.

Definition at line 185 of file map.h.


#define GET_MAP_FACE_OBJS (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)

Returns the layers array so update_position can just copy the entire array over.

Definition at line 190 of file map.h.


#define GET_MAP_FLAGS (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].flags)

Gets map flags. Not multitile aware.

Definition at line 162 of file map.h.


#define GET_MAP_LIGHT (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].light)

Gets map light. Not multitile aware.

Definition at line 166 of file map.h.


#define GET_MAP_MOVE_BLOCK (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_block)

Gets the blocking state of a square. Not multitile aware.

Definition at line 193 of file map.h.


#define GET_MAP_MOVE_OFF (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_off)

Gets the move_off state of a square. Not multitile aware.

Definition at line 208 of file map.h.


#define GET_MAP_MOVE_ON (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_on)

Gets the move_on state of a square. Not multitile aware.

Definition at line 203 of file map.h.


#define GET_MAP_MOVE_SLOW (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_slow)

Gets the slowing state of a square. Not multitile aware.

Definition at line 198 of file map.h.


#define GET_MAP_OB (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].bottom)

Gets the bottom object on a map. Not multitile aware.

Definition at line 173 of file map.h.


#define GET_MAP_PLAYER (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].pl)

Definition at line 169 of file map.h.


#define GET_MAP_TOP (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].top)

Gets the top object on a map. Not multitile aware.

Definition at line 175 of file map.h.



Definition at line 25 of file map.h.


#define MAGIC_MAP_SIZE   50

Definition at line 24 of file map.h.


#define MAP_DARKNESS (   m)    (m)->darkness

Map darkness used to enforce the MAX_DARKNESS value. but IMO, if it is beyond max value, that should be fixed on the map or in the code.

Definition at line 75 of file map.h.


#define MAP_DIFFICULTY (   m)    ((m)->difficulty)

Definition at line 65 of file map.h.


#define MAP_ENTER_X (   m)    (m)->enter_x

Default X coordinate for map enter.

Definition at line 85 of file map.h.


#define MAP_ENTER_Y (   m)    (m)->enter_y

Default Y coordinate for map enter.

Definition at line 87 of file map.h.


#define MAP_FLUSH   0x1

Always load map from the map directory, and don't do unique items or the like.

Definition at line 96 of file map.h.


#define MAP_HEIGHT (   m)    (m)->height

Map height.

Definition at line 80 of file map.h.


#define MAP_IN_MEMORY   1

Map is fully loaded.

Definition at line 131 of file map.h.


#define MAP_LAYER_FLOOR   0

Definition at line 40 of file map.h.


#define MAP_LAYER_FLY1   8

Flying objects - creatures, spells

Definition at line 48 of file map.h.


#define MAP_LAYER_FLY2   9

Arrows, etc

Definition at line 49 of file map.h.


#define MAP_LAYER_ITEM1   3

Items that can be picked up

Definition at line 43 of file map.h.


#define MAP_LAYER_ITEM2   4

Definition at line 44 of file map.h.


#define MAP_LAYER_ITEM3   5

Definition at line 45 of file map.h.


#define MAP_LAYER_LIVING1   6

Living creatures

Definition at line 46 of file map.h.


#define MAP_LAYER_LIVING2   7

Definition at line 47 of file map.h.


#define MAP_LAYER_NO_PICK1   1

Non pickable ground objects

Definition at line 41 of file map.h.


#define MAP_LAYER_NO_PICK2   2

Non pickable ground objects

Definition at line 42 of file map.h.


#define MAP_LAYERS   10

Definition at line 32 of file map.h.


#define MAP_LOADING   3

This map is being loaded.

Definition at line 133 of file map.h.


#define MAP_NO_DIFFICULTY   0x4

If set then don't compute a map difficulty if it is 0.

Definition at line 98 of file map.h.


#define MAP_NOSMOOTH (   m)    (m)->nosmooth

Definition at line 89 of file map.h.


#define MAP_OUTDOORS (   m)    ((m)->outdoor)

Definition at line 68 of file map.h.


#define MAP_OVERLAY   0x10

Map to load is an overlay. Always put items above floor.

Definition at line 100 of file map.h.


#define MAP_PLAYER_UNIQUE   0x2

This map is player-specific. Don't do any more name translation on it.

Definition at line 97 of file map.h.


#define MAP_RESET_TIMEOUT (   m)    ((m)->reset_timeout)

Definition at line 64 of file map.h.


#define MAP_SAVING   4

Map being saved. Will stop object_remove() from some processing.

Definition at line 134 of file map.h.


#define MAP_SIZE (   m)    map_size(m)

Convenient function - total number of spaces is used in many places.

Definition at line 82 of file map.h.


#define MAP_STYLE   0x8

Active objects shouldn't be put on active list.

Definition at line 99 of file map.h.


#define MAP_SWAP_TIME (   m)    ((m)->swap_time)

Definition at line 67 of file map.h.


#define MAP_SWAPPED   2

Map spaces have been saved to disk.

Definition at line 132 of file map.h.


#define MAP_TIMEOUT (   m)    ((m)->timeout)

Definition at line 66 of file map.h.


#define MAP_TYPE_CHOICE   3

Choice of maps presented to player

Definition at line 59 of file map.h.


#define MAP_TYPE_DEFAULT   2

If no map is specified, where character starts

Definition at line 58 of file map.h.


#define MAP_TYPE_LEGACY   1

These are map subtypes. With new character creation code, additional types are needed. For old character creation method

Definition at line 57 of file map.h.


#define MAP_WHEN_RESET (   m)    ((m)->reset_time)

This is when the map will reset

Definition at line 62 of file map.h.


#define MAP_WIDTH (   m)    (m)->width

Map width.

Definition at line 78 of file map.h.


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

Checks if a square is out of the map. You should really know what you are doing before using this - you should almost always be using out_of_map() instead, which takes into account map tiling.

Definition at line 218 of file map.h.


#define P_BLOCKSVIEW   0x01

This spot blocks the player's view.

Definition at line 227 of file map.h.


#define P_IS_ALIVE   0x10

Something alive is on this space.

Definition at line 238 of file map.h.


#define P_NEED_UPDATE   0x40

This space is out of date.

Definition at line 240 of file map.h.


#define P_NEW_MAP   0x200

Coordinates passed result in a new tiled map.

Definition at line 251 of file map.h.


#define P_NO_CLERIC   0x20

No clerical spells cast here.

Definition at line 239 of file map.h.


#define P_NO_ERROR   0x80

Purely temporary - if set, update_position does not complain if the flags are different.

Definition at line 241 of file map.h.


#define P_NO_MAGIC   0x02

Spells (some) can't pass this object

Definition at line 228 of file map.h.


#define P_OUT_OF_MAP   0x100

This space is outside the map.

Definition at line 250 of file map.h.


#define P_PLAYER   0x08

There is a player on this space

Definition at line 237 of file map.h.


#define SAVE_ERROR_CLOSE   -6

Close error for regular file.

Definition at line 150 of file map.h.


#define SAVE_ERROR_NO_PATH   -4

Map had no path set.

Definition at line 148 of file map.h.



Map to swap isn't in memory.

Definition at line 152 of file map.h.


#define SAVE_ERROR_OK   0

No error.

Definition at line 144 of file map.h.


#define SAVE_ERROR_PLAYER   -11

Player on map to save.

Definition at line 153 of file map.h.



Couldn't create the regular save file.

Definition at line 145 of file map.h.



Couldn't create the file for unique objects.

Definition at line 146 of file map.h.



Couldn't rename unique temporary file.

Definition at line 149 of file map.h.


#define SAVE_ERROR_WRITE   -3

Write error.

Definition at line 147 of file map.h.



If set, objects are not removed while saving.

Definition at line 112 of file map.h.



If set, unpaid items will be saved.

Definition at line 111 of file map.h.



Map is saved from where it was loaded.

Definition at line 122 of file map.h.


#define SAVE_MODE_NORMAL   0

No special handling.

Definition at line 121 of file map.h.



Map is persisted as an overlay.

Definition at line 123 of file map.h.


#define SET_MAP_FACE_OBJ (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)

Sets the layer face of specified square. Not multitile aware.

Definition at line 183 of file map.h.


#define SET_MAP_FLAGS (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].flags = C)

Sets map flags. Not multitile aware.

Definition at line 164 of file map.h.


#define SET_MAP_LIGHT (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].light = L)

Sets map light. Not multitile aware.

Definition at line 168 of file map.h.


#define SET_MAP_MOVE_BLOCK (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)

Sets the blocking state of a square. Not multitile aware.

Definition at line 195 of file map.h.


#define SET_MAP_MOVE_OFF (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)

Sets the move_off state of a square. Not multitile aware.

Definition at line 210 of file map.h.


#define SET_MAP_MOVE_ON (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)

Sets the move_on state of a square. Not multitile aware.

Definition at line 205 of file map.h.


#define SET_MAP_MOVE_SLOW (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)

Sets the slowing state of a square. Not multitile aware.

Definition at line 200 of file map.h.


#define SET_MAP_OB (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))

Sets the bottom object on a map. Not multitile aware.

Definition at line 178 of file map.h.


#define SET_MAP_PLAYER (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].pl = C)

Definition at line 170 of file map.h.


#define SET_MAP_TOP (   M,
)    ((M)->spaces[(X)+(M)->width*(Y)].top = (tmp))

Sets the top object on a map. Not multitile aware.

Definition at line 180 of file map.h.

Typedef Documentation

◆ MapSpace

typedef struct MapSpace MapSpace

This structure contains all information related to one map square.

◆ mapstruct

typedef struct mapdef mapstruct

This is a game-map.

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.

◆ region

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 definiton, so they have to appear here in the headers, before the mapdef

◆ rv_vector

typedef struct rv_vector rv_vector

This is used by get_rangevector to determine where the other creature is. get_rangevector takes into account map tiling, so you just can not look the the map coordinates and get the righte value. distance_x/y are distance away, which can be negative. direction is the crossfire direction scheme that the creature should head. part is the part of the monster that is closest. Note: distance should be always >=0. I changed it to UINT. MT

◆ shopitems

typedef struct shopitem shopitems

Shop-related information for a map. This is one item type the shop will deal in, and the price-chance.

Function Documentation

◆ map_size()

uint32_t map_size ( mapstruct m)

Calculate map size without intermediate sign extension.

Definition at line 825 of file map.cpp.

References m.

Referenced by allocate_map(), command_style_map_info(), and malloc_info().

+ Here is the caller graph for this function:

Variable Documentation

◆ map_layer_name

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, names are duplicated to correspond to that layer.

Definition at line 45 of file map.cpp.

Referenced by get_ob_diff(), and while().