summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Makefile27
-rw-r--r--src/battle/struct/btl_character.erl60
-rw-r--r--src/bounty/bnt_join_battle.erl6
-rw-r--r--src/roster/struct/rst_character.erl56
4 files changed, 78 insertions, 71 deletions
diff --git a/Makefile b/Makefile
index 82a5c0b..77ba3c8 100644
--- a/Makefile
+++ b/Makefile
@@ -21,7 +21,7 @@ ERLC ?= erlc
ERLC_OPTS ?=
ERL ?= erl
-ERL_OPTS ?= -connect_all false -pa $(BIN_DIR)
+ERL_OPTS ?= -connect_all false -pa `find $(BIN_DIR) -type d`
YAWS ?= yaws
YAWS_OPTS ?= $(ERL_NAME_VS_SNAME) query_node -erlarg "$(ERL_OPTS)"
@@ -33,6 +33,7 @@ M4 ?= m4
M4_OPTS ?=
## Filenames
+DIALYZER_BASE_PLT_FILE ?= base.plt
DIALYZER_PLT_FILE ?= tacticians-server.plt
YAWS_CONFIG_FILE ?= $(CONFIG_DIR)/yaws.conf
@@ -50,8 +51,12 @@ PREPROCESSABLE_FILES = $(shell find -L ${CURDIR} -name "*.m4")
PREPROCESSED_FILES = $(patsubst %.m4,%,$(PREPROCESSABLE_FILES))
## Erlang
-ERL_SRC_FILES = $(shell find -L $(SRC_DIR) -name "*.erl")
-ERL_BIN_FILES = $(patsubst %.erl,$(BIN_DIR)/%.beam,$(notdir $(ERL_SRC_FILES)))
+PREPROCESSED_ERL_SRC_FILES = $(filter %.erl,$(PREPROCESSED_FILES))
+CURRENT_ERL_SRC_FILES = $(shell find -L $(SRC_DIR) -name "*.erl")
+ERL_SRC_FILES = \
+ $(filter-out $(PREPROCESSED_ERL_SRC_FILES),$(CURRENT_ERL_SRC_FILES)) \
+ $(PREPROCESSED_ERL_SRC_FILES)
+ERL_BIN_FILES = $(patsubst $(SRC_DIR)%.erl,$(BIN_DIR)/%.beam,$(ERL_SRC_FILES))
## Yaws
REQUIRED_HEADERS = $(INCLUDE_DIR)/yaws_api.hrl
@@ -126,17 +131,19 @@ debug_rebuild:
$(MAKE) clean
$(MAKE) ERLC_OPTS="$(ERLC_OPTS) +debug_info"
-ifeq ($(wildcard $(DIALYZER_PLT_FILE)),)
-debug_run:
+$(DIALYZER_BASE_PLT_FILE):
$(DIALYZER_EXEC) --build_plt --apps erts kernel stdlib crypto jiffy mnesia \
- --output_plt $(DIALYZER_PLT_FILE)
+ --output_plt $@
+ifeq ($(wildcard $(DIALYZER_PLT_FILE)),)
+debug_run: $(DIALYZER_BASE_PLT_FILE)
$(MAKE) debug_rebuild
+ cp $< $(DIALYZER_PLT_FILE)
$(DIALYZER_EXEC) --add_to_plt --plt $(DIALYZER_PLT_FILE) -r $(BIN_DIR)
else
debug_run:
$(MAKE) debug_rebuild
$(DIALYZER_EXEC) --check_plt --plt $(DIALYZER_PLT_FILE)
- $(DIALYZER_EXEC) --get_warnings $(ERL_SRC_FILES) \
+ $(DIALYZER_EXEC) --get_warnings $(ERL_SRC_FILES) $(PREPROCESSED_ERL_SRC_FILES)\
--src --plt $(DIALYZER_PLT_FILE)
endif
@@ -146,9 +153,9 @@ $(PREPROCESSED_FILES): %: %.m4 .PHONY
$(OPTIONAL_DIRS): %:
mkdir -p $@
-.SECONDEXPANSION:
-$(ERL_BIN_FILES): $(BIN_DIR)/%.beam: $$(shell find -L $(SRC_DIR) -name "%.erl")
- $(ERLC_EXEC) -o $(BIN_DIR) $<
+$(ERL_BIN_FILES): $(BIN_DIR)/%.beam: $(SRC_DIR)/%.erl
+ mkdir -p $(dir $@)
+ $(ERLC_EXEC) -o $(dir $@) $<
.PHONY:
diff --git a/src/battle/struct/btl_character.erl b/src/battle/struct/btl_character.erl
index 84eecfb..f5b230d 100644
--- a/src/battle/struct/btl_character.erl
+++ b/src/battle/struct/btl_character.erl
@@ -7,7 +7,7 @@
-record
(
- character,
+ btl_char,
{
player_ix :: non_neg_integer(),
name :: binary(),
@@ -23,7 +23,7 @@
}
).
--opaque type() :: #character{}.
+-opaque type() :: #btl_char{}.
-export_type([type/0, rank/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -79,53 +79,53 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-spec get_player_index (type()) -> non_neg_integer().
-get_player_index (Char) -> Char#character.player_ix.
+get_player_index (Char) -> Char#btl_char.player_ix.
-spec get_name (type()) -> binary().
-get_name (Char) -> Char#character.name.
+get_name (Char) -> Char#btl_char.name.
-spec get_rank (type()) -> rank().
-get_rank (Char) -> Char#character.rank.
+get_rank (Char) -> Char#btl_char.rank.
-spec get_portrait_id (type()) -> shr_portrait:id().
-get_portrait_id (Char) -> Char#character.portrait_id.
+get_portrait_id (Char) -> Char#btl_char.portrait_id.
-spec get_armor_id (type()) -> shr_armor:id().
-get_armor_id (Char) -> Char#character.armor_id.
+get_armor_id (Char) -> Char#btl_char.armor_id.
-spec get_weapon_ids (type()) -> {shr_weapon:id(), shr_weapon:id()}.
-get_weapon_ids (Char) -> Char#character.weapon_ids.
+get_weapon_ids (Char) -> Char#btl_char.weapon_ids.
-spec get_location (type()) -> {non_neg_integer(), non_neg_integer()}.
-get_location (Char) -> Char#character.location.
+get_location (Char) -> Char#btl_char.location.
-spec get_current_health (type()) -> integer().
-get_current_health (Char) -> Char#character.current_health.
+get_current_health (Char) -> Char#btl_char.current_health.
-spec get_permanent_omnimods (type()) -> shr_omnimods:type().
-get_permanent_omnimods (Char) -> Char#character.permanent_omnimods.
+get_permanent_omnimods (Char) -> Char#btl_char.permanent_omnimods.
-spec get_is_alive (type()) -> boolean().
get_is_alive (Char) ->
(
- (not Char#character.is_defeated)
- and (Char#character.current_health > 0)
+ (not Char#btl_char.is_defeated)
+ and (Char#btl_char.current_health > 0)
).
-spec get_is_active (type()) -> boolean().
get_is_active (Char) ->
(
- (not Char#character.is_defeated)
- and Char#character.is_active
+ (not Char#btl_char.is_defeated)
+ and Char#btl_char.is_active
and get_is_alive(Char)
).
-spec get_is_defeated (type()) -> boolean().
-get_is_defeated (Char) -> Char#character.is_defeated.
+get_is_defeated (Char) -> Char#btl_char.is_defeated.
-spec set_rank (rank(), type()) -> type().
set_rank (Rank, Char) ->
- Char#character
+ Char#btl_char
{
rank = Rank
}.
@@ -137,42 +137,42 @@ set_rank (Rank, Char) ->
)
-> type().
set_location (Location, Char) ->
- Char#character
+ Char#btl_char
{
location = Location
}.
-spec set_current_health (integer(), type()) -> type().
set_current_health (Health, Char) ->
- Char#character
+ Char#btl_char
{
current_health = Health
}.
-spec set_is_active (boolean(), type()) -> type().
set_is_active (Active, Char) ->
- Char#character
+ Char#btl_char
{
is_active = Active
}.
-spec set_is_defeated (boolean(), type()) -> type().
set_is_defeated (Defeated, Char) ->
- Char#character
+ Char#btl_char
{
is_defeated = Defeated
}.
-spec set_armor_id (shr_armor:id(), type()) -> type().
set_armor_id (ArmorID, Char) ->
- Char#character
+ Char#btl_char
{
armor_id = ArmorID
}.
-spec set_weapon_ids ({shr_weapon:id(), shr_weapon:id()}, type()) -> type().
set_weapon_ids (WeaponIDs, Char) ->
- Char#character
+ Char#btl_char
{
weapon_ids = WeaponIDs
}.
@@ -236,7 +236,7 @@ new
shr_statistics:new_raw(CurrentAttributes)
),
- #character
+ #btl_char
{
player_ix = PlayerIX,
name = Name,
@@ -252,14 +252,14 @@ new
}.
-spec get_rank_field() -> non_neg_integer().
-get_rank_field () -> #character.rank.
+get_rank_field () -> #btl_char.rank.
-spec get_weapons_field() -> non_neg_integer().
-get_weapons_field () -> #character.weapon_ids.
+get_weapons_field () -> #btl_char.weapon_ids.
-spec get_location_field() -> non_neg_integer().
-get_location_field () -> #character.location.
+get_location_field () -> #btl_char.location.
-spec get_current_health_field() -> non_neg_integer().
-get_current_health_field () -> #character.current_health.
+get_current_health_field () -> #btl_char.current_health.
-spec get_is_active_field() -> non_neg_integer().
-get_is_active_field () -> #character.is_active.
+get_is_active_field () -> #btl_char.is_active.
-spec get_is_defeated_field() -> non_neg_integer().
-get_is_defeated_field () -> #character.is_defeated.
+get_is_defeated_field () -> #btl_char.is_defeated.
diff --git a/src/bounty/bnt_join_battle.erl b/src/bounty/bnt_join_battle.erl
index 1028166..71b6eb1 100644
--- a/src/bounty/bnt_join_battle.erl
+++ b/src/bounty/bnt_join_battle.erl
@@ -44,7 +44,7 @@ update_ordset (New, Old) ->
-spec get_equipment_ids
(
- orddict:orddict(non_neg_integer(), btl_character:type())
+ list(btl_character:type())
)
->
{
@@ -58,9 +58,9 @@ get_equipment_ids (Characters) ->
UsedWeaponIDs,
UsedArmorIDs
} =
- orddict:fold
+ lists:foldl
(
- fun (_IX, Character, {UPIDs, UWIDs, UAIDs}) ->
+ fun (Character, {UPIDs, UWIDs, UAIDs}) ->
{MWpID, SWpID} = btl_character:get_weapon_ids(Character),
AID = btl_character:get_armor_id(Character),
PID = btl_character:get_portrait_id(Character),
diff --git a/src/roster/struct/rst_character.erl b/src/roster/struct/rst_character.erl
index 2a159e4..61d7b7e 100644
--- a/src/roster/struct/rst_character.erl
+++ b/src/roster/struct/rst_character.erl
@@ -5,7 +5,7 @@
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-record
(
- character,
+ rst_char,
{
name :: binary(),
portrait_id :: shr_portrait:id(),
@@ -16,7 +16,7 @@
}
).
--opaque type() :: #character{}.
+-opaque type() :: #rst_char{}.
-export_type([type/0]).
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
@@ -117,62 +117,62 @@ validate_glyphs_on_board (_Glyphs, _GlyphBoard) ->
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%%% Accessors
-spec get_name (type()) -> binary().
-get_name (Char) -> Char#character.name.
+get_name (Char) -> Char#rst_char.name.
-spec get_portrait_id (type()) -> shr_portrait:id().
-get_portrait_id (Char) -> Char#character.portrait_id.
+get_portrait_id (Char) -> Char#rst_char.portrait_id.
-spec get_weapon_ids (type()) -> {shr_weapon:id(), shr_weapon:id()}.
-get_weapon_ids (Char) -> Char#character.weapon_ids.
+get_weapon_ids (Char) -> Char#rst_char.weapon_ids.
-spec get_armor_id (type()) -> shr_armor:id().
-get_armor_id (Char) -> Char#character.armor_id.
+get_armor_id (Char) -> Char#rst_char.armor_id.
-spec get_glyph_ids (type()) -> list(shr_glyph:id()).
-get_glyph_ids (Char) -> Char#character.glyph_ids.
+get_glyph_ids (Char) -> Char#rst_char.glyph_ids.
-spec get_glyph_board_id (type()) -> shr_glyph_board:id().
-get_glyph_board_id (Char) -> Char#character.glyph_board_id.
+get_glyph_board_id (Char) -> Char#rst_char.glyph_board_id.
-spec set_name (binary(), type()) -> type().
set_name (Name, Char) ->
- Char#character
+ Char#rst_char
{
name = Name
}.
-spec set_portrait_id (shr_portrait:id(), type()) -> type().
set_portrait_id (PortraitID, Char) ->
- Char#character
+ Char#rst_char
{
portrait_id = PortraitID
}.
-spec set_armor_id (shr_armor:id(), type()) -> type().
set_armor_id (ArmorID, Char) ->
- Char#character
+ Char#rst_char
{
armor_id = ArmorID
}.
-spec set_weapon_ids ({shr_weapon:id(), shr_weapon:id()}, type()) -> type().
set_weapon_ids (WeaponIDs, Char) ->
- Char#character
+ Char#rst_char
{
weapon_ids = WeaponIDs
}.
-spec set_glyph_ids (list(shr_glyph:id()), type()) -> type().
set_glyph_ids (GlyphIDs, Char) ->
- Char#character
+ Char#rst_char
{
glyph_ids = GlyphIDs
}.
-spec set_glyph_board_id (shr_glyph_board:id(), type()) -> type().
set_glyph_board_id (GlyphBoardID, Char) ->
- Char#character
+ Char#rst_char
{
glyph_board_id = GlyphBoardID
}.
@@ -180,7 +180,7 @@ set_glyph_board_id (GlyphBoardID, Char) ->
-spec new () -> type().
new () ->
UnarmedID = shr_weapon:get_id(shr_weapon:none()),
- #character
+ #rst_char
{
name = <<"Nameless">>,
portrait_id = shr_portrait:get_id(shr_portrait:default()),
@@ -191,17 +191,17 @@ new () ->
}.
-spec get_name_field () -> non_neg_integer().
-get_name_field () -> #character.name.
+get_name_field () -> #rst_char.name.
-spec get_portrait_id_field () -> non_neg_integer().
-get_portrait_id_field () -> #character.portrait_id.
+get_portrait_id_field () -> #rst_char.portrait_id.
-spec get_armor_id_field () -> non_neg_integer().
-get_armor_id_field () -> #character.armor_id.
+get_armor_id_field () -> #rst_char.armor_id.
-spec get_weapon_ids_field () -> non_neg_integer().
-get_weapon_ids_field () -> #character.weapon_ids.
+get_weapon_ids_field () -> #rst_char.weapon_ids.
-spec get_glyph_ids_field () -> non_neg_integer().
-get_glyph_ids_field () -> #character.glyph_ids.
+get_glyph_ids_field () -> #rst_char.glyph_ids.
-spec get_glyph_board_id_field () -> non_neg_integer().
-get_glyph_board_id_field () -> #character.glyph_board_id.
+get_glyph_board_id_field () -> #rst_char.glyph_board_id.
-spec decode (map()) -> type().
decode (JSONReqMap) ->
@@ -213,7 +213,7 @@ decode (JSONReqMap) ->
GlyphsList = maps:get(<<"gls">>, JSONReqMap),
GlyphBoard = maps:get(<<"gb">>, JSONReqMap),
- #character
+ #rst_char
{
name = Name,
portrait_id = Portrait,
@@ -225,13 +225,13 @@ decode (JSONReqMap) ->
-spec validate (shr_inventory:type(), type()) -> ok.
validate (Inventory, Character) ->
- Glyphs = Character#character.glyph_ids,
- GlyphBoard = Character#character.glyph_board_id,
+ Glyphs = Character#rst_char.glyph_ids,
+ GlyphBoard = Character#rst_char.glyph_board_id,
- validate_name(Character#character.name),
- validate_portrait_id(Inventory, Character#character.portrait_id),
- validate_weapons(Inventory, Character#character.weapon_ids),
- validate_armor(Inventory, Character#character.armor_id),
+ validate_name(Character#rst_char.name),
+ validate_portrait_id(Inventory, Character#rst_char.portrait_id),
+ validate_weapons(Inventory, Character#rst_char.weapon_ids),
+ validate_armor(Inventory, Character#rst_char.armor_id),
validate_glyphs(Inventory, Glyphs),
validate_glyph_board(Inventory, GlyphBoard),
validate_glyphs_on_board(Glyphs, GlyphBoard),