game: Print chat messages.

This commit is contained in:
Loïc Hoguin 2010-05-24 13:41:06 +02:00
parent 52d6bccc5f
commit dd0162458b

View File

@ -380,7 +380,6 @@ handle(16#0302, _, GID, _, _) ->
%% @todo Only broadcast to people in the same map. %% @todo Only broadcast to people in the same map.
handle(16#0304, _, GID, Version, Packet) -> handle(16#0304, _, GID, Version, Packet) ->
log(GID, "broadcast chat"),
[{gid, _}, {name, ChatName}, {modifiers, ChatModifiers}, {message, ChatMessage}] = egs_proto:parse_chat(Version, Packet), [{gid, _}, {name, ChatName}, {modifiers, ChatModifiers}, {message, ChatMessage}] = egs_proto:parse_chat(Version, Packet),
case ChatName of case ChatName of
missing -> missing ->
@ -393,6 +392,9 @@ handle(16#0304, _, GID, Version, Packet) ->
_ -> _ ->
ActualName = ChatName ActualName = ChatName
end, end,
[LogName|_] = re:split(ActualName, "\\0\\0", [{return, binary}]),
[LogMessage|_] = re:split(ChatMessage, "\\0\\0", [{return, binary}]),
log(GID, io_lib:format("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, ActualName, ChatModifiers, ChatMessage} end, egs_db:users_select_all());
%% @doc Map change handler. %% @doc Map change handler.