Crossfire Server, Branches 1.12  R18729
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
 

Macros

#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_HALF   MAGIC_MAP_SIZE/2
 
#define MAGIC_MAP_SIZE   50
 
#define MAP_BLOCK   0x4
 
#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_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)   ((m)->width*(m)->height)
 
#define MAP_STYLE   0x8
 
#define MAP_SWAP_TIME(m)   ((m)->swap_time)
 
#define MAP_SWAPPED   2
 
#define MAP_TIMEOUT(m)   ((m)->timeout)
 
#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_RRENAME   -7
 
#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)   ((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))
 

Typedefs

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

Variables

const char * 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 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 205 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 210 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 182 of file map.h.

Referenced by find_closest_monster(), find_monster_in_room_recursive(), move_to(), update_object(), 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 186 of file map.h.

Referenced by expand_lighted_sight(), and stand_in_light().

#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 228 of file map.h.

Referenced by update_object().

#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 223 of file map.h.

Referenced by check_move_on(), and update_object().

#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 218 of file map.h.

Referenced by check_move_on(), and update_object().

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

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

Definition at line 193 of file map.h.

Referenced by add_exits_to_map(), alchemy(), apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_map_builder(), attack_message(), attempt_jump(), blocked_link(), calculate_difficulty(), can_build_over(), cast_cause_disease(), cast_destruction(), cast_detection(), cast_earth_to_dust(), cast_identify(), cast_light(), cast_polymorph(), cast_raise_dead_spell(), cast_transfer(), cfapi_map_get_object_at(), check_bullet(), check_doors(), check_earthwalls(), check_hp(), check_infection(), check_move_on(), check_spell_knockback(), command_style_map_info(), common_process_projectile(), communicate(), coords_in_shop(), counterspell(), decay_objects(), decrease_ob_nr(), delete_unique_items(), dispel_rune(), do_auto_apply(), do_exit_map(), do_harvest(), do_mood_floor(), do_skill_detect_curse(), do_skill_detect_magic(), do_skill_ident(), door_in_square(), esrv_draw_look(), esrv_get_ob_from_count(), find_by_name(), find_closest_monster(), find_dir(), find_monster_in_room_recursive(), find_nearest_living_creature(), find_target_for_friendly_spell(), find_traps(), fix_auto_apply(), free_all_objects(), generate_monster(), get_connection_rune(), get_msg_book(), get_pet_enemy(), get_pointed_target(), get_wall(), hit_map(), include_map_in_map(), increase_ob_nr(), insert_ob_in_map(), is_legal_2ways_exit(), kill_player(), link_multipart_objects(), load_objects(), look_at(), make_map_floor(), merge_spell(), mood_change(), move_detector(), move_golem(), move_marker(), move_player_attack(), move_player_mover(), move_to(), npc_call_help(), nuke_map_region(), obj_count_in_map(), ok_to_put_more(), peacemaker_type_process(), pet_move(), pick_arrow_target(), pick_lock(), pick_random_object(), place_exits(), present(), present_arch(), probe(), process_map(), put_floor(), reflwall(), remove_adjacent_doors(), remove_marking_runes(), remove_monsters(), remove_ob(), remove_trap(), replace_insert_ob_in_map(), retrofit_joined_wall(), roll_ob(), save_objects(), shop_inventory_type_apply(), singing(), skill_attack(), spell_find_dir(), stand_near_hostile(), START_TEST(), steal(), teleport(), try_fit(), unblock_exits(), update_position(), use_alchemy(), use_oratory(), and write_rune().

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

Definition at line 189 of file map.h.

Referenced by update_object().

#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 195 of file map.h.

Referenced by insert_ob_in_map().

#define MAGIC_MAP_HALF   MAGIC_MAP_SIZE/2

Definition at line 53 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 52 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 94 of file map.h.

Referenced by expand_lighted_sight(), expand_sight(), insert_ob_in_map(), and insert_ob_in_ob().

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

Definition at line 84 of file map.h.

Referenced by calculate_difficulty(), and load_original_map().

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

Default X coordinate for map enter.

Definition at line 104 of file map.h.

Referenced by current_map_info(), dump_map(), enter_exit(), enter_map(), enter_random_map(), enter_random_template_map(), get_linked_map(), and place_exits().

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

Default Y coordinate for map enter.

Definition at line 106 of file map.h.

Referenced by current_map_info(), dump_map(), enter_exit(), enter_map(), enter_random_map(), enter_random_template_map(), get_linked_map(), and place_exits().

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

Definition at line 108 of file map.h.

Referenced by map2_add_ob().

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

Definition at line 87 of file map.h.

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

Definition at line 83 of file map.h.

Referenced by get_linked_map(), and set_map_reset_time().

#define MAP_SIZE (   m)    ((m)->width*(m)->height)

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

Definition at line 101 of file map.h.

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

Definition at line 86 of file map.h.

Referenced by apply_savebed().

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

This is when the map will reset

Definition at line 81 of file map.h.

Referenced by map_info(), and set_map_reset_time().

#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 238 of file map.h.

Referenced by apply_builder_floor(), apply_builder_wall(), blocked_link(), compute_path(), follow_owner(), insert_ob_in_map(), move_player_attack(), 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 203 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 184 of file map.h.

Referenced by cfapi_object_set_property(), do_turn(), insert_ob_in_ob(), remove_ob(), update_object(), and update_position().

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

Sets map lighe. Not multitile aware.

Definition at line 188 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 215 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 230 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 225 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 220 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 198 of file map.h.

Referenced by insert_ob_in_map(), and remove_ob().

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

Definition at line 190 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 200 of file map.h.

Referenced by insert_ob_in_map(), and remove_ob().

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

Variable Documentation

const char* 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 54 of file map.c.