It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server.
authordag10
Mon, 21 Jan 2013 02:21:04 -0500
changeset 8416 e691acd778f5
parent 8415 02acf6b92f52
child 8417 790492abc004
It is now possible to start a game even if not all players are "ready"; a confirmation prompt is shown. This commit updates the server. Unless the official server is updated, this commit will do nothing new.
QTfrontend/hwform.cpp
QTfrontend/hwform.h
QTfrontend/net/newnetclient.cpp
QTfrontend/net/newnetclient.h
gameServer/HWProtoInRoomState.hs
--- a/QTfrontend/hwform.cpp	Mon Jan 21 00:30:18 2013 -0500
+++ b/QTfrontend/hwform.cpp	Mon Jan 21 02:21:04 2013 -0500
@@ -1732,7 +1732,7 @@
     if (hwnet)
     {
         // disconnect connections first to ensure their inexistance and not to connect twice
-        ui.pageNetGame->BtnStart->disconnect(hwnet);
+        ui.pageNetGame->BtnStart->disconnect(this);
         ui.pageNetGame->BtnUpdate->disconnect(hwnet);
         ui.pageNetGame->leRoomName->disconnect(hwnet);
         ui.pageNetGame->restrictJoins->disconnect(hwnet);
@@ -1741,7 +1741,7 @@
 
         ui.pageNetGame->setRoomName(hwnet->getRoom());
 
-        connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame()));
+        connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), this, SLOT(startGame()));
         connect(ui.pageNetGame, SIGNAL(askForUpdateRoomName(const QString &)), hwnet, SLOT(updateRoomName(const QString &)));
         connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins()));
         connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds()));
@@ -1971,3 +1971,17 @@
     FeedbackDialog dialog(this);
     dialog.exec();
 }
+
+void HWForm::startGame()
+{
+    QMessageBox questionMsg(this);
+    questionMsg.setIcon(QMessageBox::Question);
+    questionMsg.setWindowTitle(QMessageBox::tr("Not all players are ready"));
+    questionMsg.setText(QMessageBox::tr("Are you sure you want to start this game?\nNot all players are ready."));
+    questionMsg.setWindowModality(Qt::WindowModal);
+    questionMsg.addButton(QMessageBox::Yes);
+    questionMsg.addButton(QMessageBox::Cancel);
+
+    if (hwnet->allPlayersReady() || questionMsg.exec() == QMessageBox::Yes)
+        hwnet->startGame();
+}
--- a/QTfrontend/hwform.h	Mon Jan 21 00:30:18 2013 -0500
+++ b/QTfrontend/hwform.h	Mon Jan 21 02:21:04 2013 -0500
@@ -139,6 +139,8 @@
         void saveDemoWithCustomName();
         void openRegistrationPage();
 
+        void startGame();
+
     private:
         void _NetConnect(const QString & hostName, quint16 port, QString nick);
         void UpdateTeamsLists();
--- a/QTfrontend/net/newnetclient.cpp	Mon Jan 21 00:30:18 2013 -0500
+++ b/QTfrontend/net/newnetclient.cpp	Mon Jan 21 02:21:04 2013 -0500
@@ -933,6 +933,15 @@
     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"));
@@ -1016,4 +1025,4 @@
 QAbstractItemModel *HWNewNet::roomPlayersModel()
 {
     return m_roomPlayersModel;
-}
+}
\ No newline at end of file
--- a/QTfrontend/net/newnetclient.h	Mon Jan 21 00:30:18 2013 -0500
+++ b/QTfrontend/net/newnetclient.h	Mon Jan 21 02:21:04 2013 -0500
@@ -60,6 +60,7 @@
         RoomsListModel * roomsListModel();
         QAbstractItemModel * lobbyPlayersModel();
         QAbstractItemModel * roomPlayersModel();
+        bool allPlayersReady();
 
     private:
         bool isChief;
--- a/gameServer/HWProtoInRoomState.hs	Mon Jan 21 00:30:18 2013 -0500
+++ b/gameServer/HWProtoInRoomState.hs	Mon Jan 21 02:21:04 2013 -0500
@@ -185,7 +185,7 @@
     let nicks = map (nick . client rnc) . roomClients rnc $ clientRoom rnc ci
     let allPlayersRegistered = all ((<) 0 . B.length . webPassword . client rnc . teamownerId) $ teams rm
 
-    if isMaster cl && playersIn rm == readyPlayers rm && not (isJust $ gameInfo rm) then
+    if isMaster cl && not (isJust $ gameInfo rm) then
         if enoughClans rm then
             return [
                 ModifyRoom