summaryrefslogtreecommitdiff |
diff options
author | nsensfel <SpamShield0@noot-noot.org> | 2018-08-28 18:30:19 +0200 |
---|---|---|
committer | nsensfel <SpamShield0@noot-noot.org> | 2018-08-28 18:30:19 +0200 |
commit | c41e76dc8fcbef9b64bee69e921304a2cad2fdd4 (patch) | |
tree | 0df6e3d4647ef7860d4fb4dc5f5a9004e0dd7455 /src/map | |
parent | ea42e4ea8667ddf8e9c30cbf234c109a139c25ff (diff) |
Adds the structure for omnimods, merges *_tile.erl
Diffstat (limited to 'src/map')
-rw-r--r-- | src/map/reply/map_add_tile.erl | 8 | ||||
-rw-r--r-- | src/map/reply/map_set_map.erl | 2 | ||||
-rw-r--r-- | src/map/struct/map_map.erl | 10 | ||||
-rw-r--r-- | src/map/struct/map_tile.erl.m4 | 120 |
4 files changed, 10 insertions, 130 deletions
diff --git a/src/map/reply/map_add_tile.erl b/src/map/reply/map_add_tile.erl index 1047231..d5f029a 100644 --- a/src/map/reply/map_add_tile.erl +++ b/src/map/reply/map_add_tile.erl @@ -16,13 +16,13 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec generate (map_tile:type()) -> {list(any())}. +-spec generate (shr_tile:type()) -> {list(any())}. generate (Tile) -> { [ {<<"msg">>, <<"add_tile">>}, - {<<"id">>, map_tile:get_class_id(Tile)}, - {<<"nam">>, map_tile:get_name(Tile)}, - {<<"ct">>, map_tile:get_cost(Tile)} + {<<"id">>, shr_tile:get_class_id(Tile)}, + {<<"nam">>, shr_tile:get_name(Tile)}, + {<<"ct">>, shr_tile:get_cost(Tile)} ] }. diff --git a/src/map/reply/map_set_map.erl b/src/map/reply/map_set_map.erl index a4fc01a..be99103 100644 --- a/src/map/reply/map_set_map.erl +++ b/src/map/reply/map_set_map.erl @@ -27,7 +27,7 @@ generate (Map) -> <<"t">>, lists:map ( - fun map_tile:instance_to_int_list/1, + fun shr_tile:instance_to_int_list/1, array:sparse_to_list(map_map:get_tile_instances(Map)) ) } diff --git a/src/map/struct/map_map.erl b/src/map/struct/map_map.erl index 46e501f..55c1a41 100644 --- a/src/map/struct/map_map.erl +++ b/src/map/struct/map_map.erl @@ -13,7 +13,7 @@ owner :: binary(), width :: integer(), height :: integer(), - tile_instances :: array:array(map_tile:instance()) + tile_instances :: array:array(shr_tile:instance()) } ). @@ -87,10 +87,10 @@ get_width (Map) -> Map#map.width. -spec get_height (type()) -> integer(). get_height (Map) -> Map#map.height. --spec get_tile_instances (type()) -> array:array(map_tile:instance()). +-spec get_tile_instances (type()) -> array:array(shr_tile:instance()). get_tile_instances (Map) -> Map#map.tile_instances. --spec get_tile_instance (map_location:type(), type()) -> map_tile:instance(). +-spec get_tile_instance (map_location:type(), type()) -> shr_tile:instance(). get_tile_instance (Location, Map) -> TileIX = location_to_array_index(Map#map.width, Location), array:get(TileIX, Map#map.tile_instances). @@ -114,7 +114,7 @@ get_tile_instances_field () -> #map.tile_instances. ) -> type(). from_list (ID, Owner, Width, Height, List) -> - TileInstances = lists:map(fun map_tile:instance_from_ints/1, List), + TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List), #map { @@ -134,7 +134,7 @@ from_list (ID, Owner, Width, Height, List) -> ) -> type(). update_from_list (Map, Width, Height, List) -> - TileInstances = lists:map(fun map_tile:instance_from_ints/1, List), + TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List), Map#map { diff --git a/src/map/struct/map_tile.erl.m4 b/src/map/struct/map_tile.erl.m4 deleted file mode 100644 index 278e556..0000000 --- a/src/map/struct/map_tile.erl.m4 +++ /dev/null @@ -1,120 +0,0 @@ --module(map_tile). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --record -( - tile, - { - id :: class_id(), - name :: binary(), - cost :: non_neg_integer(), - family :: non_neg_integer(), - depth :: non_neg_integer() - } -). - --opaque class_id() :: non_neg_integer(). --opaque instance() :: list(non_neg_integer()). --opaque border() :: list(non_neg_integer()). - --opaque type() :: #tile{}. - --export_type([type/0, class_id/0, instance/0, border/0]). -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( - [ - get_class_id/1, - get_name/1, - get_cost/1, - from_class_id/1, - cost_when_oob/0 - ] -). - --export -( - [ - instance_to_int_list/1, - instance_from_ints/1 - ] -). - --export -( - [ - extract_main_class_id/1, - extract_variant_ix/1, - extract_borders/1 - ] -). - --export -( - [ - extract_border_main_class_id/1, - extract_border_variant_ix/1 - ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - --spec extract_main_class_id (instance()) -> class_id(). -extract_main_class_id (I) -> lists:nth(1, I). - --spec extract_borders (instance()) -> list(border()). -extract_borders (I) -> - [_|[_|Result]] = I, - Result. - --spec extract_variant_ix (instance()) -> non_neg_integer(). -extract_variant_ix (I) -> lists:nth(2, I). - --spec extract_border_main_class_id (border()) -> class_id(). -extract_border_main_class_id (B) -> lists:nth(1, B). - --spec extract_border_variant_ix (border()) -> non_neg_integer(). -extract_border_variant_ix (B) -> lists:nth(2, B). - --spec from_class_id (class_id()) -> type(). -m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/error.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/grassland.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/mud.m4d)m4_dnl -m4_include(__MAKEFILE_DATA_DIR/tile/water.m4d)m4_dnl -from_class_id(_) -> - from_class_id(0). - --spec cost_when_oob () -> non_neg_integer(). -cost_when_oob () -> __TILE_COST_WHEN_OOB. - --spec get_class_id (type()) -> non_neg_integer(). -get_class_id (Tile) -> Tile#tile.id. - --spec get_cost (type()) -> non_neg_integer(). -get_cost (Tile) -> Tile#tile.cost. - --spec get_name (type()) -> binary(). -get_name (Tile) -> Tile#tile.name. - --spec instance_from_ints (list(non_neg_integer())) -> instance(). -instance_from_ints (L) -> - LLength = length(L), - - case (((LLength rem 2) == 0) and (LLength /= 0)) of - true -> L; - _ -> [0, 0] - end. - --spec instance_to_int_list (instance()) -> list(non_neg_integer()). -instance_to_int_list (I) -> I. |