psu_proto: Review send_0115 and move it to psu_proto.

This commit is contained in:
Loïc Hoguin 2010-09-23 16:09:13 +02:00
parent 5f2ad649a5
commit f0a88e1b19
4 changed files with 26 additions and 25 deletions

View File

@ -348,9 +348,7 @@ event({hit, FromTargetID, ToTargetID, A, B}, State=#state{gid=GID}) ->
end,
%% exp
if HasEXP =:= true ->
Character = NewUser#egs_user_model.character,
Level = Character#characters.mainlevel,
psu_game:send_0115(GID, ToTargetID, Level#level.number, Level#level.exp, Character#characters.money);
psu_proto:send_0115(NewUser#egs_user_model{lid=0}, ToTargetID, State);
true -> ignore
end,
%% save

View File

@ -30,25 +30,13 @@
%% Only contains the actually saved data, not the stats and related information.
character_tuple_to_binary(Tuple) ->
#characters{type=Type, name=Name, race=Race, gender=Gender, class=Class, appearance=Appearance,
mainlevel=Level, blastbar=BlastBar, luck=Luck, money=Money, playtime=PlayTime} = Tuple,
#level{number=LV, exp=EXP} = Level,
#characters{name=Name, race=Race, gender=Gender, class=Class, appearance=Appearance} = Tuple,
RaceBin = race_atom_to_binary(Race),
GenderBin = gender_atom_to_binary(Gender),
ClassBin = class_atom_to_binary(Class),
AppearanceBin = psu_appearance:tuple_to_binary(Race, Appearance),
FooterBin = case Type of
npc ->
<< 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#4e4f4630:32, 16#08000000:32, 0:32, 0:32, 16#4e454e44:32 >>;
_ -> %% @todo Handle classes.
<< 0:160,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32 >>
end,
<< Name/binary, RaceBin:8, GenderBin:8, ClassBin:8, AppearanceBin/binary, LV:32/little-unsigned-integer, BlastBar:16/little-unsigned-integer,
Luck:8, 0:40, EXP:32/little-unsigned-integer, 0:32, Money:32/little-unsigned-integer, PlayTime:32/little-unsigned-integer, FooterBin/binary >>.
LevelsBin = psu_proto:build_char_level(Tuple),
<< Name/binary, RaceBin:8, GenderBin:8, ClassBin:8, AppearanceBin/binary, LevelsBin/binary >>.
%% @doc Convert a character tuple into a binary to be sent to clients.
%% Contains everything from character_tuple_to_binary/1 along with location, stats, SE and more.

View File

@ -148,6 +148,7 @@ area_load(AreaType, IsStart, SetID, OldUser, User, QuestFile, ZoneFile, AreaName
psu_proto:send_020e(QuestFile, State);
true -> ignore
end,
%% @todo The LID changes here.
if IsStart =:= true ->
psu_proto:send_0215(16#ffffffff, State);
true -> ignore
@ -288,13 +289,6 @@ send_0113() ->
GID = get(gid),
send(<< 16#01130300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, GID:32/little-unsigned-integer, File/binary >>).
%% @doc Update the character's EXP, level or money.
send_0115(GID, TargetID, LV, EXP, Money) ->
send(<< 16#01150300:32, 0:64, GID:32/little-unsigned-integer, 0:64, 16#00011300:32, GID:32/little-unsigned-integer, 0:64, GID:32/little-unsigned-integer,
0:32, TargetID:32/little-unsigned-integer, LV:32/little-unsigned-integer, 0:32, 0:32, EXP:32/little-unsigned-integer, 0:32, Money:32/little-unsigned-integer, 16#f5470500:32, 0:96, 0:64,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32 >>).
%% @doc Revive player?
%% @todo Figure out more of it.
send_0117(HP) ->

View File

@ -1177,6 +1177,27 @@ send_010d(CharUser, #state{socket=Socket, gid=DestGID}) ->
0:64, 1:32/little-unsigned-integer, 0:32, 16#00000300:32, 16#ffff0000:32, 0:32, CharGID:32/little-unsigned-integer,
0:192, CharGID:32/little-unsigned-integer, CharLID:32/little-unsigned-integer, 16#ffffffff:32, CharBin/binary >>).
%% @doc Update the character level, blastbar, luck and money information.
send_0115(CharUser, State) ->
send_0115(CharUser, 16#ffffffff, State).
send_0115(#egs_user_model{id=CharGID, lid=CharLID, character=Character}, EnemyTargetID, #state{socket=Socket, gid=DestGID, lid=DestLID}) ->
packet_send(Socket, << 16#01150300:32, DestLID:16/little, 0:48, CharGID:32/little, 0:64, 16#00011300:32, DestGID:32/little, 0:64,
CharGID:32/little, CharLID:32/little, EnemyTargetID:32/little, (build_char_level(Character))/binary >>).
%% @todo Handle class levels.
build_char_level(#characters{type=Type, mainlevel=#level{number=Level, exp=EXP}, blastbar=BlastBar, luck=Luck, money=Money, playtime=PlayTime}) ->
ClassesBin = case Type of
npc ->
<< 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#4e4f4630:32, 16#08000000:32, 0:32, 0:32, 16#4e454e44:32 >>;
_ ->
<< 0:160,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32,
16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32, 16#01000000:32 >>
end,
<< Level:32/little, BlastBar:16/little, Luck:8, 0:40, EXP:32/little, 0:32, Money:32/little, PlayTime:32/little, ClassesBin/binary >>.
%% @doc Send character location, appearance and other information.
send_0201(CharUser, #state{socket=Socket, gid=DestGID}) ->
[CharTypeID, GameVersion] = case (CharUser#egs_user_model.character)#characters.type of