summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-11-15 22:08:22 +0100
committerNathanael Sensfelder <SpamShield0@MultiAgentSystems.org>2018-11-15 22:08:22 +0100
commit9939f0f046198823857e316faaf08b267e7ec03d (patch)
tree2b59ee20c8bd363de9bb6cd3312affe636be92f9 /src
parenta0d1713808f0682180fa04492a8ccc14627c0748 (diff)
ID as strings.
Diffstat (limited to 'src')
-rw-r--r--src/battle/reply/btl_set_map.erl2
-rw-r--r--src/battle/struct/btl_map.erl4
-rw-r--r--src/map/map_shim.erl59
-rw-r--r--src/map/query/map_update.erl20
-rw-r--r--src/map/reply/map_set_map.erl2
-rw-r--r--src/map/struct/map_map.erl8
-rw-r--r--src/roster/struct/rst_roster.erl17
-rw-r--r--src/shared/struct/shr_armor.erl.m48
-rw-r--r--src/shared/struct/shr_tile.erl.m444
-rw-r--r--src/shared/struct/shr_weapon.erl.m48
10 files changed, 54 insertions, 118 deletions
diff --git a/src/battle/reply/btl_set_map.erl b/src/battle/reply/btl_set_map.erl
index 25e0541..e4a638e 100644
--- a/src/battle/reply/btl_set_map.erl
+++ b/src/battle/reply/btl_set_map.erl
@@ -27,7 +27,7 @@ generate (Map) ->
<<"t">>,
lists:map
(
- fun shr_tile:instance_to_int_list/1,
+ fun shr_tile:instance_to_binary_list/1,
array:sparse_to_list(btl_map:get_tile_instances(Map))
)
}
diff --git a/src/battle/struct/btl_map.erl b/src/battle/struct/btl_map.erl
index 157382d..e4aa88b 100644
--- a/src/battle/struct/btl_map.erl
+++ b/src/battle/struct/btl_map.erl
@@ -78,11 +78,11 @@ get_tile_instance (Location, Map) ->
(
non_neg_integer(),
non_neg_integer(),
- list(list(non_neg_integer()))
+ list(list(binary()))
)
-> type().
from_list (Width, Height, List) ->
- TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List),
+ TileInstances = lists:map(fun shr_tile:instance_from_binary_list/1, List),
#map
{
diff --git a/src/map/map_shim.erl b/src/map/map_shim.erl
deleted file mode 100644
index 600af60..0000000
--- a/src/map/map_shim.erl
+++ /dev/null
@@ -1,59 +0,0 @@
--module(map_shim).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--export([generate_random_map/1]).
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec demo_map () -> list(list(non_neg_integer())).
-demo_map () ->
- [
- [2, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [2, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0], [2, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [3, 0], [2, 0], [1, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0], [3, 0], [3, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [2, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [2, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [2, 0], [2, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [2, 0],
- [2, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [2, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [3, 0], [2, 0],
- [2, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [3, 0], [3, 0], [1, 0], [2, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [3, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [3, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [1, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [2, 0],
- [2, 0], [3, 0], [3, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [1, 0], [3, 0], [4, 0], [4, 0], [4, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [1, 0], [1, 0], [3, 0], [1, 0], [3, 0], [3, 0], [3, 0], [2, 0],
- [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0],
- [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0], [4, 0]
- ].
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec generate_random_map (binary()) -> map_map:type().
-generate_random_map (Owner) ->
- Map = map_map:from_list(Owner, 32, 32, demo_map()),
-
- Map.
diff --git a/src/map/query/map_update.erl b/src/map/query/map_update.erl
index a88992c..49ed1de 100644
--- a/src/map/query/map_update.erl
+++ b/src/map/query/map_update.erl
@@ -14,7 +14,7 @@
map_id :: binary(),
w :: non_neg_integer(),
h :: non_neg_integer(),
- t :: list(list(non_neg_integer()))
+ t :: list(list(binary()))
}
).
@@ -55,22 +55,8 @@ parse_input (Req) ->
lists:all
(
fun (T) ->
- [M|[V|B]] = T,
- (
- (M > 0)
- and (V >= 0)
- and ((length(B) rem 2) == 0)
- and
- lists:all
- (
- fun (Bo) ->
- %% FIXME [SECURITY][LOW]: this does not prevent "Error"
- %% tiles.
- (Bo >= 0)
- end,
- B
- )
- )
+ [_M|[_V|B]] = T,
+ ((length(B) rem 2) == 0)
end,
MapContent
),
diff --git a/src/map/reply/map_set_map.erl b/src/map/reply/map_set_map.erl
index be99103..3a3f36c 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 shr_tile:instance_to_int_list/1,
+ fun shr_tile:instance_to_binary_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 cc30645..4cce9cf 100644
--- a/src/map/struct/map_map.erl
+++ b/src/map/struct/map_map.erl
@@ -105,11 +105,11 @@ get_tile_instances_field () -> #map.tile_instances.
binary(),
non_neg_integer(),
non_neg_integer(),
- list(list(non_neg_integer()))
+ list(list(binary()))
)
-> type().
from_list (Owner, Width, Height, List) ->
- TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List),
+ TileInstances = lists:map(fun shr_tile:instance_from_binary_list/1, List),
#map
{
@@ -124,11 +124,11 @@ from_list (Owner, Width, Height, List) ->
type(),
non_neg_integer(),
non_neg_integer(),
- list(list(non_neg_integer()))
+ list(list(binary()))
)
-> type().
update_from_list (Map, Width, Height, List) ->
- TileInstances = lists:map(fun shr_tile:instance_from_ints/1, List),
+ TileInstances = lists:map(fun shr_tile:instance_from_binary_list/1, List),
Map#map
{
diff --git a/src/roster/struct/rst_roster.erl b/src/roster/struct/rst_roster.erl
index 2d1791b..6371878 100644
--- a/src/roster/struct/rst_roster.erl
+++ b/src/roster/struct/rst_roster.erl
@@ -114,8 +114,23 @@ get_characters_field () -> #roster.characters.
-spec new (binary()) -> type().
new (Owner) ->
+ NewChar = rst_character:new(),
#roster
{
owner = Owner,
- characters = array:from_list([rst_character:new(), rst_character:new()])
+ characters =
+ array:from_list
+ (
+ [
+ NewChar,
+ NewChar,
+ NewChar,
+ NewChar,
+
+ NewChar,
+ NewChar,
+ NewChar,
+ NewChar
+ ]
+ )
}.
diff --git a/src/shared/struct/shr_armor.erl.m4 b/src/shared/struct/shr_armor.erl.m4
index a72331a..18d203a 100644
--- a/src/shared/struct/shr_armor.erl.m4
+++ b/src/shared/struct/shr_armor.erl.m4
@@ -3,7 +3,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--type id() :: non_neg_integer().
+-type id() :: binary().
-record
(
@@ -35,7 +35,6 @@
-export
(
[
- random_id/0,
none/0,
from_id/1
]
@@ -66,7 +65,4 @@ from_id(_) ->
none().
-spec none () -> type().
-none () -> from_id(0).
-
--spec random_id () -> id().
-random_id () -> shr_roll:between(0, 4).
+none () -> from_id(<<"0">>).
diff --git a/src/shared/struct/shr_tile.erl.m4 b/src/shared/struct/shr_tile.erl.m4
index 906dc84..c963b0b 100644
--- a/src/shared/struct/shr_tile.erl.m4
+++ b/src/shared/struct/shr_tile.erl.m4
@@ -3,6 +3,9 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type class_id() :: binary().
+-type variant_id() :: binary().
+
-record
(
tile,
@@ -11,18 +14,17 @@
name :: binary(),
cost :: non_neg_integer(),
omnimods :: shr_omnimods:type(),
- family :: non_neg_integer(),
+ family :: variant_id(),
depth :: non_neg_integer()
}
).
--type class_id() :: non_neg_integer().
--opaque instance() :: list(non_neg_integer()).
--opaque border() :: list(non_neg_integer()).
+-opaque instance() :: list(binary()).
+-opaque border() :: list(binary()).
-opaque type() :: #tile{}.
--export_type([type/0, class_id/0, instance/0, border/0]).
+-export_type([type/0, class_id/0, variant_id/0, instance/0, border/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -41,8 +43,8 @@
-export
(
[
- instance_to_int_list/1,
- instance_from_ints/1,
+ instance_to_binary_list/1,
+ instance_from_binary_list/1,
default_tile_instance/0
]
).
@@ -51,7 +53,7 @@
(
[
extract_main_class_id/1,
- extract_variant_ix/1,
+ extract_variant_id/1,
extract_borders/1
]
).
@@ -60,7 +62,7 @@
(
[
extract_border_main_class_id/1,
- extract_border_variant_ix/1
+ extract_border_variant_id/1
]
).
@@ -80,14 +82,14 @@ extract_borders (I) ->
[_|[_|Result]] = I,
Result.
--spec extract_variant_ix (instance()) -> non_neg_integer().
-extract_variant_ix (I) -> lists:nth(2, I).
+-spec extract_variant_id (instance()) -> variant_id().
+extract_variant_id (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 extract_border_variant_id (border()) -> variant_id().
+extract_border_variant_id (B) -> lists:nth(2, B).
-spec from_class_id (class_id()) -> type().
m4_include(__MAKEFILE_DATA_DIR/tile/global.m4.conf)m4_dnl
@@ -96,12 +98,12 @@ 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).
+ 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().
+-spec get_class_id (type()) -> class_id().
get_class_id (Tile) -> Tile#tile.id.
-spec get_cost (type()) -> non_neg_integer().
@@ -113,17 +115,17 @@ get_name (Tile) -> Tile#tile.name.
-spec get_omnimods (type()) -> shr_omnimods:type().
get_omnimods (Tile) -> Tile#tile.omnimods.
--spec instance_from_ints (list(non_neg_integer())) -> instance().
-instance_from_ints (L) ->
+-spec instance_from_binary_list (list(binary())) -> instance().
+instance_from_binary_list (L) ->
LLength = length(L),
case (((LLength rem 2) == 0) and (LLength /= 0)) of
true -> L;
- _ -> [0, 0]
+ _ -> [<<"0">>, <<"0">>]
end.
--spec instance_to_int_list (instance()) -> list(non_neg_integer()).
-instance_to_int_list (I) -> I.
+-spec instance_to_binary_list (instance()) -> list(binary()).
+instance_to_binary_list (I) -> I.
-spec default_tile_instance () -> instance().
-default_tile_instance () -> [1, 0].
+default_tile_instance () -> [<<"1">>, <<"0">>].
diff --git a/src/shared/struct/shr_weapon.erl.m4 b/src/shared/struct/shr_weapon.erl.m4
index ccda881..f15922c 100644
--- a/src/shared/struct/shr_weapon.erl.m4
+++ b/src/shared/struct/shr_weapon.erl.m4
@@ -3,7 +3,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--type id() :: non_neg_integer().
+-type id() :: binary().
-record
(
@@ -39,7 +39,6 @@
-export
(
[
- random_id/0,
none/0,
from_id/1
]
@@ -75,7 +74,4 @@ from_id (_) ->
none().
-spec none () -> type().
-none () -> from_id(0).
-
--spec random_id () -> id().
-random_id () -> shr_roll:between(0, 24).
+none () -> from_id(<<"0">>).