summaryrefslogtreecommitdiff
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/shared
parenta0d1713808f0682180fa04492a8ccc14627c0748 (diff)
ID as strings.
Diffstat (limited to 'src/shared')
-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
3 files changed, 27 insertions, 33 deletions
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">>).