Simplify /quit chat command
authorWuzzy <Wuzzy2@mail.ru>
Fri, 05 Oct 2018 13:37:49 +0200
changeset 13867 d8e606cf8ff5
parent 13866 1a1fb597da8f
child 13868 1738ae8c8e75
Simplify /quit chat command
QTfrontend/hwform.cpp
QTfrontend/net/newnetclient.cpp
QTfrontend/ui/widget/chatwidget.cpp
gameServer/HWProtoCore.hs
gameServer/HWProtoInRoomState.hs
share/hedgewars/Data/Locale/de.txt
share/hedgewars/Data/Locale/en.txt
--- a/QTfrontend/hwform.cpp	Fri Oct 05 04:57:03 2018 +0200
+++ b/QTfrontend/hwform.cpp	Fri Oct 05 13:37:49 2018 +0200
@@ -1680,7 +1680,7 @@
     }
     if (pnetserver)
         return; // we have server - let it care of all things
-    if (hwnet && (reason != "bye") && (!reason.startsWith("User quit: ")))
+    if (hwnet && (reason != "bye"))
     {
         QString errorStr = QMessageBox::tr("The connection to the server is lost.") + (reason.isEmpty()?"":("\n\n" + HWNewNet::tr("Reason:") + "\n" + reason));
         MessageDialog::ShowErrorMessage(errorStr, this);
--- a/QTfrontend/net/newnetclient.cpp	Fri Oct 05 04:57:03 2018 +0200
+++ b/QTfrontend/net/newnetclient.cpp	Fri Oct 05 13:37:49 2018 +0200
@@ -75,7 +75,7 @@
     if (m_game_connected)
     {
         RawSendNet(QString("QUIT%1").arg(delimiter));
-        emit disconnected(tr("User quit"));
+        emit disconnected("");
     }
     NetSocket.flush();
 }
@@ -892,18 +892,7 @@
             else
             {
                 QString leaveMsg = QString(lst[2]);
-                if (leaveMsg.startsWith("User quit: "))
-                {
-                    leaveMsg.remove(0, 11);
-                    emit chatStringFromNet(tr("%1 *** %2 has left (message: \"%3\")").arg('\x03').arg(lst[1]).arg(leaveMsg));
-                }
-                else if (leaveMsg.startsWith("part: "))
-                {
-                    leaveMsg.remove(0, 6);
-                    emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1]).arg(leaveMsg));
-                }
-                else
-                    emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1]).arg(HWApplication::translate("server", leaveMsg.toLatin1().constData())));
+                emit chatStringFromNet(tr("%1 *** %2 has left (%3)").arg('\x03').arg(lst[1]).arg(HWApplication::translate("server", leaveMsg.toLatin1().constData())));
             }
             m_playersModel->playerLeftRoom(lst[1]);
             return;
--- a/QTfrontend/ui/widget/chatwidget.cpp	Fri Oct 05 04:57:03 2018 +0200
+++ b/QTfrontend/ui/widget/chatwidget.cpp	Fri Oct 05 13:37:49 2018 +0200
@@ -541,20 +541,8 @@
 
     // Normal quit
     if (message.isEmpty() || message == "bye")
+    {
         printChatString(nick, QString("*** ") + tr("%1 has left").arg(linkedNick(nick)), "Leave", false);
-    // Quit with custom player message
-    else if (message.startsWith("User quit: ") && message.length() > 11)
-    {
-        QString playerMessage = QString(message);
-        playerMessage.remove(0, 11);
-        printChatString(nick, QString("*** ") + tr("%1 has left (message: \"%2\")").arg(linkedNick(nick)).arg(playerMessage.toHtmlEscaped()), "Leave", false);
-    }
-    // Quit with special PART message
-    else if (message.startsWith("part: ") && message.length() > 6)
-    {
-        QString playerMessage = QString(message);
-        playerMessage.remove(0, 6);
-        printChatString(nick, QString("*** ") + tr("%1 has left (%2)").arg(linkedNick(nick).arg(playerMessage.toHtmlEscaped())), "Leave", false);
     }
     // Quit with additional server message (i.e. ping timeout)
     else
--- a/gameServer/HWProtoCore.hs	Fri Oct 05 04:57:03 2018 +0200
+++ b/gameServer/HWProtoCore.hs	Fri Oct 05 13:37:49 2018 +0200
@@ -41,10 +41,9 @@
 
 handleCmd ("QUIT" : xs) = return [ByeClient msg]
     where
-        -- "User quit: " is a special string parsed by frontend, do not localize.
-        -- It denotes when the /quit command has been used with message parameter.
-        -- "bye" is also a special string.
-        msg = if not $ null xs then "User quit: " `B.append` (head xs) else "bye"
+        -- "bye" is a special string (do not translate!) when the user quits manually,
+        -- otherwise there will be an additional server message
+        msg = if not $ null xs then (head xs) else "bye"
 
 
 handleCmd ["PONG"] = do
@@ -110,8 +109,7 @@
         h "RESTART_SERVER" "YES" = handleCmd_lobbyOnly ["RESTART_SERVER"]
 
         -- room and lobby commands
-        h "QUIT" m | not $ B.null m = handleCmd ["QUIT", m]
-                   | otherwise = handleCmd ["QUIT"]
+        h "QUIT" _ = handleCmd ["QUIT"]
         h "RND" p = handleCmd ("RND" : B.words p)
         h "GLOBAL" p = serverAdminOnly $ do
             rnc <- liftM snd ask
--- a/gameServer/HWProtoInRoomState.hs	Fri Oct 05 04:57:03 2018 +0200
+++ b/gameServer/HWProtoInRoomState.hs	Fri Oct 05 13:37:49 2018 +0200
@@ -76,9 +76,7 @@
 
 -- Leave room normally
 handleCmd_inRoom ["PART"] = return [MoveToLobby ""]
--- Leave room with custom quit message by player
--- "part: " is a special marker string to be detected by the frontend. Not translated for obvious reasons
-handleCmd_inRoom ["PART", msg] = return [MoveToLobby $ "part: " `B.append` msg]
+handleCmd_inRoom ["PART", _] = return [MoveToLobby ""]
 
 
 handleCmd_inRoom ("CFG" : paramName : paramStrs)
--- a/share/hedgewars/Data/Locale/de.txt	Fri Oct 05 04:57:03 2018 +0200
+++ b/share/hedgewars/Data/Locale/de.txt	Fri Oct 05 13:37:49 2018 +0200
@@ -1403,7 +1403,7 @@
 06:04=/pause: Pause umschalten
 06:05=/pause: Automatisches Überspringen umschalten
 06:06=/fullscreen: Vollbild umschalten
-06:07=/quit [Nachricht]: Hedgewars verlassen, mit optionaler Nachricht
+06:07=/quit: Hedgewars verlassen
 06:08=/help: Grundlegende Client-Chatbefehle auflisten
 06:09=/help taunts: Spott-Chatbefehle auflisten
 06:10=/history: Langes Chatprotokoll umschalten
--- a/share/hedgewars/Data/Locale/en.txt	Fri Oct 05 04:57:03 2018 +0200
+++ b/share/hedgewars/Data/Locale/en.txt	Fri Oct 05 13:37:49 2018 +0200
@@ -1306,7 +1306,7 @@
 06:04=/pause: Toggle pause
 06:05=/pause: Toggle auto skip
 06:06=/fullscreen: Toggle fullscreen
-06:07=/quit [message]: Quit Hedgewars with optional message
+06:07=/quit: Quit Hedgewars
 06:08=/help: List basic client chat commands
 06:09=/help taunts: List taunt chat commands
 06:10=/history: Toggle long chat history display