|
Crossfire Server
1.75.0
|
This file contains basic map-related structures and macros. More...
Go to the source code of this file.
Data Structures | |
| struct | MapSpace |
| This structure contains all information related to one map square. More... | |
| struct | mapstruct |
| This is a game-map. More... | |
| struct | region |
| This is a game region. More... | |
| struct | rv_vector |
| This is used by get_rangevector to determine where the other creature is. More... | |
| struct | shopitems |
| Shop-related information for a map. More... | |
Macros | |
| #define | AB_NO_PASS 0x04 |
| #define | GET_MAP_FACE_OBJ(M, X, Y, L) (map_space(M, X, Y)->faces_obj[L]) |
| Gets the layer face of specified square. More... | |
| #define | GET_MAP_FACE_OBJS(M, X, Y) (map_space(M, X, 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) (map_space(M, X, Y)->flags) |
| Gets map flags. More... | |
| #define | GET_MAP_LIGHT(M, X, Y) (map_space(M, X, Y)->light) |
| Gets map light. More... | |
| #define | GET_MAP_MOVE_BLOCK(M, X, Y) (map_space(M, X, Y)->move_block) |
| Gets the blocking state of a square. More... | |
| #define | GET_MAP_MOVE_OFF(M, X, Y) (map_space(M, X, Y)->move_off) |
| Gets the move_off state of a square. More... | |
| #define | GET_MAP_MOVE_ON(M, X, Y) (map_space(M, X, Y)->move_on) |
| Gets the move_on state of a square. More... | |
| #define | GET_MAP_MOVE_SLOW(M, X, Y) (map_space(M, X, Y)->move_slow) |
| Gets the slowing state of a square. More... | |
| #define | GET_MAP_OB(M, X, Y) (map_space(M, X, Y)->bottom) |
| Gets the bottom object on a map. More... | |
| #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) |
| 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 level (0-MAX_DARKNESS) 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 |
| This correspondes to the map layers in the map2 protocol. More... | |
| #define | MAP_LOADING 3 |
| This map is being loaded. More... | |
| #define | MAP_NO_DIFFICULTY 0x4 |
| If set then don't compute a map difficulty if it is 0. 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_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 |
| For old character creation method. 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_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) (map_space(M, X, Y)->faces_obj[L] = C) |
| Sets the layer face of specified square. More... | |
| #define | SET_MAP_FLAGS(M, X, Y, C) (map_space(M, X, Y)->flags = C) |
| Sets map flags. More... | |
| #define | SET_MAP_LIGHT(M, X, Y, L) (map_space(M, X, Y)->light = L) |
| Sets map light. More... | |
| #define | SET_MAP_MOVE_BLOCK(M, X, Y, C) (map_space(M, X, Y)->move_block = C) |
| Sets the blocking state of a square. More... | |
| #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. More... | |
| #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. More... | |
| #define | SET_MAP_MOVE_SLOW(M, X, Y, C) (map_space(M, X, Y)->move_slow = C) |
| Sets the slowing state of a square. More... | |
| #define | SET_MAP_OB(M, X, Y, tmp) (map_space(M, X, Y)->bottom = (tmp)) |
| Sets the bottom object on a map. More... | |
| #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)) |
| Sets the top object on a map. More... | |
Functions | |
| bool | coords_in_shop (mapstruct *map, int x, int y) |
| Check if the given map coordinates are in a shop. More... | |
| int | map_light_on (mapstruct *m, int x, int y) |
| Return the light level at position (X, Y) on map M. More... | |
| bool | map_path_unique (const char *name) |
| Return true if the given map path leads to a unique map. More... | |
| void | map_reset_swap (mapstruct *m) |
| Call this when an in-memory map is used or referenced. More... | |
| uint32_t | map_size (mapstruct *m) |
| Calculate map size without intermediate sign extension. More... | |
| MapSpace * | map_space (const mapstruct *m, int x, int y) |
| bool | ob_move_block (object *ob1, object *ob2) |
| Basic macro to see if ob2 blocks ob1 from moving onto this space. More... | |
| bool | shop_contains (object *ob) |
| Check if an object is in a shop. 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... | |
This file contains basic map-related structures and macros.
Definition in file map.h.
| #define GET_MAP_FACE_OBJ | ( | M, | |
| X, | |||
| Y, | |||
| L | |||
| ) | (map_space(M, X, Y)->faces_obj[L]) |
Gets the layer face of specified square.
Not multitile aware.
Definition at line 185 of file map.h.
Referenced by draw_client_map2(), magic_mapping_mark(), and magic_mapping_mark_recursive().
| #define GET_MAP_FACE_OBJS | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, 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.
Referenced by update_position().
Gets map flags.
Not multitile aware.
Definition at line 160 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, | |||
| Y | |||
| ) | (map_space(M, X, Y)->light) |
Gets map light.
Not multitile aware.
Definition at line 165 of file map.h.
Referenced by expand_lighted_sight(), and map_light_on().
| #define GET_MAP_MOVE_BLOCK | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->move_block) |
Gets the blocking state of a square.
Not multitile aware.
Definition at line 195 of file map.h.
Referenced by alchemy(), animate_weapon(), attempt_jump(), blocked_link(), cast_cause_disease(), cast_cone(), cast_create_obj(), cast_earth_to_dust(), cast_light(), cast_polymorph(), check_bullet(), common_process_projectile(), create_bomb(), dimension_door(), do_throw(), fire_arch_from_position(), fire_bolt(), fire_bow(), forklightning(), get_pointed_target(), magic_wall(), monster_use_bow(), move_aura(), move_ball_spell(), move_bolt(), move_bullet(), ob_blocked(), object_check_move_on(), object_free(), object_update(), ok_to_put_more(), path_to_player(), pets_move(), pick_arrow_target(), roll_ob(), skill_attack(), stand_near_hostile(), steal(), surround_flag3(), teleport(), and wall_blocked().
| #define GET_MAP_MOVE_OFF | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->move_off) |
Gets the move_off state of a square.
Not multitile aware.
Definition at line 210 of file map.h.
Referenced by object_update().
| #define GET_MAP_MOVE_ON | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->move_on) |
Gets the move_on state of a square.
Not multitile aware.
Definition at line 205 of file map.h.
Referenced by object_check_move_on(), and object_update().
| #define GET_MAP_MOVE_SLOW | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->move_slow) |
Gets the slowing state of a square.
Not multitile aware.
Definition at line 200 of file map.h.
Referenced by object_check_move_on(), and object_update().
| #define GET_MAP_OB | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->bottom) |
Gets the bottom object on a map.
Not multitile aware.
Definition at line 173 of file map.h.
Referenced by apply_builder_floor(), apply_builder_item(), apply_builder_remove(), apply_map_builder(), cast_polymorph(), cfapi_map_get_object_at(), check_spell_knockback(), do_mood_floor(), esrv_draw_look(), eventListener(), find_target_for_friendly_spell(), free_all_objects(), is_legal_2ways_exit(), look_at(), make_map_floor(), map_find_by_flag(), monster_compute_path(), move_detector(), move_marker(), move_player_attack(), move_to(), object_check_move_on(), object_insert_in_map(), object_remove(), pick_lock(), pick_random_object(), put_floor(), remove_monsters(), shop_inventory_type_apply(), spell_find_dir(), and steal().
| #define GET_MAP_PLAYER | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->pl) |
Definition at line 169 of file map.h.
Referenced by object_update().
| #define GET_MAP_TOP | ( | M, | |
| X, | |||
| Y | |||
| ) | (map_space(M, X, Y)->top) |
Gets the top object on a map.
Not multitile aware.
Definition at line 175 of file map.h.
Referenced by cast_detection(), find_insert_pos(), and identify().
| #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().
Map darkness level (0-MAX_DARKNESS)
Definition at line 73 of file map.h.
Referenced by expand_lighted_sight(), expand_sight(), object_insert_in_map(), and object_insert_in_ob().
Definition at line 68 of file map.h.
Referenced by calculate_difficulty(), and mapfile_load().
Default X coordinate for map enter.
Definition at line 83 of file map.h.
Referenced by current_map_info(), dump_map(), enter_exit(), enter_map(), enter_player_maplevel(), enter_random_map(), enter_random_template_map(), get_linked_map(), and place_exits().
Default Y coordinate for map enter.
Definition at line 85 of file map.h.
Referenced by current_map_info(), dump_map(), enter_exit(), enter_map(), enter_player_maplevel(), enter_random_map(), enter_random_template_map(), get_linked_map(), and place_exits().
Map height.
Definition at line 78 of file map.h.
Referenced by add_exits_to_map(), adjacent_map(), apply_auto_fix(), apply_map_builder(), calculate_difficulty(), command_style_map_info(), current_map_info(), decay_objects(), delete_unique_items(), do_auto_apply(), do_exit_map(), dump_map(), enter_map(), find_spot_for_submap(), fix_walls(), free_all_objects(), generate_monster(), get_linked_map(), get_map_from_coord(), include_map_in_map(), link_multipart_objects(), load_objects(), object_find_multi_free_spot_around(), object_update(), pick_random_object(), place_fountain_with_specials(), place_monsters(), place_special_exit(), place_specials_in_map(), process_map(), ready_map_name(), save_objects(), shop_inventory_type_apply(), and update_all_los().
| #define MAP_LAYERS 10 |
This correspondes to the map layers in the map2 protocol.
The MAP_LAYER_... correspond to what goes on what layer - this removes the need for hardcoding, and also makes sure we don't overstep the number of layers.
Definition at line 32 of file map.h.
Referenced by check_space_for_heads(), draw_client_map2(), magic_mapping_mark(), magic_mapping_mark_recursive(), map2_add_ob(), and update_position().
Definition at line 87 of file map.h.
Referenced by map2_add_ob().
Definition at line 67 of file map.h.
Referenced by get_linked_map(), and set_map_reset_time().
Definition at line 69 of file map.h.
Referenced by current_map_info(), and leave().
This is when the map will reset.
Definition at line 65 of file map.h.
Referenced by map_info(), and set_map_reset_time().
Map width.
Definition at line 76 of file map.h.
Referenced by add_exits_to_map(), adjacent_map(), apply_auto_fix(), apply_map_builder(), calculate_difficulty(), command_style_map_info(), current_map_info(), decay_objects(), delete_unique_items(), do_auto_apply(), do_exit_map(), dump_map(), enter_map(), find_spot_for_submap(), fix_walls(), free_all_objects(), generate_monster(), get_linked_map(), get_map_from_coord(), include_map_in_map(), link_multipart_objects(), load_objects(), object_find_multi_free_spot_around(), object_update(), pick_random_object(), place_fountain_with_specials(), place_monsters(), place_special_exit(), place_specials_in_map(), process_map(), ready_map_name(), save_objects(), shop_inventory_type_apply(), and update_all_los().
| #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.
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 220 of file map.h.
Referenced by apply_builder_floor(), apply_builder_wall(), attack_message(), blocked_link(), get_map_from_coord(), load_objects(), map_find_by_archetype(), map_find_by_type(), map_space(), monster_compute_path(), move_player_attack(), object_insert_in_map(), pick_lock(), reflwall(), teleport(), and wall_blocked().
| #define SET_MAP_FACE_OBJ | ( | M, | |
| X, | |||
| Y, | |||
| C, | |||
| L | |||
| ) | (map_space(M, X, Y)->faces_obj[L] = C) |
Sets map flags.
Not multitile aware.
Definition at line 162 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, | |||
| L | |||
| ) | (map_space(M, X, 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, | |||
| C | |||
| ) | (map_space(M, X, Y)->move_block = C) |
Sets the blocking state of a square.
Not multitile aware.
Definition at line 197 of file map.h.
Referenced by update_position().
| #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 212 of file map.h.
Referenced by update_position().
| #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 207 of file map.h.
Referenced by update_position().
| #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 202 of file map.h.
Referenced by update_position().
| #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 178 of file map.h.
Referenced by object_insert_in_map(), and object_remove().
| #define SET_MAP_PLAYER | ( | M, | |
| X, | |||
| Y, | |||
| C | |||
| ) | (map_space(M, X, Y)->pl = C) |
Definition at line 170 of file map.h.
Referenced by update_position().
| #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 180 of file map.h.
Referenced by object_insert_in_map(), and object_remove().
| bool coords_in_shop | ( | mapstruct * | map, |
| int | x, | ||
| int | y | ||
| ) |
Check if the given map coordinates are in a shop.
Definition at line 2756 of file map.cpp.
References FOR_MAP_FINISH, FOR_MAP_PREPARE, and SHOP_FLOOR.
Referenced by shop_contains(), and shopkeeper_move().
| int map_light_on | ( | mapstruct * | m, |
| int | x, | ||
| int | y | ||
| ) |
Return the light level at position (X, Y) on map M.
Currently either 1 (lit) or 0 (unlit).
Definition at line 2729 of file map.cpp.
References get_map_from_coord(), GET_MAP_LIGHT, ihypot(), and MAX_LIGHT_RADII.
Referenced by monster_stand_in_light_internal().
| 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 2713 of file map.cpp.
Referenced by cast_create_town_portal(), enter_exit(), and town_portal_destroy_existing().
| 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 1759 of file map.cpp.
References MAP_MINTIMEOUT, and mapstruct::timeout.
Referenced by draw_client_map(), and ready_map_name().
| uint32_t map_size | ( | mapstruct * | m | ) |
Calculate map size without intermediate sign extension.
Definition at line 808 of file map.cpp.
References mapstruct::height, and mapstruct::width.
Referenced by allocate_map(), command_style_map_info(), and malloc_info().
Definition at line 2717 of file map.cpp.
References OUT_OF_REAL_MAP, mapstruct::spaces, and mapstruct::width.
Basic macro to see if ob2 blocks ob1 from moving onto this space.
Basically, ob2 has to block all of ob1 movement types.
Definition at line 327 of file map.cpp.
References object::move_block, object::move_type, and MOVE_WALK.
| bool shop_contains | ( | object * | ob | ) |
Check if an object is in a shop.
Definition at line 2763 of file map.cpp.
References coords_in_shop(), object::map, object::x, and object::y.
Referenced by do_item_conversion(), drop_object(), examine(), kill_player_not_permadeath(), shop_mat_type_move_on(), and transport_type_apply().
| 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().