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  MapSpace
 
struct  mapstruct
 
struct  region
 
struct  rv_vector
 
struct  shopitems
 

Macros

#define AB_NO_PASS   0x04
 
#define GET_MAP_FACE_OBJ(M, X, Y, L)   (map_space(M, X, Y)->faces_obj[L])
 
#define GET_MAP_FACE_OBJS(M, X, Y)   (map_space(M, X, Y)->faces_obj)
 
#define GET_MAP_FLAGS(M, X, Y)   (map_space(M, X, Y)->flags)
 
#define GET_MAP_LIGHT(M, X, Y)   (map_space(M, X, Y)->light)
 
#define GET_MAP_MOVE_BLOCK(M, X, Y)   (map_space(M, X, Y)->move_block)
 
#define GET_MAP_MOVE_OFF(M, X, Y)   (map_space(M, X, Y)->move_off)
 
#define GET_MAP_MOVE_ON(M, X, Y)   (map_space(M, X, Y)->move_on)
 
#define GET_MAP_MOVE_SLOW(M, X, Y)   (map_space(M, X, Y)->move_slow)
 
#define GET_MAP_OB(M, X, Y)   (map_space(M, X, Y)->bottom)
 
#define GET_MAP_PLAYER(M, X, Y)   (map_space(M, X, Y)->pl)
 
#define GET_MAP_TOP(M, X, Y)   (map_space(M, X, Y)->top)
 
#define MAGIC_MAP_HALF   MAGIC_MAP_SIZE/2
 
#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_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_NOT_IN_MEMORY   -10
 
#define SAVE_ERROR_OK   0
 
#define SAVE_ERROR_PLAYER   -11
 
#define SAVE_ERROR_RCREATION   -1
 
#define SAVE_ERROR_UCREATION   -2
 
#define SAVE_ERROR_URENAME   -5
 
#define SAVE_ERROR_WRITE   -3
 
#define SAVE_FLAG_NO_REMOVE   2
 
#define SAVE_FLAG_SAVE_UNPAID   1
 
#define SAVE_MODE_INPLACE   1
 
#define SAVE_MODE_NORMAL   0
 
#define SAVE_MODE_OVERLAY   2
 
#define SET_MAP_FACE_OBJ(M, X, Y, C, L)   (map_space(M, X, Y)->faces_obj[L] = C)
 
#define SET_MAP_FLAGS(M, X, Y, C)   (map_space(M, X, Y)->flags = C)
 
#define SET_MAP_LIGHT(M, X, Y, L)   (map_space(M, X, Y)->light = L)
 
#define SET_MAP_MOVE_BLOCK(M, X, Y, C)   (map_space(M, X, Y)->move_block = C)
 
#define SET_MAP_MOVE_OFF(M, X, Y, C)   (map_space(M, X, Y)->move_off = C)
 
#define SET_MAP_MOVE_ON(M, X, Y, C)   (map_space(M, X, Y)->move_on = C)
 
#define SET_MAP_MOVE_SLOW(M, X, Y, C)   (map_space(M, X, Y)->move_slow = C)
 
#define SET_MAP_OB(M, X, Y, tmp)   (map_space(M, X, Y)->bottom = (tmp))
 
#define SET_MAP_PLAYER(M, X, Y, C)   (map_space(M, X, Y)->pl = C)
 
#define SET_MAP_TOP(M, X, Y, tmp)   (map_space(M, X, Y)->top = (tmp))
 

Functions

bool map_path_unique (const char *name)
 
void map_reset_swap (mapstruct *m)
 
uint32_t map_size (mapstruct *m)
 
MapSpacemap_space (const mapstruct *m, int x, int y)
 

Variables

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

◆ AB_NO_PASS

#define AB_NO_PASS   0x04

Definition at line 233 of file map.h.

◆ GET_MAP_FACE_OBJ

#define GET_MAP_FACE_OBJ (   M,
  X,
  Y,
 
)    (map_space(M, X, Y)->faces_obj[L])

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

Definition at line 182 of file map.h.

◆ GET_MAP_FACE_OBJS

#define GET_MAP_FACE_OBJS (   M,
  X,
 
)    (map_space(M, X, Y)->faces_obj)

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

Definition at line 187 of file map.h.

◆ GET_MAP_FLAGS

#define GET_MAP_FLAGS (   M,
  X,
 
)    (map_space(M, X, Y)->flags)

Gets map flags. Not multitile aware.

Definition at line 157 of file map.h.

◆ GET_MAP_LIGHT

#define GET_MAP_LIGHT (   M,
  X,
 
)    (map_space(M, X, Y)->light)

Gets map light. Not multitile aware.

Definition at line 162 of file map.h.

◆ GET_MAP_MOVE_BLOCK

#define GET_MAP_MOVE_BLOCK (   M,
  X,
 
)    (map_space(M, X, Y)->move_block)

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

Definition at line 190 of file map.h.

◆ GET_MAP_MOVE_OFF

#define GET_MAP_MOVE_OFF (   M,
  X,
 
)    (map_space(M, X, Y)->move_off)

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

Definition at line 205 of file map.h.

◆ GET_MAP_MOVE_ON

#define GET_MAP_MOVE_ON (   M,
  X,
 
)    (map_space(M, X, Y)->move_on)

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

Definition at line 200 of file map.h.

◆ GET_MAP_MOVE_SLOW

#define GET_MAP_MOVE_SLOW (   M,
  X,
 
)    (map_space(M, X, Y)->move_slow)

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

Definition at line 195 of file map.h.

◆ GET_MAP_OB

#define GET_MAP_OB (   M,
  X,
 
)    (map_space(M, X, Y)->bottom)

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

Definition at line 170 of file map.h.

◆ GET_MAP_PLAYER

#define GET_MAP_PLAYER (   M,
  X,
 
)    (map_space(M, X, Y)->pl)

Definition at line 166 of file map.h.

◆ GET_MAP_TOP

#define GET_MAP_TOP (   M,
  X,
 
)    (map_space(M, X, Y)->top)

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

Definition at line 172 of file map.h.

◆ MAGIC_MAP_HALF

#define MAGIC_MAP_HALF   MAGIC_MAP_SIZE/2

Definition at line 25 of file map.h.

◆ MAGIC_MAP_SIZE

#define MAGIC_MAP_SIZE   50

Definition at line 24 of file map.h.

◆ MAP_DARKNESS

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

Map darkness level (0-MAX_DARKNESS)

Definition at line 70 of file map.h.

◆ MAP_DIFFICULTY

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

Definition at line 65 of file map.h.

◆ MAP_ENTER_X

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

Default X coordinate for map enter.

Definition at line 80 of file map.h.

◆ MAP_ENTER_Y

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

Default Y coordinate for map enter.

Definition at line 82 of file map.h.

◆ MAP_FLUSH

#define MAP_FLUSH   0x1

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

Definition at line 91 of file map.h.

◆ MAP_HEIGHT

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

Map height.

Definition at line 75 of file map.h.

◆ MAP_IN_MEMORY

#define MAP_IN_MEMORY   1

Map is fully loaded.

Definition at line 126 of file map.h.

◆ MAP_LAYER_FLOOR

#define MAP_LAYER_FLOOR   0

Definition at line 40 of file map.h.

◆ MAP_LAYER_FLY1

#define MAP_LAYER_FLY1   8

Flying objects - creatures, spells

Definition at line 48 of file map.h.

◆ MAP_LAYER_FLY2

#define MAP_LAYER_FLY2   9

Arrows, etc

Definition at line 49 of file map.h.

◆ MAP_LAYER_ITEM1

#define MAP_LAYER_ITEM1   3

Items that can be picked up

Definition at line 43 of file map.h.

◆ MAP_LAYER_ITEM2

#define MAP_LAYER_ITEM2   4

Definition at line 44 of file map.h.

◆ MAP_LAYER_ITEM3

#define MAP_LAYER_ITEM3   5

Definition at line 45 of file map.h.

◆ MAP_LAYER_LIVING1

#define MAP_LAYER_LIVING1   6

Living creatures

Definition at line 46 of file map.h.

◆ MAP_LAYER_LIVING2

#define MAP_LAYER_LIVING2   7

Definition at line 47 of file map.h.

◆ MAP_LAYER_NO_PICK1

#define MAP_LAYER_NO_PICK1   1

Non pickable ground objects

Definition at line 41 of file map.h.

◆ MAP_LAYER_NO_PICK2

#define MAP_LAYER_NO_PICK2   2

Non pickable ground objects

Definition at line 42 of file map.h.

◆ MAP_LAYERS

#define MAP_LAYERS   10

Definition at line 32 of file map.h.

◆ MAP_LOADING

#define MAP_LOADING   3

This map is being loaded.

Definition at line 128 of file map.h.

◆ MAP_NO_DIFFICULTY

#define MAP_NO_DIFFICULTY   0x4

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

Definition at line 93 of file map.h.

◆ MAP_NOSMOOTH

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

Definition at line 84 of file map.h.

◆ MAP_OUTDOORS

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

Definition at line 67 of file map.h.

◆ MAP_OVERLAY

#define MAP_OVERLAY   0x10

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

Definition at line 95 of file map.h.

◆ MAP_PLAYER_UNIQUE

#define MAP_PLAYER_UNIQUE   0x2

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

Definition at line 92 of file map.h.

◆ MAP_RESET_TIMEOUT

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

Definition at line 64 of file map.h.

◆ MAP_SAVING

#define MAP_SAVING   4

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

Definition at line 129 of file map.h.

◆ MAP_SIZE

#define MAP_SIZE (   m)    map_size(m)

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

Definition at line 77 of file map.h.

◆ MAP_STYLE

#define MAP_STYLE   0x8

Active objects shouldn't be put on active list.

Definition at line 94 of file map.h.

◆ MAP_SWAPPED

#define MAP_SWAPPED   2

Map spaces have been saved to disk.

Definition at line 127 of file map.h.

◆ MAP_TIMEOUT

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

Definition at line 66 of file map.h.

◆ MAP_TYPE_CHOICE

#define MAP_TYPE_CHOICE   3

Choice of maps presented to player

Definition at line 59 of file map.h.

◆ MAP_TYPE_DEFAULT

#define MAP_TYPE_DEFAULT   2

If no map is specified, where character starts

Definition at line 58 of file map.h.

◆ MAP_TYPE_LEGACY

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

◆ MAP_WHEN_RESET

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

This is when the map will reset

Definition at line 62 of file map.h.

◆ MAP_WIDTH

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

Map width.

Definition at line 73 of file map.h.

◆ OUT_OF_REAL_MAP

#define OUT_OF_REAL_MAP (   M,
  X,
 
)    ((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 215 of file map.h.

◆ P_BLOCKSVIEW

#define P_BLOCKSVIEW   0x01

This spot blocks the player's view.

Definition at line 224 of file map.h.

◆ P_IS_ALIVE

#define P_IS_ALIVE   0x10

Something alive is on this space.

Definition at line 235 of file map.h.

◆ P_NEED_UPDATE

#define P_NEED_UPDATE   0x40

This space is out of date.

Definition at line 237 of file map.h.

◆ P_NEW_MAP

#define P_NEW_MAP   0x200

Coordinates passed result in a new tiled map.

Definition at line 248 of file map.h.

◆ P_NO_CLERIC

#define P_NO_CLERIC   0x20

No clerical spells cast here.

Definition at line 236 of file map.h.

◆ P_NO_ERROR

#define P_NO_ERROR   0x80

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

Definition at line 238 of file map.h.

◆ P_NO_MAGIC

#define P_NO_MAGIC   0x02

Spells (some) can't pass this object

Definition at line 225 of file map.h.

◆ P_OUT_OF_MAP

#define P_OUT_OF_MAP   0x100

This space is outside the map.

Definition at line 247 of file map.h.

◆ P_PLAYER

#define P_PLAYER   0x08

There is a player on this space

Definition at line 234 of file map.h.

◆ SAVE_ERROR_CLOSE

#define SAVE_ERROR_CLOSE   -6

Close error for regular file.

Definition at line 145 of file map.h.

◆ SAVE_ERROR_NO_PATH

#define SAVE_ERROR_NO_PATH   -4

Map had no path set.

Definition at line 143 of file map.h.

◆ SAVE_ERROR_NOT_IN_MEMORY

#define SAVE_ERROR_NOT_IN_MEMORY   -10

Map to swap isn't in memory.

Definition at line 147 of file map.h.

◆ SAVE_ERROR_OK

#define SAVE_ERROR_OK   0

No error.

Definition at line 139 of file map.h.

◆ SAVE_ERROR_PLAYER

#define SAVE_ERROR_PLAYER   -11

Player on map to save.

Definition at line 148 of file map.h.

◆ SAVE_ERROR_RCREATION

#define SAVE_ERROR_RCREATION   -1

Couldn't create the regular save file.

Definition at line 140 of file map.h.

◆ SAVE_ERROR_UCREATION

#define SAVE_ERROR_UCREATION   -2

Couldn't create the file for unique objects.

Definition at line 141 of file map.h.

◆ SAVE_ERROR_URENAME

#define SAVE_ERROR_URENAME   -5

Couldn't rename unique temporary file.

Definition at line 144 of file map.h.

◆ SAVE_ERROR_WRITE

#define SAVE_ERROR_WRITE   -3

Write error.

Definition at line 142 of file map.h.

◆ SAVE_FLAG_NO_REMOVE

#define SAVE_FLAG_NO_REMOVE   2

If set, objects are not removed while saving.

Definition at line 107 of file map.h.

◆ SAVE_FLAG_SAVE_UNPAID

#define SAVE_FLAG_SAVE_UNPAID   1

If set, unpaid items will be saved.

Definition at line 106 of file map.h.

◆ SAVE_MODE_INPLACE

#define SAVE_MODE_INPLACE   1

Map is saved from where it was loaded.

Definition at line 117 of file map.h.

◆ SAVE_MODE_NORMAL

#define SAVE_MODE_NORMAL   0

No special handling.

Definition at line 116 of file map.h.

◆ SAVE_MODE_OVERLAY

#define SAVE_MODE_OVERLAY   2

Map is persisted as an overlay.

Definition at line 118 of file map.h.

◆ SET_MAP_FACE_OBJ

#define SET_MAP_FACE_OBJ (   M,
  X,
  Y,
  C,
 
)    (map_space(M, X, Y)->faces_obj[L] = C)

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

Definition at line 180 of file map.h.

◆ SET_MAP_FLAGS

#define SET_MAP_FLAGS (   M,
  X,
  Y,
  C 
)    (map_space(M, X, Y)->flags = C)

Sets map flags. Not multitile aware.

Definition at line 159 of file map.h.

◆ SET_MAP_LIGHT

#define SET_MAP_LIGHT (   M,
  X,
  Y,
 
)    (map_space(M, X, Y)->light = L)

Sets map light. Not multitile aware.

Definition at line 164 of file map.h.

◆ SET_MAP_MOVE_BLOCK

#define SET_MAP_MOVE_BLOCK (   M,
  X,
  Y,
  C 
)    (map_space(M, X, Y)->move_block = C)

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

Definition at line 192 of file map.h.

◆ SET_MAP_MOVE_OFF

#define SET_MAP_MOVE_OFF (   M,
  X,
  Y,
  C 
)    (map_space(M, X, Y)->move_off = C)

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

Definition at line 207 of file map.h.

◆ SET_MAP_MOVE_ON

#define SET_MAP_MOVE_ON (   M,
  X,
  Y,
  C 
)    (map_space(M, X, Y)->move_on = C)

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

Definition at line 202 of file map.h.

◆ SET_MAP_MOVE_SLOW

#define SET_MAP_MOVE_SLOW (   M,
  X,
  Y,
  C 
)    (map_space(M, X, Y)->move_slow = C)

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

Definition at line 197 of file map.h.

◆ SET_MAP_OB

#define SET_MAP_OB (   M,
  X,
  Y,
  tmp 
)    (map_space(M, X, Y)->bottom = (tmp))

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

Definition at line 175 of file map.h.

◆ SET_MAP_PLAYER

#define SET_MAP_PLAYER (   M,
  X,
  Y,
  C 
)    (map_space(M, X, Y)->pl = C)

Definition at line 167 of file map.h.

◆ SET_MAP_TOP

#define SET_MAP_TOP (   M,
  X,
  Y,
  tmp 
)    (map_space(M, X, Y)->top = (tmp))

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

Definition at line 177 of file map.h.

Function Documentation

◆ map_path_unique()

bool map_path_unique ( const char *  path)

Return true if the given map path leads to a unique map. This is needed to correctly load a map with the MAP_UNIQUE flag set, because there are some contexts in which only a map path is available.

Definition at line 2683 of file map.cpp.

References python_init::path.

Referenced by cast_create_town_portal(), enter_exit(), and town_portal_destroy_existing().

+ Here is the caller graph for this function:

◆ map_reset_swap()

void map_reset_swap ( mapstruct m)

Call this when an in-memory map is used or referenced. Helps inform which maps to swap.

Definition at line 1750 of file map.cpp.

References m, and MAP_MINTIMEOUT.

Referenced by draw_client_map(), and ready_map_name().

+ Here is the caller graph for this function:

◆ map_size()

uint32_t map_size ( mapstruct m)

Calculate map size without intermediate sign extension.

Definition at line 798 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:

◆ map_space()

MapSpace* map_space ( const mapstruct m,
int  x,
int  y 
)

Definition at line 2687 of file map.cpp.

References m, OUT_OF_REAL_MAP, diamondslots::x, and diamondslots::y.

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 46 of file map.cpp.

Referenced by get_ob_diff(), and while().