QTfrontend/net/newnetclient.cpp
changeset 13969 4d761adb4e6c
parent 13846 d8e606cf8ff5
child 14838 bdb47255d7e4
equal deleted inserted replaced
13968:9468efabd337 13969:4d761adb4e6c
   381             return;
   381             return;
   382         }
   382         }
   383 
   383 
   384         QString action;
   384         QString action;
   385         QString message;
   385         QString message;
       
   386         QString sender = lst[1];
   386         // '[' is a special character used in fake nick names of server messages.
   387         // '[' is a special character used in fake nick names of server messages.
   387         // Those are supposed to be translated
   388         // Those are supposed to be translated
   388         if(!lst[1].startsWith('['))
   389         if(!sender.startsWith('['))
   389         {
   390         {
   390             // Normal message
   391             // Normal message
   391             message = lst[2];
   392             message = lst[2];
   392             // Another kind of fake nick. '(' nicks are server messages, but they must not be translated
   393             // Another kind of fake nick. '(' nicks are server messages, but they must not be translated
   393             if(!lst[1].startsWith('('))
   394             if(!sender.startsWith('('))
   394             {
   395             {
   395                 // Check for action (/me command)
   396                 // Check for action (/me command)
   396                 action = HWProto::chatStringToAction(message);
   397                 action = HWProto::chatStringToAction(message);
       
   398             }
       
   399             else
       
   400             {
       
   401                 // If parenthesis were used, replace them with square brackets
       
   402                 // for a consistent style.
       
   403                 sender.replace(0, 1, '[');
       
   404                 sender.replace(sender.length()-1, 1, ']');
   397             }
   405             }
   398         }
   406         }
   399         else
   407         else
   400         {
   408         {
   401             // Server message
   409             // Server message
   404         }
   412         }
   405 
   413 
   406         if (netClientState == InLobby)
   414         if (netClientState == InLobby)
   407         {
   415         {
   408             if (!action.isNull())
   416             if (!action.isNull())
   409                 emit lobbyChatAction(lst[1], action);
   417                 emit lobbyChatAction(sender, action);
   410             else
   418             else
   411                 emit lobbyChatMessage(lst[1], message);
   419                 emit lobbyChatMessage(sender, message);
   412         }
   420         }
   413         else
   421         else
   414         {
   422         {
   415             emit chatStringFromNet(HWProto::formatChatMsg(lst[1], message));
   423             emit chatStringFromNet(HWProto::formatChatMsg(sender, message));
   416             if (!action.isNull())
   424             if (!action.isNull())
   417                 emit roomChatAction(lst[1], action);
   425                 emit roomChatAction(sender, action);
   418             else
   426             else
   419                 emit roomChatMessage(lst[1], message);
   427                 emit roomChatMessage(sender, message);
   420         }
   428         }
   421         return;
   429         return;
   422     }
   430     }
   423 
   431 
   424     if (lst[0] == "INFO")
   432     if (lst[0] == "INFO")