| summaryrefslogtreecommitdiff | 
diff options
| author | nsensfel <SpamShield0@noot-noot.org> | 2019-04-26 15:05:44 +0200 | 
|---|---|---|
| committer | nsensfel <SpamShield0@noot-noot.org> | 2019-04-26 15:05:44 +0200 | 
| commit | ec6eec260d6383ae948505c3d42b3055ae3dd94c (patch) | |
| tree | 1d9ab2b09ab0a534fc6c09b62b940d9f1c7e139f /src/shared/struct | |
| parent | 7d428bac2f9d62c5a0e704eb32be869c10fec72e (diff) | |
Makes Dialyzer validate shared & battle.
Diffstat (limited to 'src/shared/struct')
| -rw-r--r-- | src/shared/struct/inventory/shr_equipment.erl | 26 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_glyph.erl.m4 | 2 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_glyph_board.erl.m4 | 9 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_inventory.erl | 48 | ||||
| -rw-r--r-- | src/shared/struct/inventory/shr_weapon.erl.m4 | 2 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_inventory.erl | 153 | ||||
| -rw-r--r-- | src/shared/struct/map/shr_map.erl | 6 | ||||
| -rw-r--r-- | src/shared/struct/shr_character.erl | 24 | ||||
| -rw-r--r-- | src/shared/struct/shr_omnimods.erl | 4 | 
9 files changed, 63 insertions, 211 deletions
| diff --git a/src/shared/struct/inventory/shr_equipment.erl b/src/shared/struct/inventory/shr_equipment.erl index cbd4381..a931444 100644 --- a/src/shared/struct/inventory/shr_equipment.erl +++ b/src/shared/struct/inventory/shr_equipment.erl @@ -40,7 +40,7 @@  -opaque unresolved() :: #shr_eq_ref{}.  -type either() :: (type() | unresolved()). --export_type([type/0, unresolved/0]). +-export_type([type/0, unresolved/0, either/0]).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -84,7 +84,6 @@        set_portrait_id/2,        set_glyph_board_id/2,        set_glyph_ids/2, -      set_glyph_ids/2,        ataxia_set_primary_weapon_id/2,        ataxia_set_secondary_weapon_id/2, @@ -299,14 +298,12 @@ set_glyphs (V, Eq) when is_record(Eq, shr_eq_ref) ->     (list(shr_glyph:type()), type()) -> {type(), ataxic:basic()};     (list(shr_glyph:type()), unresolved()) -> {unresolved(), ataxic:basic()}.  ataxia_set_glyphs (V, Eq) -> -   { -      set_glyphs(V, Eq), -      ataxic:update_field -      ( -         get_glyphs_field(), -         ataxic:constant(shr_glyph:get_id(V)) -      ) -   }. +   ataxia_set_glyphs +   ( +      V, +      ataxic:constant(lists:map(fun shr_glyph:get_id/1, V)), +      Eq +   ).  -spec ataxia_set_glyphs     ( @@ -448,14 +445,7 @@ set_glyph_ids (V, Eq) when is_record(Eq, shr_eq) ->     (list(shr_glyph:id()), type()) -> {type(), ataxic:basic()};     (list(shr_glyph:id()), unresolved()) -> {unresolved(), ataxic:basic()}.  ataxia_set_glyph_ids (V, Eq) -> -   { -      set_glyph_ids(V, Eq), -      ataxic:update_field -      ( -         get_glyphs_field(), -         ataxic:constant(V) -      ) -   }. +   ataxia_set_glyph_ids(V, ataxic:constant(V), Eq).  -spec ataxia_set_glyph_ids     ( diff --git a/src/shared/struct/inventory/shr_glyph.erl.m4 b/src/shared/struct/inventory/shr_glyph.erl.m4 index 0ce4c47..a451cc0 100644 --- a/src/shared/struct/inventory/shr_glyph.erl.m4 +++ b/src/shared/struct/inventory/shr_glyph.erl.m4 @@ -35,7 +35,7 @@     [        get_id/1,        get_name/1, -      get_omnimods/1, +      get_omnimods/1     ]  ). diff --git a/src/shared/struct/inventory/shr_glyph_board.erl.m4 b/src/shared/struct/inventory/shr_glyph_board.erl.m4 index c2128a9..3324997 100644 --- a/src/shared/struct/inventory/shr_glyph_board.erl.m4 +++ b/src/shared/struct/inventory/shr_glyph_board.erl.m4 @@ -58,7 +58,7 @@        list(shr_glyph:type()),        list(integer())     ) -   -> ({'ok', shr_omnimods:type()} | 'error'). +   -> ('error' | {'ok', shr_omnimods:type()}).  get_omnimods_with_glyphs_internals (Omnimods, [], []) ->     {ok, Omnimods};  get_omnimods_with_glyphs_internals (_Omnimods, [], _) -> @@ -102,12 +102,15 @@ default () -> from_id(<<"0">>).        list(shr_glyph:type()),        type()     ) -   -> ({'ok', shr_omnimods:type()} | 'error'). +   -> shr_omnimods:type().  get_omnimods_with_glyphs (Glyphs, GlyphBoard) ->     BoardOmnimods = GlyphBoard#glyph_board.omnimods,     BoardSlots = GlyphBoard#glyph_board.slots, -   get_omnimods_with_glyphs_internals(BoardOmnimods, Glyphs, BoardSlots). +   {ok, Omnimods} = +      get_omnimods_with_glyphs_internals(BoardOmnimods, Glyphs, BoardSlots), + +   Omnimods.  -spec default_id () -> id().  default_id () -> <<"0">>. diff --git a/src/shared/struct/inventory/shr_inventory.erl b/src/shared/struct/inventory/shr_inventory.erl index 4ea3e7b..884c213 100644 --- a/src/shared/struct/inventory/shr_inventory.erl +++ b/src/shared/struct/inventory/shr_inventory.erl @@ -22,8 +22,9 @@  ).  -opaque type() :: #inventory{}. +-type id() :: ataxia_id:type(). --export_type([type/0]). +-export_type([type/0, id/0]).  %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%  %% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% @@ -95,19 +96,27 @@ get_glyphs (Inv) -> Inv#inventory.glyphs.  -spec add_weapon (shr_weapon:id(), type()) -> type(). -add_weapon (V, Inv) -> Inv#inventory{ weapons = V }. +add_weapon (V, Inv) -> +   Inv#inventory{ weapons = ordsets:add_element(V, Inv#inventory.weapons) }.  -spec add_armor (shr_armor:id(), type()) -> type(). -add_armor (V, Inv) -> Inv#inventory{ armors = V }. +add_armor (V, Inv) -> +   Inv#inventory{ armors = ordsets:add_element(V, Inv#inventory.armors) }.  -spec add_portrait (shr_portrait:id(), type()) -> type(). -add_portrait (V, Inv) -> Inv#inventory{ portraits = V }. +add_portrait (V, Inv) -> +   Inv#inventory{ portraits = ordsets:add_element(V, Inv#inventory.portraits) }.  -spec add_glyph_board (shr_glyph_board:id(), type()) -> type(). -add_glyph_board (V, Inv) -> Inv#inventory{ glyph_boards = V }. +add_glyph_board (V, Inv) -> +   Inv#inventory +   { +      glyph_boards = ordsets:add_element(V, Inv#inventory.glyph_boards) +   }.  -spec add_glyph (shr_glyph:id(), type()) -> type(). -add_glyph (V, Inv) -> Inv#inventory{ glyphs = V }. +add_glyph (V, Inv) -> +   Inv#inventory{ glyphs = ordsets:add_element(V, Inv#inventory.glyphs) }.  -spec ataxia_add_weapon @@ -115,12 +124,12 @@ add_glyph (V, Inv) -> Inv#inventory{ glyphs = V }.        shr_weapon:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_weapon (V, Inv) ->     CurrentWeapons = Inv#inventory.weapons,     case ordsets:is_element(V, CurrentWeapons) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory{ weapons = ordsets:add_element(V, CurrentWeapons) }, @@ -142,12 +151,12 @@ ataxia_add_weapon (V, Inv) ->        shr_armor:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_armor (V, Inv) ->     CurrentArmors = Inv#inventory.armors,     case ordsets:is_element(V, CurrentArmors) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory{ armors = ordsets:add_element(V, CurrentArmors) }, @@ -169,12 +178,12 @@ ataxia_add_armor (V, Inv) ->        shr_portrait:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_portrait (V, Inv) ->     CurrentPortraits = Inv#inventory.portraits,     case ordsets:is_element(V, CurrentPortraits) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory @@ -199,12 +208,12 @@ ataxia_add_portrait (V, Inv) ->        shr_glyph_board:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_glyph_board (V, Inv) ->     CurrentGlyphBoards = Inv#inventory.glyph_boards,     case ordsets:is_element(V, CurrentGlyphBoards) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory @@ -229,12 +238,12 @@ ataxia_add_glyph_board (V, Inv) ->        shr_glyph:id(),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_glyph (V, Inv) ->     CurrentGlyphs = Inv#inventory.glyphs,     case ordsets:is_element(V, CurrentGlyphs) of -      true -> Inv; +      true -> {Inv, ataxic:current_value()};        false ->           {              Inv#inventory{ glyphs = ordsets:add_element(V, CurrentGlyphs) }, @@ -354,7 +363,7 @@ add_equipment (Eq, Inv) ->        (shr_equipment:type()|shr_equipment:unresolved()),        type()     ) -   -> {type(), list(ataxic:basic())}. +   -> {type(), ataxic:basic()}.  ataxia_add_equipment (Eq, Inv) ->     {S0Inv, Ataxic0} =        ataxia_add_weapon(shr_equipment:get_primary_weapon_id(Eq), Inv), @@ -380,10 +389,9 @@ ataxia_add_equipment (Eq, Inv) ->     {        S4Inv, -      lists:flatten +      ataxic:optimize        ( -         [Ataxic0, Ataxic1, Ataxic2, Ataxic3], -         lists:flatten(Ataxic4s) +         ataxic:sequence([Ataxic0, Ataxic1, Ataxic2, Ataxic3|Ataxic4s])        )     }. diff --git a/src/shared/struct/inventory/shr_weapon.erl.m4 b/src/shared/struct/inventory/shr_weapon.erl.m4 index 189afa7..a18c48e 100644 --- a/src/shared/struct/inventory/shr_weapon.erl.m4 +++ b/src/shared/struct/inventory/shr_weapon.erl.m4 @@ -41,7 +41,7 @@  (     [        default/0, -      default/0, +      default_id/0,        from_id/1     ]  ). diff --git a/src/shared/struct/map/shr_inventory.erl b/src/shared/struct/map/shr_inventory.erl deleted file mode 100644 index 1f04533..0000000 --- a/src/shared/struct/map/shr_inventory.erl +++ /dev/null @@ -1,153 +0,0 @@ --module(shr_inventory). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% TYPES %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% --type id() :: ataxia_id:type(). --record -( -   inventory, -   { -      owner_id :: shr_player:id(), -      portrait_ids :: ordsets:ordset(binary()), -      glyph_ids :: ordsets:ordset(binary()), -      glyph_board_ids :: ordsets:ordset(binary()), -      weapon_ids :: ordsets:ordset(binary()), -      armor_ids :: ordsets:ordset(binary()) -   } -). - --opaque type() :: #inventory{}. - --export_type([type/0, id/0]). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --export -( -   [ -      get_owner_id/1, - -      get_portrait_ids/1, -      get_glyph_ids/1, -      get_glyph_board_ids/1, -      get_weapon_ids/1, -      get_armor_ids/1, - -      set_portrait_ids/2, -      set_glyph_ids/2, -      set_glyph_board_ids/2, -      set_weapon_ids/2, -      set_armor_ids/2 -   ] -). - --export -( -   [ -      get_portrait_ids_field/0, -      get_glyph_ids_field/0, -      get_glyph_board_ids_field/0, -      get_weapon_ids_field/0, -      get_armor_ids_field/0 -   ] -). - --export -( -   [ -      new/1 -   ] -). - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% LOCAL FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% - -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%% EXPORTED FUNCTIONS %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -%%%% Accessors --spec get_owner_id (type()) -> shr_player:id(). -get_owner_id (Inv) -> Inv#inventory.owner_id. - --spec get_portrait_ids (type()) -> ordsets:ordset(binary()). -get_portrait_ids (Inv) -> Inv#inventory.portrait_ids. - --spec get_glyph_ids (type()) -> ordsets:ordset(binary()). -get_glyph_ids (Inv) -> Inv#inventory.glyph_ids. - --spec get_glyph_board_ids (type()) -> ordsets:ordset(binary()). -get_glyph_board_ids (Inv) -> Inv#inventory.glyph_board_ids. - --spec get_weapon_ids (type()) -> ordsets:ordset(binary()). -get_weapon_ids (Inv) -> Inv#inventory.weapon_ids. - --spec get_armor_ids (type()) -> ordsets:ordset(binary()). -get_armor_ids (Inv) -> Inv#inventory.armor_ids. - --spec set_portrait_ids (ordsets:ordset(binary()), type()) -> type(). -set_portrait_ids (Value, Inv) -> -   Inv#inventory -   { -      portrait_ids = Value -   }. - --spec set_glyph_ids (ordsets:ordset(binary()), type()) -> type(). -set_glyph_ids (Value, Inv) -> -   Inv#inventory -   { -      glyph_ids = Value -   }. - --spec set_glyph_board_ids (ordsets:ordset(binary()), type()) -> type(). -set_glyph_board_ids (Value, Inv) -> -   Inv#inventory -   { -      glyph_board_ids = Value -   }. - --spec set_weapon_ids (ordsets:ordset(binary()), type()) -> type(). -set_weapon_ids (Value, Inv) -> -   Inv#inventory -   { -      weapon_ids = Value -   }. - --spec set_armor_ids (ordsets:ordset(binary()), type()) -> type(). -set_armor_ids (Value, Inv) -> -   Inv#inventory -   { -      armor_ids = Value -   }. - --spec get_portrait_ids_field () -> non_neg_integer(). -get_portrait_ids_field () -> #inventory.portrait_ids. - --spec get_glyph_ids_field () -> non_neg_integer(). -get_glyph_ids_field () -> #inventory.glyph_ids. - --spec get_glyph_board_ids_field () -> non_neg_integer(). -get_glyph_board_ids_field () -> #inventory.glyph_board_ids. - --spec get_weapon_ids_field () -> non_neg_integer(). -get_weapon_ids_field () -> #inventory.weapon_ids. - --spec get_armor_ids_field () -> non_neg_integer(). -get_armor_ids_field () -> #inventory.armor_ids. - --spec new (shr_player:id()) -> type(). -new (OwnerID) -> -   EmptySet = ordsets:new(), - -   #inventory -   { -      owner_id = OwnerID, -      portrait_ids = EmptySet, -      glyph_ids = EmptySet, -      glyph_board_ids = EmptySet, -      weapon_ids = EmptySet, -      armor_ids = EmptySet -   }. diff --git a/src/shared/struct/map/shr_map.erl b/src/shared/struct/map/shr_map.erl index c0bf385..6db984b 100644 --- a/src/shared/struct/map/shr_map.erl +++ b/src/shared/struct/map/shr_map.erl @@ -36,7 +36,7 @@        get_markers/1,        get_marker/2, -      get_used_tile_ids/1 +      get_related_tile_ids/1     ]  ). @@ -136,8 +136,8 @@ get_markers_field () -> #map.markers.  get_tile_instances_field () -> #map.tile_instances.  %%%% Utility --spec get_used_tile_ids (type()) -> ordsets:ordset(shr_tile:id()). -get_used_tile_ids (Map) -> +-spec get_related_tile_ids (type()) -> ordsets:ordset(shr_tile:id()). +get_related_tile_ids (Map) ->     UsedTileIDs =        lists:foldl        ( diff --git a/src/shared/struct/shr_character.erl b/src/shared/struct/shr_character.erl index d5dec75..ea8e857 100644 --- a/src/shared/struct/shr_character.erl +++ b/src/shared/struct/shr_character.erl @@ -164,15 +164,15 @@ set_equipment (Eq, Char) when is_record(Char, shr_char) ->     NewAttributes =        shr_omnimods:apply_to_attributes        ( -         shr_attributes:default(), -         NewOmnimods +         NewOmnimods, +         shr_attributes:default()        ),     NewStatistics =        shr_omnimods:apply_to_statistics        ( -         shr_statistics:new_raw(NewAttributes), -         NewOmnimods +         NewOmnimods, +         shr_statistics:new_raw(NewAttributes)        ),     Char#shr_char @@ -239,15 +239,15 @@ switch_weapons (Char) when is_record(Char, shr_char) ->     NewAttributes =        shr_omnimods:apply_to_attributes        ( -         shr_attributes:default(), -         NewOmnimods +         NewOmnimods, +         shr_attributes:default()        ),     NewStatistics =        shr_omnimods:apply_to_statistics        ( -         shr_statistics:new_raw(NewAttributes), -         NewOmnimods +         NewOmnimods, +         shr_statistics:new_raw(NewAttributes)        ),     Char#shr_char @@ -325,15 +325,15 @@ set_extra_omnimods (O, Char) ->     NewAttributes =        shr_omnimods:apply_to_attributes        ( -         shr_attributes:default(), -         NewOmnimods +         NewOmnimods, +         shr_attributes:default()        ),     NewStatistics =        shr_omnimods:apply_to_statistics        ( -         shr_statistics:new_raw(NewAttributes), -         NewOmnimods +         NewOmnimods, +         shr_statistics:new_raw(NewAttributes)        ),     Char#shr_char diff --git a/src/shared/struct/shr_omnimods.erl b/src/shared/struct/shr_omnimods.erl index bfd9d25..8d82287 100644 --- a/src/shared/struct/shr_omnimods.erl +++ b/src/shared/struct/shr_omnimods.erl @@ -28,6 +28,7 @@  -export  (     [ +      default/0,        new/4,        new_dirty/4     ] @@ -115,6 +116,9 @@ new (AttributeMods, StatisticMods, AttackMods, DefenseMods) ->        defmods = dict:from_list(DefenseMods)     }. +-spec default () -> type(). +default () -> new([], [], [], []). +  -spec new_dirty  (        list(entry()), | 


