From e2a74899c5ab96a4a1dc848ca8e48df9b126a70a Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Tue, 9 Dec 2008 20:29:51 +0100 Subject: Fixed two issues with the chat message parsing MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Don't treat anything starting with "Welcome" as a server message, for example messages starting with a name that starts with "Welcome" shouldn't belong in that category. Put the nick in the right place for global announcements. Signed-off-by: Bjørn Lindeijer --- src/gui/chat.cpp | 23 +++++++++++++++++------ 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/gui/chat.cpp b/src/gui/chat.cpp index eef1150f..34e7b04b 100644 --- a/src/gui/chat.cpp +++ b/src/gui/chat.cpp @@ -120,22 +120,33 @@ void ChatWindow::chatLog(std::string line, int own, bool ignoreRecord) tmp.nick = ""; tmp.text = line; - // Fix the owner of welcome message. - if (line.substr(0, 7) == "Welcome") { - own = BY_SERVER; - } std::string::size_type pos = line.find(" : "); if (pos != std::string::npos) { tmp.nick = line.substr(0, pos); tmp.text = line.substr(pos + 3); + } else { + // Fix the owner of welcome message. + if (line.substr(0, 7) == "Welcome") + { + own = BY_SERVER; + } } std::string lineColor = "##C"; switch (own) { case BY_GM: - tmp.nick += std::string("Global announcement: "); - lineColor = "##G"; + if (tmp.nick.empty()) + { + tmp.nick = std::string("Global announcement: "); + lineColor = "##G"; + } + else + { + tmp.nick = std::string("Global announcement from " + tmp.nick + + std::string(": ")); + lineColor = "##1"; // Equiv. to BrowserBox::RED + } break; case BY_PLAYER: tmp.nick += CAT_NORMAL; -- cgit v1.2.3-70-g09d2