--- a/QTfrontend/net/newnetclient.cpp Sat Aug 25 12:12:15 2018 +0200
+++ b/QTfrontend/net/newnetclient.cpp Sat Aug 25 17:43:29 2018 +0200
@@ -381,22 +381,40 @@
return;
}
- QString action = HWProto::chatStringToAction(lst[2]);
+ QString action;
+ QString message;
+ // Fake nicks are nicks used for messages from the server with nicks like
+ // [server], [random], etc.
+ // The '[' character is not allowed in real nicks.
+ bool isFakeNick = lst[1].startsWith('[');
+ if(!isFakeNick)
+ {
+ // Normal message
+ message = lst[2];
+ // Check for action (/me command)
+ action = HWProto::chatStringToAction(message);
+ }
+ else
+ {
+ // Server message
+ // Server messages are translated client-side
+ message = HWApplication::translate("server", lst[2].toLatin1().constData());
+ }
if (netClientState == InLobby)
{
- if (action != NULL)
+ if (!action.isNull())
emit lobbyChatAction(lst[1], action);
else
- emit lobbyChatMessage(lst[1], lst[2]);
+ emit lobbyChatMessage(lst[1], message);
}
else
{
- emit chatStringFromNet(HWProto::formatChatMsg(lst[1], lst[2]));
- if (action != NULL)
+ emit chatStringFromNet(HWProto::formatChatMsg(lst[1], message));
+ if (!action.isNull())
emit roomChatAction(lst[1], action);
else
- emit roomChatMessage(lst[1], lst[2]);
+ emit roomChatMessage(lst[1], message);
}
return;
}
--- a/QTfrontend/ui/widget/chatwidget.cpp Sat Aug 25 12:12:15 2018 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp Sat Aug 25 17:43:29 2018 +0200
@@ -373,8 +373,8 @@
// it as host would convert it to it's lower case variant
QString HWChatWidget::linkedNick(const QString & nickname)
{
- // '[' is reserved character used for fake player names in special server messages
- if ((nickname != m_userNick) && (!nickname.contains('[')))
+ // '[' and '(' are reserved characters used for fake player names in special server messages
+ if ((nickname != m_userNick) && (!nickname.startsWith('[')) && (!nickname.startsWith('(')))
// linked nick
return QString("<a href=\"hwnick://?%1\" class=\"nick\">%2</a>").arg(
QString(nickname.toUtf8().toBase64())).arg(nickname.toHtmlEscaped());
--- a/gameServer/CommandHelp.hs Sat Aug 25 12:12:15 2018 +0200
+++ b/gameServer/CommandHelp.hs Sat Aug 25 17:43:29 2018 +0200
@@ -99,7 +99,7 @@
-- Helper functions for chat command handler
cmdHelpActionEntry :: [ClientChan] -> B.ByteString -> Action
-cmdHelpActionEntry chan msg = AnswerClients chan [ "CHAT", "[server]", B.concat [ " ", msg ] ]
+cmdHelpActionEntry chan msg = AnswerClients chan [ "CHAT", "[server]", msg ]
cmdHelpActionList :: [ClientChan] -> [B.ByteString] -> [Action]
cmdHelpActionList chan list = map (cmdHelpActionEntry chan) list
--- a/gameServer/HWProtoCore.hs Sat Aug 25 12:12:15 2018 +0200
+++ b/gameServer/HWProtoCore.hs Sat Aug 25 17:43:29 2018 +0200
@@ -81,7 +81,8 @@
h "GLOBAL" p = serverAdminOnly $ do
rnc <- liftM snd ask
let chans = map (sendChan . client rnc) $ allClients rnc
- return [AnswerClients chans ["CHAT", "[global notice]", p]]
+ -- parenthesis instead of square brackets used to avoid accidental translation by frontend
+ return [AnswerClients chans ["CHAT", "(global notice)", p]]
h "WATCH" f = return [QueryReplay f]
h "FIX" _ = handleCmd ["FIX"]
h "UNFIX" _ = handleCmd ["UNFIX"]