Frontend: Make sure special nicks always show up in square brackets
authorWuzzy <Wuzzy2@mail.ru>
Thu, 25 Oct 2018 18:35:35 +0200
changeset 13969 4d761adb4e6c
parent 13968 9468efabd337
child 13970 f791c46b47a4
Frontend: Make sure special nicks always show up in square brackets
QTfrontend/net/newnetclient.cpp
--- a/QTfrontend/net/newnetclient.cpp	Thu Oct 25 16:44:46 2018 +0200
+++ b/QTfrontend/net/newnetclient.cpp	Thu Oct 25 18:35:35 2018 +0200
@@ -383,18 +383,26 @@
 
         QString action;
         QString message;
+        QString sender = lst[1];
         // '[' is a special character used in fake nick names of server messages.
         // Those are supposed to be translated
-        if(!lst[1].startsWith('['))
+        if(!sender.startsWith('['))
         {
             // Normal message
             message = lst[2];
             // Another kind of fake nick. '(' nicks are server messages, but they must not be translated
-            if(!lst[1].startsWith('('))
+            if(!sender.startsWith('('))
             {
                 // Check for action (/me command)
                 action = HWProto::chatStringToAction(message);
             }
+            else
+            {
+                // If parenthesis were used, replace them with square brackets
+                // for a consistent style.
+                sender.replace(0, 1, '[');
+                sender.replace(sender.length()-1, 1, ']');
+            }
         }
         else
         {
@@ -406,17 +414,17 @@
         if (netClientState == InLobby)
         {
             if (!action.isNull())
-                emit lobbyChatAction(lst[1], action);
+                emit lobbyChatAction(sender, action);
             else
-                emit lobbyChatMessage(lst[1], message);
+                emit lobbyChatMessage(sender, message);
         }
         else
         {
-            emit chatStringFromNet(HWProto::formatChatMsg(lst[1], message));
+            emit chatStringFromNet(HWProto::formatChatMsg(sender, message));
             if (!action.isNull())
-                emit roomChatAction(lst[1], action);
+                emit roomChatAction(sender, action);
             else
-                emit roomChatMessage(lst[1], message);
+                emit roomChatMessage(sender, message);
         }
         return;
     }