From 2dc9d30660fbbf472b1215a2874db14fd57883b0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Hoguin?= Date: Fri, 4 Jun 2010 12:18:12 +0200 Subject: [PATCH] proto: Remove parse_chat. --- src/egs_game.erl | 24 ++++++++++-------------- src/egs_proto.erl | 12 ------------ 2 files changed, 10 insertions(+), 26 deletions(-) diff --git a/src/egs_game.erl b/src/egs_game.erl index 2ccfc88..59d70dc 100644 --- a/src/egs_game.erl +++ b/src/egs_game.erl @@ -573,23 +573,19 @@ handle(16#0302, _, GID, _, _) -> %% @todo Only broadcast to people in the same map. handle(16#0304, _, GID, Version, Orig) -> - [{gid, _}, {name, ChatName}, {modifiers, ChatModifiers}, {message, ChatMessage}] = egs_proto:parse_chat(Version, Orig), - case ChatName of - missing -> - case egs_db:users_select(GID) of - error -> - ActualName = ChatName; - User -> - ActualName = User#users.charname - end; - _ -> - ActualName = ChatName + case Version of + 0 -> % AOTI v2.000 + << _:416, Modifiers:128/bits, Message/bits >> = Orig, + User = egs_db:users_select(GID), + Name = User#users.charname; + _ -> % Above + << _:416, Modifiers:128/bits, Name:512/bits, Message/bits >> = Orig end, - [LogName|_] = re:split(ActualName, "\\0\\0", [{return, binary}]), - [TmpMessage|_] = re:split(ChatMessage, "\\0\\0", [{return, binary}]), + [LogName|_] = re:split(Name, "\\0\\0", [{return, binary}]), + [TmpMessage|_] = re:split(Message, "\\0\\0", [{return, binary}]), LogMessage = re:replace(TmpMessage, "\\n", " ", [global, {return, binary}]), log(GID, "chat from ~s: ~s", [[re:replace(LogName, "\\0", "", [global, {return, binary}])], [re:replace(LogMessage, "\\0", "", [global, {return, binary}])]]), - lists:foreach(fun(User) -> User#users.pid ! {psu_chat, GID, ActualName, ChatModifiers, ChatMessage} end, egs_db:users_select_all()); + lists:foreach(fun(User) -> User#users.pid ! {psu_chat, GID, Name, Modifiers, Message} end, egs_db:users_select_all()); %% @todo Handle this packet. Ignore for now. diff --git a/src/egs_proto.erl b/src/egs_proto.erl index fe06790..5f4377a 100644 --- a/src/egs_proto.erl +++ b/src/egs_proto.erl @@ -119,18 +119,6 @@ packet_split(Packet, Result) -> end end. -%% @doc Parse a chat command. AOTI v2.000 version of the command. - -parse_chat(0, Packet) -> - << _:384, FromGID:32/unsigned-integer, Modifiers:128/bits, Message/bits >> = Packet, - [{gid, FromGID}, {name, missing}, {modifiers, Modifiers}, {message, Message}]; - -%% @doc Parse a chat command. AOTI since an unknown version of the game. - -parse_chat(_, Packet) -> - << _:384, FromGID:32/unsigned-integer, Modifiers:128/bits, FromName:512/bits, Message/bits >> = Packet, - [{gid, FromGID}, {name, FromName}, {modifiers, Modifiers}, {message, Message}]. - %% @doc Center the camera on the player, if possible. %% @todo Probably.