QTfrontend/net/newnetclient.cpp
branchwebgl
changeset 8444 75db7bb8dce8
parent 8330 aaefa587e277
parent 8436 b89aacebb9db
child 8833 c13ebed437cb
--- a/QTfrontend/net/newnetclient.cpp	Wed Jan 02 11:11:49 2013 +0100
+++ b/QTfrontend/net/newnetclient.cpp	Sun Jan 27 00:28:57 2013 +0100
@@ -28,6 +28,8 @@
 #include "game.h"
 #include "roomslistmodel.h"
 #include "playerslistmodel.h"
+#include "servermessages.h"
+#include "HWApplication.h"
 
 char delimeter='\n';
 
@@ -251,7 +253,7 @@
     if (lst[0] == "ERROR")
     {
         if (lst.size() == 2)
-            emit Error(lst[1]);
+            emit Error(HWApplication::translate("server", lst[1].toAscii().constData()));
         else
             emit Error("Unknown error");
         return;
@@ -260,7 +262,7 @@
     if (lst[0] == "WARNING")
     {
         if (lst.size() == 2)
-            emit Warning(lst[1]);
+            emit Warning(HWApplication::translate("server", lst[1].toAscii().constData()));
         else
             emit Warning("Unknown warning");
         return;
@@ -579,14 +581,14 @@
         if (lst[1] == "Authentication failed")
         {
             emit AuthFailed();
-        m_game_connected = false;
-        Disconnect();
-        //omitted 'emit disconnected()', we don't want the error message
-        return;
+            m_game_connected = false;
+            Disconnect();
+            //omitted 'emit disconnected()', we don't want the error message
+            return;
         }
         m_game_connected = false;
         Disconnect();
-        emit disconnected(lst[1]);
+        emit disconnected(HWApplication::translate("server", lst[1].toAscii().constData()));
         return;
     }
 
@@ -926,6 +928,20 @@
     }
 }
 
+void HWNewNet::consoleCommand(const QString & cmd)
+{
+    RawSendNet(QString("CMD%1%2").arg(delimeter).arg(cmd));
+}
+
+bool HWNewNet::allPlayersReady()
+{
+    int ready = 0;
+    for (int i = 0; i < m_roomPlayersModel->rowCount(); i++)
+        if (m_roomPlayersModel->index(i, 0).data(PlayersListModel::Ready).toBool()) ready++;
+
+    return (ready == m_roomPlayersModel->rowCount());
+}
+
 void HWNewNet::startGame()
 {
     RawSendNet(QString("START_GAME"));