--- a/QTfrontend/net/newnetclient.cpp Fri Oct 11 17:43:13 2013 +0200
+++ b/QTfrontend/net/newnetclient.cpp Sat Jan 04 23:55:54 2014 +0400
@@ -94,7 +94,7 @@
NetSocket.disconnectFromHost();
}
-void HWNewNet::CreateRoom(const QString & room)
+void HWNewNet::CreateRoom(const QString & room, const QString & password)
{
if(netClientState != InLobby)
{
@@ -104,11 +104,15 @@
myroom = room;
- RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room));
+ if(password.isEmpty())
+ RawSendNet(QString("CREATE_ROOM%1%2").arg(delimeter).arg(room));
+ else
+ RawSendNet(QString("CREATE_ROOM%1%2%1%3").arg(delimeter).arg(room).arg(password));
+
isChief = true;
}
-void HWNewNet::JoinRoom(const QString & room)
+void HWNewNet::JoinRoom(const QString & room, const QString &password)
{
if(netClientState != InLobby)
{
@@ -118,7 +122,11 @@
myroom = room;
- RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room));
+ if(password.isEmpty())
+ RawSendNet(QString("JOIN_ROOM%1%2").arg(delimeter).arg(room));
+ else
+ RawSendNet(QString("JOIN_ROOM%1%2%1%3").arg(delimeter).arg(room).arg(password));
+
isChief = false;
}
@@ -303,14 +311,12 @@
if (lst[0] == "ROOMS")
{
- if(lst.size() % 8 != 1)
+ if(lst.size() % 9 != 1)
{
qWarning("Net: Malformed ROOMS message");
return;
}
- QStringList tmp = lst;
- tmp.removeFirst();
- m_roomsListModel->setRoomsList(tmp);
+ m_roomsListModel->setRoomsList(lst.mid(1));
if (m_private_game == false && m_nick_registered == false)
{
emit NickNotRegistered(mynick);
@@ -398,7 +404,7 @@
return;
}
- if (lst[0] == "CLIENT_FLAGS")
+ if (lst[0] == "CLIENT_FLAGS" || lst[0] == "CF")
{
if(lst.size() < 3 || lst[1].size() < 2)
{
@@ -519,7 +525,7 @@
return;
}
- if(lst[0] == "ROOM" && lst.size() == 10 && lst[1] == "ADD")
+ if(lst[0] == "ROOM" && lst.size() == 11 && lst[1] == "ADD")
{
QStringList tmp = lst;
tmp.removeFirst();
@@ -529,7 +535,7 @@
return;
}
- if(lst[0] == "ROOM" && lst.size() == 11 && lst[1] == "UPD")
+ if(lst[0] == "ROOM" && lst.size() == 12 && lst[1] == "UPD")
{
QStringList tmp = lst;
tmp.removeFirst();
@@ -539,7 +545,7 @@
m_roomsListModel->updateRoom(roomName, tmp);
// keep track of room name so correct name is displayed
- if(myroom == roomName)
+ if(myroom == roomName && myroom != tmp[1])
{
myroom = tmp[1];
emit roomNameUpdated(myroom);
@@ -619,15 +625,9 @@
return;
}
- if (lst[0] == "ADMIN_ACCESS")
- {
- // obsolete, see +a client flag
- return;
- }
-
if(lst[0] == "JOINING")
{
- if(lst.size() < 2)
+ if(lst.size() != 2)
{
qWarning("Net: Bad JOINING message");
return;
@@ -635,6 +635,7 @@
myroom = lst[1];
emit roomNameUpdated(myroom);
+ return;
}
if(netClientState == InLobby && lst[0] == "JOINED")
@@ -810,17 +811,6 @@
m_playersModel->playerLeftRoom(lst[1]);
return;
}
-
- // obsolete
- if (lst[0] == "ROOM_CONTROL_ACCESS")
- {
- if (lst.size() < 2)
- {
- qWarning("Net: Bad ROOM_CONTROL_ACCESS message");
- return;
- }
- return;
- }
}
qWarning() << "Net: Unknown message or wrong state:" << lst;
@@ -1065,10 +1055,11 @@
switch(n)
{
case 0:
- {
emit NickTaken(mynick);
break;
- }
+ case 2:
+ emit askForRoomPassword();
+ break;
}
}
@@ -1086,3 +1077,9 @@
{
return m_roomPlayersModel;
}
+
+void HWNewNet::roomPasswordEntered(const QString &password)
+{
+ if(!myroom.isEmpty())
+ JoinRoom(myroom, password);
+}