From 6a82ead205f4463ee34cc4fcbc06f1b3e7b1dd1a Mon Sep 17 00:00:00 2001 From: nsensfel Date: Mon, 5 Mar 2018 13:51:14 +0100 Subject: Starting to work on the client diff messages. --- src/struct/location.erl | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'src/struct/location.erl') diff --git a/src/struct/location.erl b/src/struct/location.erl index 624fe56..462dc46 100644 --- a/src/struct/location.erl +++ b/src/struct/location.erl @@ -10,6 +10,14 @@ %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +-export +( + [ + decode/1, + encode/1 + ] +). + -export ( [ @@ -43,3 +51,9 @@ apply_direction (down, {X, Y}) -> -spec dist(type(), type()) -> non_neg_integer(). dist ({OX, OY}, {DX, DY}) -> (abs(DY - OY) + abs(DX - OX)). + +-spec encode (type()) -> list(non_neg_integer()). +encode ({X, Y}) -> [X, Y]. + +-spec decode (list(non_neg_integer)) -> type(). +decode ([X, Y]) when (is_integer(X) and is_integer(Y)) -> validate({X, Y}). -- cgit v1.2.3-70-g09d2