From 066e2a4839504ffd2adcce31bdc1fbc3202938f3 Mon Sep 17 00:00:00 2001 From: Nathan Fulton Date: Tue, 15 Mar 2016 13:32:25 -0400 Subject: [PATCH] Use a username with whispers and mod chats MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit “username to username:” or “username to mods:” was originally prefixed to the chat and then the whole string was sent as a server message. Now, “username to username:” is considered the user’s name for the chat. This way, clients will process it as a user chat instead of a server message (this results in the client coloring the chat differently). --- server/endpoint.cpp | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/server/endpoint.cpp b/server/endpoint.cpp index 7b12f00..469dd32 100644 --- a/server/endpoint.cpp +++ b/server/endpoint.cpp @@ -1237,9 +1237,9 @@ bool Endpoint::ProcessCommand(const char *chat, std::string *response) { std::string dummy; const char *rest; if (GetArgument(chat, 0, &dummy, &rest) && *rest != 0) { - const char *s = base::Format::ToString("%s to mods: %s", - name_, rest); - server_.lobby().SendAdminChat("", s, true); + const char *s = base::Format::ToString("%s to mods", + name_); + server_.lobby().SendAdminChat(s, rest, true); } } *response = ""; @@ -1254,23 +1254,31 @@ bool Endpoint::ProcessCommand(const char *chat, std::string *response) { std::string dummy; const char *rest; if (GetArgument(chat, 1, &dummy, &rest) && *rest != 0) { - const char *s = base::Format::ToString("%s to %s: %s", - name_, endpoint->name(), rest); + const char *s = base::Format::ToString("%s to %s", + name_, endpoint->name()); if (endpoint->state_ == ES_GAME) { endpoint->xpump().Send( - XMsgGameReceiveChat::ToBuffer("", s)); + XMsgGameReceiveChat::ToBuffer(s, rest)); } if (endpoint->state_ == ES_ROOM) { endpoint->xpump().Send( - XMsgRoomReceiveChat::ToBuffer("", s)); + XMsgRoomReceiveChat::ToBuffer(s, rest)); } - server_.logger().LogSystemMsg(this, s); if (endpoint != this) { - *response = s; - return true; + if (this->state_ == ES_GAME) { + this->xpump().Send( + XMsgGameReceiveChat::ToBuffer(s, rest)); + } + if (this->state_ == ES_ROOM) { + this->xpump().Send( + XMsgRoomReceiveChat::ToBuffer(s, rest)); + } } + server_.logger().LogSystemMsg(this, base::Format::ToString( + "%s: %s", s, rest)); } *response = ""; + return true; } break;