| summaryrefslogtreecommitdiff | 
diff options
| -rw-r--r-- | src/map/query/map_update.erl | 1 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_armor.erl.m4 (renamed from src/shared/struct/shr_armor.erl.m4) | 0 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_glyph.erl.m4 (renamed from src/shared/struct/shr_glyph.erl.m4) | 0 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_glyph_board.erl.m4 (renamed from src/shared/struct/shr_glyph_board.erl.m4) | 0 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_portrait.erl.m4 (renamed from src/shared/struct/shr_portrait.erl.m4) | 0 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_weapon.erl.m4 (renamed from src/shared/struct/shr_weapon.erl.m4) | 0 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_direction.erl (renamed from src/shared/struct/shr_direction.erl) | 0 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_inventory.erl (renamed from src/shared/struct/shr_inventory.erl) | 0 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_location.erl (renamed from src/shared/struct/shr_location.erl) | 0 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_map.erl (renamed from src/shared/struct/shr_map.erl) | 28 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_map_marker.erl | 52 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_tile.erl.m4 (renamed from src/shared/struct/shr_tile.erl.m4) | 0 | 
12 files changed, 78 insertions, 3 deletions
| diff --git a/src/map/query/map_update.erl b/src/map/query/map_update.erl index 5cb9e42..00f9a29 100644 --- a/src/map/query/map_update.erl +++ b/src/map/query/map_update.erl @@ -109,6 +109,7 @@ update_data (QueryState, Input) ->              QueryState#query_state.map,              Input#input.w,              Input#input.h, +            shr_map_marker:empty_collection(),              Input#input.t           )     }. diff --git a/src/shared/struct/shr_armor.erl.m4 b/src/shared/struct/inventory/shr_armor.erl.m4 index 18d203a..18d203a 100644 --- a/src/shared/struct/shr_armor.erl.m4 +++ b/src/shared/struct/inventory/shr_armor.erl.m4 diff --git a/src/shared/struct/shr_glyph.erl.m4 b/src/shared/struct/inventory/shr_glyph.erl.m4 index cd59a27..cd59a27 100644 --- a/src/shared/struct/shr_glyph.erl.m4 +++ b/src/shared/struct/inventory/shr_glyph.erl.m4 diff --git a/src/shared/struct/shr_glyph_board.erl.m4 b/src/shared/struct/inventory/shr_glyph_board.erl.m4 index 7fe77b1..7fe77b1 100644 --- a/src/shared/struct/shr_glyph_board.erl.m4 +++ b/src/shared/struct/inventory/shr_glyph_board.erl.m4 diff --git a/src/shared/struct/shr_portrait.erl.m4 b/src/shared/struct/inventory/shr_portrait.erl.m4 index fefc434..fefc434 100644 --- a/src/shared/struct/shr_portrait.erl.m4 +++ b/src/shared/struct/inventory/shr_portrait.erl.m4 diff --git a/src/shared/struct/shr_weapon.erl.m4 b/src/shared/struct/inventory/shr_weapon.erl.m4 index 1a2dcf5..1a2dcf5 100644 --- a/src/shared/struct/shr_weapon.erl.m4 +++ b/src/shared/struct/inventory/shr_weapon.erl.m4 diff --git a/src/shared/struct/shr_direction.erl b/src/shared/struct/map/shr_direction.erl index f0793b3..f0793b3 100644 --- a/src/shared/struct/shr_direction.erl +++ b/src/shared/struct/map/shr_direction.erl diff --git a/src/shared/struct/shr_inventory.erl b/src/shared/struct/map/shr_inventory.erl index 1f04533..1f04533 100644 --- a/src/shared/struct/shr_inventory.erl +++ b/src/shared/struct/map/shr_inventory.erl diff --git a/src/shared/struct/shr_location.erl b/src/shared/struct/map/shr_location.erl index ec62ff7..ec62ff7 100644 --- a/src/shared/struct/shr_location.erl +++ b/src/shared/struct/map/shr_location.erl diff --git a/src/shared/struct/shr_map.erl b/src/shared/struct/map/shr_map.erl index a57ed32..b72c566 100644 --- a/src/shared/struct/shr_map.erl +++ b/src/shared/struct/map/shr_map.erl @@ -12,7 +12,8 @@        owner :: shr_player:id(),        width :: non_neg_integer(),        height :: non_neg_integer(), -      tile_instances :: shr_tile:instances_tuple() +      tile_instances :: shr_tile:instances_tuple(), +      markers :: shr_map_marker:collection()     }  ). @@ -32,6 +33,8 @@        get_height/1,        get_tile_instances/1,        get_tile_instance/2, +      get_markers/1, +      get_marker/2,        get_used_tile_ids/1     ] @@ -43,6 +46,7 @@     [        get_width_field/0,        get_height_field/0, +      get_markers_field/0,        get_tile_instances_field/0     ]  ). @@ -51,7 +55,7 @@  -export  (     [ -      update_from_list/4, +      update_from_list/5,        default/1     ]  ). @@ -94,6 +98,18 @@ get_tile_instance (Location, Map) ->     TileIX = location_to_index(Map#map.width, Location),     element((TileIX + 1), Map#map.tile_instances). +-spec get_markers (type()) -> shr_map_marker:collection(). +get_markers (Map) -> Map#map.markers. + +-spec get_marker +   ( +      shr_map_marker:name(), +      type() +   ) +   -> ('not_found' | {'ok', shr_map_marker:type()}). +get_marker (Name, Map) -> +   shr_map_marker:get(Name, Map#map.markers). +  %%%% Fields  -spec get_width_field () -> non_neg_integer().  get_width_field () -> #map.width. @@ -101,6 +117,9 @@ get_width_field () -> #map.width.  -spec get_height_field () -> non_neg_integer().  get_height_field () -> #map.height. +-spec get_markers_field () -> non_neg_integer(). +get_markers_field () -> #map.markers. +  -spec get_tile_instances_field () -> non_neg_integer().  get_tile_instances_field () -> #map.tile_instances. @@ -128,16 +147,18 @@ get_used_tile_ids (Map) ->        type(),        non_neg_integer(),        non_neg_integer(), +      shr_map_marker:collection(),        list(list(binary()))     )     -> type(). -update_from_list (Map, Width, Height, List) -> +update_from_list (Map, Width, Height, Markers, List) ->     TileInstances = lists:map(fun shr_tile:instance_from_binary_list/1, List),     Map#map     {        width = Width,        height = Height, +      markers = Markers,        tile_instances = list_to_tuple(TileInstances)     }. @@ -150,5 +171,6 @@ default (Owner) ->        owner = Owner,        width = 32,        height = 32, +      markers = shr_map_marker:empty_collection(),        tile_instances = list_to_tuple(lists:duplicate(1024, DefaultTileInstance))     }. diff --git a/src/shared/struct/map/shr_map_marker.erl b/src/shared/struct/map/shr_map_marker.erl new file mode 100644 index 0000000..35ba195 --- /dev/null +++ b/src/shared/struct/map/shr_map_marker.erl @@ -0,0 +1,52 @@ +-module(shr_map_marker). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-type name() :: binary(). +-type type() :: 'none'. +-type collection() :: orddict:orddict(name(), type()). + +-export_type([name/0, type/0, collection/0]). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( +   [ +      get/2, +      empty_collection/0 +   ] +). + +-export +( +   [ +      decode_collection/1, +      encode_collection/1 +   ] +). + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-spec get (name(), collection()) -> ('not_found' | {'ok', type()}). +get (Name, Collection) -> +   case orddict:find(Name, Collection) of +      error -> not_found; +      Other -> Other +   end. + +-spec empty_collection () -> collection(). +empty_collection () -> orddict:new(). + +-spec encode_collection (collection()) -> list(any()). +encode_collection (_Collection) -> []. + +-spec decode_collection (map()) -> collection(). +decode_collection (_Map) -> orddict:new(). diff --git a/src/shared/struct/shr_tile.erl.m4 b/src/shared/struct/map/shr_tile.erl.m4 index 7876f8f..7876f8f 100644 --- a/src/shared/struct/shr_tile.erl.m4 +++ b/src/shared/struct/map/shr_tile.erl.m4 | 


