Crossfire Server, Trunk  R20513
Data Structures | Macros | Typedefs | Functions | Variables
map.h File Reference

This file contains basic map-related structures and macros. More...

This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mapdef
 This is a game-map. More...
 
struct  MapSpace
 This structure contains all information related to one map square. More...
 
struct  regiondef
 This is a game region. More...
 
struct  rv_vector
 This is used by get_rangevector to determine where the other creature is. More...
 
struct  shopitem
 Shop-related information for a map. More...
 

Macros

#define AB_NO_PASS   0x04
 
#define GET_MAP_FACE_OBJ(M, X, Y, L)   ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L])
 Gets the layer face of specified square. More...
 
#define GET_MAP_FACE_OBJS(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].faces_obj)
 Returns the layers array so update_position can just copy the entire array over. More...
 
#define GET_MAP_FLAGS(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].flags)
 Gets map flags. More...
 
#define GET_MAP_LIGHT(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].light)
 Gets map light. More...
 
#define GET_MAP_MOVE_BLOCK(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_block)
 Gets the blocking state of a square. More...
 
#define GET_MAP_MOVE_OFF(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_off)
 Gets the move_off state of a square. More...
 
#define GET_MAP_MOVE_ON(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_on)
 Gets the move_on state of a square. More...
 
#define GET_MAP_MOVE_SLOW(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].move_slow)
 Gets the slowing state of a square. More...
 
#define GET_MAP_OB(M, X, Y)   ((M)->spaces[(X)+(M)->width*(Y)].bottom)
 Gets the bottom object on a map. More...
 
#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)
 Gets the top object on a map. More...
 
#define MAGIC_MAP_HALF   MAGIC_MAP_SIZE/2
 
#define MAGIC_MAP_SIZE   50
 
#define MAP_DARKNESS(m)   (m)->darkness
 Map darkness used to enforce the MAX_DARKNESS value. More...
 
#define MAP_DIFFICULTY(m)   ((m)->difficulty)
 
#define MAP_ENTER_X(m)   (m)->enter_x
 Default X coordinate for map enter. More...
 
#define MAP_ENTER_Y(m)   (m)->enter_y
 Default Y coordinate for map enter. More...
 
#define MAP_FLUSH   0x1
 Always load map from the map directory, and don't do unique items or the like. More...
 
#define MAP_HEIGHT(m)   (m)->height
 Map height. More...
 
#define MAP_IN_MEMORY   1
 Map is fully loaded. More...
 
#define MAP_LAYER_FLOOR   0
 
#define MAP_LAYER_FLY1   8
 Flying objects - creatures, spells. More...
 
#define MAP_LAYER_FLY2   9
 Arrows, etc. More...
 
#define MAP_LAYER_ITEM1   3
 Items that can be picked up. More...
 
#define MAP_LAYER_ITEM2   4
 
#define MAP_LAYER_ITEM3   5
 
#define MAP_LAYER_LIVING1   6
 Living creatures. More...
 
#define MAP_LAYER_LIVING2   7
 
#define MAP_LAYER_NO_PICK1   1
 Non pickable ground objects. More...
 
#define MAP_LAYER_NO_PICK2   2
 Non pickable ground objects. More...
 
#define MAP_LAYERS   10
 
#define MAP_LOADING   3
 This map is being loaded. More...
 
#define MAP_NOSMOOTH(m)   (m)->nosmooth
 
#define MAP_OUTDOORS(m)   ((m)->outdoor)
 
#define MAP_OVERLAY   0x10
 Map to load is an overlay. More...
 
#define MAP_PLAYER_UNIQUE   0x2
 This map is player-specific. More...
 
#define MAP_RESET_TIMEOUT(m)   ((m)->reset_timeout)
 
#define MAP_SAVING   4
 Map being saved. More...
 
#define MAP_SIZE(m)   map_size(m)
 Convenient function - total number of spaces is used in many places. More...
 
#define MAP_STYLE   0x8
 Active objects shouldn't be put on active list. More...
 
#define MAP_SWAP_TIME(m)   ((m)->swap_time)
 
#define MAP_SWAPPED   2
 Map spaces have been saved to disk. More...
 
#define MAP_TIMEOUT(m)   ((m)->timeout)
 
#define MAP_TYPE_CHOICE   3
 Choice of maps presented to player. More...
 
#define MAP_TYPE_DEFAULT   2
 If no map is specified, where character starts. More...
 
#define MAP_TYPE_LEGACY   1
 These are map subtypes. More...
 
#define MAP_WHEN_RESET(m)   ((m)->reset_time)
 This is when the map will reset. More...
 
#define MAP_WIDTH(m)   (m)->width
 Map width. More...
 
#define OUT_OF_REAL_MAP(M, X, Y)   ((X) < 0 || (Y) < 0 || (X) >= (M)->width || (Y) >= (M)->height)
 Checks if a square is out of the map. More...
 
#define P_BLOCKSVIEW   0x01
 This spot blocks the player's view. More...
 
#define P_IS_ALIVE   0x10
 Something alive is on this space. More...
 
#define P_NEED_UPDATE   0x40
 This space is out of date. More...
 
#define P_NEW_MAP   0x200
 Coordinates passed result in a new tiled map. More...
 
#define P_NO_CLERIC   0x20
 No clerical spells cast here. More...
 
#define P_NO_ERROR   0x80
 Purely temporary - if set, update_position does not complain if the flags are different. More...
 
#define P_NO_MAGIC   0x02
 Spells (some) can't pass this object. More...
 
#define P_OUT_OF_MAP   0x100
 This space is outside the map. More...
 
#define P_PLAYER   0x08
 There is a player on this space. More...
 
#define SAVE_ERROR_CLOSE   -6
 Close error for regular file. More...
 
#define SAVE_ERROR_NO_PATH   -4
 Map had no path set. More...
 
#define SAVE_ERROR_NOT_IN_MEMORY   -10
 Map to swap isn't in memory. More...
 
#define SAVE_ERROR_OK   0
 No error. More...
 
#define SAVE_ERROR_PLAYER   -11
 Player on map to save. More...
 
#define SAVE_ERROR_RCREATION   -1
 Couldn't create the regular save file. More...
 
#define SAVE_ERROR_RRENAME   -7
 Couldn't rename regular temporary file. More...
 
#define SAVE_ERROR_UCREATION   -2
 Couldn't create the file for unique objects. More...
 
#define SAVE_ERROR_URENAME   -5
 Couldn't rename unique temporary file. More...
 
#define SAVE_ERROR_WRITE   -3
 Write error. More...
 
#define SAVE_FLAG_NO_REMOVE   2
 If set, objects are not removed while saving. More...
 
#define SAVE_FLAG_SAVE_UNPAID   1
 If set, unpaid items will be saved. More...
 
#define SAVE_MODE_INPLACE   1
 Map is saved from where it was loaded. More...
 
#define SAVE_MODE_NORMAL   0
 No special handling. More...
 
#define SAVE_MODE_OVERLAY   2
 Map is persisted as an overlay. More...
 
#define SET_MAP_FACE_OBJ(M, X, Y, C, L)   ((M)->spaces[(X)+(M)->width*(Y)].faces_obj[L] = C)
 Sets the layer face of specified square. More...
 
#define SET_MAP_FLAGS(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].flags = C)
 Sets map flags. More...
 
#define SET_MAP_LIGHT(M, X, Y, L)   ((M)->spaces[(X)+(M)->width*(Y)].light = L)
 Sets map light. More...
 
#define SET_MAP_MOVE_BLOCK(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_block = C)
 Sets the blocking state of a square. More...
 
#define SET_MAP_MOVE_OFF(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_off = C)
 Sets the move_off state of a square. More...
 
#define SET_MAP_MOVE_ON(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_on = C)
 Sets the move_on state of a square. More...
 
#define SET_MAP_MOVE_SLOW(M, X, Y, C)   ((M)->spaces[(X)+(M)->width*(Y)].move_slow = C)
 Sets the slowing state of a square. More...
 
#define SET_MAP_OB(M, X, Y, tmp)   ((M)->spaces[(X)+(M)->width*(Y)].bottom = (tmp))
 Sets the bottom object on a map. More...
 
#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))
 Sets the top object on a map. More...
 

Typedefs

typedef struct MapSpace MapSpace
 This structure contains all information related to one map square. More...
 
typedef struct mapdef mapstruct
 This is a game-map. More...
 
typedef struct regiondef region
 This is a game region. More...
 
typedef struct rv_vector rv_vector
 This is used by get_rangevector to determine where the other creature is. More...
 
typedef struct shopitem shopitems
 Shop-related information for a map. More...
 

Functions

uint32_t map_size (mapstruct *m)
 Calculate map size without intermediate sign extension. More...
 

Variables

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

Detailed Description

This file contains basic map-related structures and macros.

Definition in file map.h.

Macro Definition Documentation

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

Gets the layer face of specified square.

Not multitile aware.

Definition at line 184 of file map.h.

Referenced by draw_client_map2(), magic_mapping_mark(), and magic_mapping_mark_recursive().

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

Referenced by update_position().

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

Gets map flags.

Not multitile aware.

Definition at line 161 of file map.h.

Referenced by find_closest_monster(), find_monster_in_room_recursive(), object_update(), and update_position().

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

Gets map light.

Not multitile aware.

Definition at line 165 of file map.h.

Referenced by expand_lighted_sight(), and monster_stand_in_light().

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

Gets the move_off state of a square.

Not multitile aware.

Definition at line 207 of file map.h.

Referenced by object_update().

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

Gets the move_on state of a square.

Not multitile aware.

Definition at line 202 of file map.h.

Referenced by object_check_move_on(), and object_update().

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

Gets the slowing state of a square.

Not multitile aware.

Definition at line 197 of file map.h.

Referenced by object_check_move_on(), and object_update().

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

Definition at line 168 of file map.h.

Referenced by object_update().

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

Gets the top object on a map.

Not multitile aware.

Definition at line 174 of file map.h.

Referenced by identify(), and object_insert_in_map().

#define MAGIC_MAP_HALF   MAGIC_MAP_SIZE/2

Definition at line 25 of file map.h.

Referenced by draw_magic_map(), magic_mapping_mark(), and magic_mapping_mark_recursive().

#define MAGIC_MAP_SIZE   50

Definition at line 24 of file map.h.

Referenced by draw_magic_map(), magic_mapping_mark(), and magic_mapping_mark_recursive().

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

Referenced by expand_lighted_sight(), expand_sight(), object_insert_in_map(), and object_insert_in_ob().

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

Definition at line 65 of file map.h.

Referenced by calculate_difficulty(), and mapfile_load().

#define MAP_ENTER_X (   m)    (m)->enter_x
#define MAP_ENTER_Y (   m)    (m)->enter_y
#define MAP_HEIGHT (   m)    (m)->height
#define MAP_LAYERS   10
#define MAP_NOSMOOTH (   m)    (m)->nosmooth

Definition at line 89 of file map.h.

Referenced by map2_add_ob().

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

Definition at line 68 of file map.h.

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

Definition at line 64 of file map.h.

Referenced by get_linked_map(), and set_map_reset_time().

#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_SWAP_TIME (   m)    ((m)->swap_time)

Definition at line 67 of file map.h.

Referenced by apply_savebed().

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

Choice of maps presented to player.

Definition at line 59 of file map.h.

Referenced by create_player_cmd(), and send_map_info().

#define MAP_TYPE_DEFAULT   2

If no map is specified, where character starts.

Definition at line 58 of file map.h.

Referenced by create_player_cmd().

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

Referenced by init_dynamic().

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

This is when the map will reset.

Definition at line 62 of file map.h.

Referenced by map_info(), and set_map_reset_time().

#define MAP_WIDTH (   m)    (m)->width
#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 217 of file map.h.

Referenced by apply_builder_floor(), apply_builder_wall(), blocked_link(), monster_compute_path(), move_player_attack(), object_insert_in_map(), reflwall(), teleport(), and wall_blocked().

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

Sets the layer face of specified square.

Not multitile aware.

Definition at line 182 of file map.h.

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

Sets map flags.

Not multitile aware.

Definition at line 163 of file map.h.

Referenced by cfapi_object_set_property(), do_turn(), object_insert_in_ob(), object_remove(), object_update(), and update_position().

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

Sets map light.

Not multitile aware.

Definition at line 167 of file map.h.

Referenced by update_position().

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

Sets the blocking state of a square.

Not multitile aware.

Definition at line 194 of file map.h.

Referenced by update_position().

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

Sets the move_off state of a square.

Not multitile aware.

Definition at line 209 of file map.h.

Referenced by update_position().

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

Sets the move_on state of a square.

Not multitile aware.

Definition at line 204 of file map.h.

Referenced by update_position().

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

Sets the slowing state of a square.

Not multitile aware.

Definition at line 199 of file map.h.

Referenced by update_position().

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

Sets the bottom object on a map.

Not multitile aware.

Definition at line 177 of file map.h.

Referenced by object_insert_in_map(), and object_remove().

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

Definition at line 169 of file map.h.

Referenced by update_position().

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

Sets the top object on a map.

Not multitile aware.

Definition at line 179 of file map.h.

Referenced by object_insert_in_map(), and object_remove().

Typedef Documentation

typedef struct MapSpace MapSpace

This structure contains all information related to one map square.

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.

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

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

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

uint32_t map_size ( mapstruct m)

Calculate map size without intermediate sign extension.

Definition at line 830 of file map.c.

References mapdef::height, and mapdef::width.

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

Here is the caller graph for this function:

Variable Documentation

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

Referenced by get_ob_diff().