From 0c05e0e7f43917800372d3016178bf29396822fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Sat, 15 May 2010 19:31:48 +0200 Subject: [PATCH] Initial work on coordinates handling. Fix warping on spawn. Updated MOTD. --- conf/motd.txt | Bin 292 -> 620 bytes include/records.hrl | 2 +- src/egs_game.erl | 17 ++++++++++++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/conf/motd.txt b/conf/motd.txt index cf020c245be7b40e3515439b0d7be8edfc60d18a..84d9a4a7a4cf98734025b69912296131eccd5862 100644 GIT binary patch literal 620 zcmYL{K~IA~6olvOui&UAt%*myY0&6FO&a5w7Ely{0JY`MtKaMv&4z_HZ}!c+xBPs+ zs8FqqT7B}BXynWLTZmHKY8B!_18BltsMlB6mpWoyYYWnYG%#vSfuHF^704@5#gwMV!U4A*_2;y!4WRNCtT>=f1&+!kJr>+ImF23fOQF9RPr(V{UB z$BtUw?#VhGF0JEeIH*0UB-3ze1fR9;^#rw`r z{n+^p98Wtz%l!X&4^+vxfti`oZ%5vpSidJb1pn6Gg|CKuyoW@0pmvhOvwzPr-l)5d z_YkMLz_sT;u-uU+eT;&qRq6~6o`ZOS~t80z)xFDMJAe<^x%&Kt4n)1IRCB$YDqUij*@HF=R57fMtt;;<-Rp h2}1@@ERP`_D4zl37Xh&z7%BjDC4yBKO@7VT2mr9T78w8l diff --git a/include/records.hrl b/include/records.hrl index f728306..1c7b9f7 100644 --- a/include/records.hrl +++ b/include/records.hrl @@ -19,4 +19,4 @@ %% EGS database schema. -record(ids, {type, id}). --record(users, {gid, pid, socket, auth, folder, charnumber, charname, lid}). +-record(users, {gid, pid, socket, auth, folder, charnumber, charname, lid, map, entry, coords}). diff --git a/src/egs_game.erl b/src/egs_game.erl index 395ca70..8eb47cf 100644 --- a/src/egs_game.erl +++ b/src/egs_game.erl @@ -348,7 +348,11 @@ handle(16#0102, _, GID, _, Packet) -> handle(16#0503, _, GID, _, Packet) -> << _:32, Data/bits >> = Packet, - lists:foreach(fun(User) -> User#users.pid ! {psu_broadcast_0503, Data} end, egs_db:users_select_others(GID)); + << _:416, Coords:96/bits, _:160, Map:32/little-unsigned-integer, Entry:32/little-unsigned-integer, _/bits >> = Data, + User = egs_db:users_select(GID), + NewUser = User#users{coords=Coords, map=Map, entry=Entry}, + egs_db:users_insert(NewUser), + lists:foreach(fun(X) -> X#users.pid ! {psu_broadcast_0503, Data} end, egs_db:users_select_others(GID)); %% @doc Lobby change handler. @@ -410,11 +414,18 @@ build_packet_233_contents([]) -> build_packet_233_contents(Users) -> [User|Rest] = Users, {ok, File} = file:read_file("p/player.bin"), - << A:32/bits, _:32, B:64/bits, _:32, C:480/bits, _:2208, D/bits >> = File, + << A:32/bits, _:32, B:64/bits, _:32, C:192/bits, _:96, D:192/bits, _:2208, E/bits >> = File, {ok, CharFile} = file:read_file(io_lib:format("save/~s/~b-character", [User#users.folder, User#users.charnumber])), CharGID = User#users.gid, LID = User#users.lid, - Chunk = << A/binary, CharGID:32/little-unsigned-integer, B/binary, LID:16/little-unsigned-integer, 16#0100:16, C/binary, CharFile/binary, D/binary >>, + case User#users.coords of % TODO: temporary? undefined handling + undefined -> + Coords = << 0:96 >>; + _ -> + Coords = User#users.coords + end, + Chunk = << A/binary, CharGID:32/little-unsigned-integer, B/binary, LID:16/little-unsigned-integer, 16#0100:16, C/binary, + Coords:96/bits, D/binary, CharFile/binary, E/binary >>, Next = build_packet_233_contents(Rest), << Chunk/binary, Next/binary >>.