QTfrontend/net/newnetclient.cpp
changeset 6733 5abbc345a82f
parent 6732 c906dc78091f
child 6735 050237b1500f
--- a/QTfrontend/net/newnetclient.cpp	Thu Feb 23 00:46:03 2012 +0400
+++ b/QTfrontend/net/newnetclient.cpp	Thu Feb 23 18:41:52 2012 +0400
@@ -257,7 +257,7 @@
         }
 
         RawSendNet(QString("NICK%1%2").arg(delimeter).arg(mynick));
-        RawSendNet(QString("PROTO%1%2").arg(delimeter).arg(*cProtoVer));
+        RawSendNet(QString("PROTO%1%2").arg(delimeter).arg("41"));
         netClientState = Connected;
         m_game_connected = true;
         emit adminAccess(false);
@@ -275,9 +275,14 @@
 
     if (lst[0] == "ROOMS")
     {
+        if(lst.size() % 8 != 1)
+        {
+            qWarning("Net: Malformed ROOMS message");
+            return;
+        }
         QStringList tmp = lst;
         tmp.removeFirst();
-        emit roomsList(tmp);
+        m_roomsListModel->setRoomsList(tmp);
         return;
     }
 
@@ -478,14 +483,30 @@
         return;
     }
 
-    if(lst[0] == "ROOM")
+    if(lst[0] == "ROOM" && lst.size() == 10 && lst[1] == "ADD")
+    {
+        QStringList tmp = lst;
+        tmp.removeFirst();
+        tmp.removeFirst();
+
+        m_roomsListModel->addRoom(tmp);
+        return;
+    }
+
+    if(lst[0] == "ROOM" && lst.size() == 11 && lst[1] == "UPD")
     {
-        if(lst.size() < 2)
-        {
-            qWarning("Net: Bad ROOM message");
-            return;
-        }
-        RawSendNet(QString("LIST"));
+        QStringList tmp = lst;
+        tmp.removeFirst();
+        tmp.removeFirst();
+
+        QString roomName = tmp.takeFirst();
+        m_roomsListModel->updateRoom(roomName, tmp);
+        return;
+    }
+
+    if(lst[0] == "ROOM" && lst.size() == 3 && lst[1] == "DEL")
+    {
+        m_roomsListModel->removeRoom(lst[2]);
         return;
     }