summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authornsensfel <SpamShield0@noot-noot.org>2019-01-04 17:25:39 +0100
committernsensfel <SpamShield0@noot-noot.org>2019-01-04 17:25:39 +0100
commit83cd7ce064b8a46a106dc855d748b1bd7e45af01 (patch)
treecee5d4e3d21936925f8108940c35533f9f6484f5 /src/shared/struct
parent895a5348f521b16b3a6e32d921f7f23ec8f3036e (diff)
Removes 'id' field from ataxia entry values.
While sometimes usefull as a way to retrieve the object's ID, they were both redundant (you can't get the object without its ID anyway) and bothersome to maintain (insert + update, which would have required setting up a bounty for any insert).
Diffstat (limited to 'src/shared/struct')
-rw-r--r--src/shared/struct/shr_inventory.erl3
-rw-r--r--src/shared/struct/shr_player.erl26
2 files changed, 8 insertions, 21 deletions
diff --git a/src/shared/struct/shr_inventory.erl b/src/shared/struct/shr_inventory.erl
index 0225fcb..1f04533 100644
--- a/src/shared/struct/shr_inventory.erl
+++ b/src/shared/struct/shr_inventory.erl
@@ -3,6 +3,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
+-type id() :: ataxia_id:type().
-record
(
inventory,
@@ -18,7 +19,7 @@
-opaque type() :: #inventory{}.
--export_type([type/0]).
+-export_type([type/0, id/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
diff --git a/src/shared/struct/shr_player.erl b/src/shared/struct/shr_player.erl
index eabca96..076c685 100644
--- a/src/shared/struct/shr_player.erl
+++ b/src/shared/struct/shr_player.erl
@@ -3,13 +3,12 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--type id() :: binary().
+-type id() :: ataxia_id:type().
-record
(
player,
{
- id :: id(),
username :: binary(),
% {salt(crypto:strong_rand_bytes(128)), hash(sha384)}
password :: {binary(), binary()},
@@ -35,7 +34,7 @@
-export
(
[
- new/4
+ new/3
]
).
@@ -43,7 +42,6 @@
-export
(
[
- get_id/1,
get_username/1,
get_password/1,
get_token/1,
@@ -56,7 +54,6 @@
get_inventory_id/1,
get_roster_id/1,
- set_id/2,
set_username/2,
set_password/2,
new_token/1,
@@ -74,7 +71,6 @@
-export
(
[
- get_id_field/0,
get_username_field/0,
get_password_field/0,
get_token_field/0,
@@ -113,13 +109,12 @@ secure_value (Salt, Val) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
--spec new (binary(), binary(), binary(), binary()) -> type().
-new (ID, Username, Password, Email) ->
+-spec new (binary(), binary(), binary()) -> type().
+new (Username, Password, Email) ->
EmptyBattleSlot = shr_battle_summary:none(),
Result =
#player
{
- id = ID,
username = Username,
password = {<<"">>, <<"">>},
token = <<"">>,
@@ -160,8 +155,8 @@ new (ID, Username, Password, Email) ->
EmptyBattleSlot,
EmptyBattleSlot
],
- inventory_id = <<"0">>,
- roster_id = <<"0">>
+ inventory_id = ataxia_id:null(),
+ roster_id = ataxia_id:null()
},
S0Result = set_password(Password, Result),
@@ -171,9 +166,6 @@ new (ID, Username, Password, Email) ->
S2Result.
%%%% Accessors
--spec get_id (type()) -> id().
-get_id (Player) -> Player#player.id.
-
-spec get_username (type()) -> binary().
get_username (Player) -> Player#player.username.
@@ -207,9 +199,6 @@ get_roster_id (Player) -> Player#player.roster_id.
-spec get_inventory_id (type()) -> binary().
get_inventory_id (Player) -> Player#player.inventory_id.
--spec set_id (binary(), type()) -> type().
-set_id (Val, Player) -> Player#player{ id = Val }.
-
-spec set_username (binary(), type()) -> type().
set_username (Val, Player) -> Player#player{ username = Val }.
@@ -280,9 +269,6 @@ set_roster_id (RosterID, Player) -> Player#player{ roster_id = RosterID }.
-spec set_inventory_id (binary(), type()) -> type().
set_inventory_id (InvID, Player) -> Player#player{ inventory_id = InvID }.
--spec get_id_field () -> non_neg_integer().
-get_id_field () -> #player.id.
-
-spec get_username_field () -> non_neg_integer().
get_username_field () -> #player.username.