QTfrontend/net/newnetclient.cpp
changeset 13697 70c8feb81d35
parent 13678 1aa5e884326a
child 13700 e529a34872f9
--- 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;
     }