| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2018-07-12 17:10:30 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2018-07-12 17:10:30 +0200 | 
| commit | 0b2562792eb35c35b573fd9a79d1c73576e0d536 (patch) | |
| tree | 0a42b767f19e6c1ea76fd9520c886a6716b26966 /src/map | |
| parent | 73bea4600f5bb3ad748d9bfa65ef6cd14e6bbd55 (diff) | |
Shared sec. module, some renammings.
Diffstat (limited to 'src/map')
| -rw-r--r-- | src/map/io/map_security.erl | 33 | ||||
| -rw-r--r-- | src/map/query/map_load_state.erl | 159 | 
2 files changed, 0 insertions, 192 deletions
| diff --git a/src/map/io/map_security.erl b/src/map/io/map_security.erl deleted file mode 100644 index cf6bb9b..0000000 --- a/src/map/io/map_security.erl +++ /dev/null @@ -1,33 +0,0 @@ --module(btl_security). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export -( -   [ -      assert_identity/2, -      lock_queries/1, -      unlock_queries/1 -   ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec assert_identity (any(), any()) -> 'unimplemented'. -assert_identity (_PlayerID, _SessionToken) -> unimplemented. - --spec lock_queries (any()) -> 'unimplemented'. -lock_queries (_PlayerID) -> unimplemented. - --spec unlock_queries (any()) -> 'unimplemented'. -unlock_queries (_PlayerID) -> unimplemented. diff --git a/src/map/query/map_load_state.erl b/src/map/query/map_load_state.erl deleted file mode 100644 index 2026222..0000000 --- a/src/map/query/map_load_state.erl +++ /dev/null @@ -1,159 +0,0 @@ --module(btl_load_state). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --include("../../../include/yaws_api.hrl"). - --record -( -   input, -   { -      player_id :: btl_player:id(), -      session_token :: binary(), -      battle_id :: binary() -   } -). - --record -( -   query_state, -   { -      battle :: btl_battle:type() -   } -). - --type input() :: #input{}. --type query_state() :: #query_state{}. - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --export([out/1]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --spec parse_input (binary()) -> input(). -parse_input (Req) -> -   JSONReqMap = jiffy:decode(Req, [return_maps]), -   PlayerID = maps:get(<<"pid">>, JSONReqMap), -   SessionToken =  maps:get(<<"stk">>, JSONReqMap), -   BattleID = maps:get(<<"bid">>, JSONReqMap), - -   #input -   { -      player_id = PlayerID, -      session_token = SessionToken, -      battle_id = BattleID -   }. - --spec fetch_data (input()) -> query_state(). -fetch_data (Input) -> -   PlayerID = Input#input.player_id, -   BattleID = Input#input.battle_id, - -   Battle = shr_timed_cache:fetch(battle_db, PlayerID, BattleID), - -   #query_state -   { -      battle = Battle -   }. - --spec generate_reply(query_state(), input()) -> binary(). -generate_reply (QueryState, Input) -> -   PlayerID = Input#input.player_id, -   Battle = QueryState#query_state.battle, -   Players = btl_battle:get_players(Battle), - -   PlayerIX = -      shr_array_util:first -      ( -         fun (Player) -> -            (btl_player:get_id(Player) == PlayerID) -         end, -         Players -      ), - -   true = (PlayerIX >= 0), - -   SetTimeline = -      btl_set_timeline:generate -      ( -         btl_battle:get_encoded_last_turns_effects(Battle) -      ), - -   SetMap = btl_set_map:generate(btl_battle:get_battlemap(Battle)), - -   AddCharList = -      array:sparse_to_list -      ( -         array:map -         ( -            fun (IX, Character) -> -               btl_add_char:generate(IX, Character, PlayerIX) -            end, -            btl_battle:get_characters(Battle) -         ) -      ), - -   AddWeaponList = -      lists:map -      ( -         fun (WeaponID) -> -            btl_add_weapon:generate(shr_weapon:from_id(WeaponID)) -         end, -         btl_battle:get_used_weapon_ids(Battle) -      ), - -   AddArmorList = -      lists:map -      ( -         fun (ArmorID) -> -            btl_add_armor:generate(shr_armor:from_id(ArmorID)) -         end, -         btl_battle:get_used_armor_ids(Battle) -      ), - -   AddTileList = -      lists:map -      ( -         fun (TileID) -> -            btl_add_tile:generate(btl_tile:from_id(TileID)) -         end, -         btl_battle:get_used_tile_ids(Battle) -      ), - -   OutputList = -      ( -         AddTileList -         ++ [SetTimeline, SetMap | AddWeaponList] -         ++ AddArmorList -         ++ AddCharList -      ), -   Output = jiffy:encode(OutputList), - -   Output. - --spec handle (binary()) -> binary(). -handle (Req) -> -   Input = parse_input(Req), -   btl_security:assert_identity -   ( -      Input#input.player_id, -      Input#input.session_token -   ), -   btl_security:lock_queries(Input#input.player_id), -   QueryState = fetch_data(Input), -   btl_security:unlock_queries(Input#input.player_id), -   generate_reply(QueryState, Input). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -out(A) -> -   { -      content, -      "application/json; charset=UTF-8", -      handle(A#arg.clidata) -   }. | 


