Try to kill off all teams if the player returns to the lobby in mid-game. Also leave game room open for admins to kick/restrict joins etc. NEEDS TESTING PROBABLY BROKE SOMETHING OR OTHER
authornemo
Sun, 28 Nov 2010 12:55:57 -0500
changeset 4428 2bc3d3475edf
parent 4427 c5193713055f
child 4429 f9a949ef955b
Try to kill off all teams if the player returns to the lobby in mid-game. Also leave game room open for admins to kick/restrict joins etc. NEEDS TESTING PROBABLY BROKE SOMETHING OR OTHER
QTfrontend/game.cpp
QTfrontend/game.h
QTfrontend/hwform.cpp
--- a/QTfrontend/game.cpp	Sun Nov 28 19:03:28 2010 +0300
+++ b/QTfrontend/game.cpp	Sun Nov 28 12:55:57 2010 -0500
@@ -377,3 +377,15 @@
     gameState = state;
     emit GameStateChanged(state);
 }
+
+void HWGame::KillAllTeams()
+{
+    if (m_pTeamSelWidget)
+    {
+        QByteArray buf;
+        QList<HWTeam> teams = m_pTeamSelWidget->getPlayingTeams();
+        for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it)
+            HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg((*it).TeamName));
+        RawSendIPC(buf);
+    }
+}
--- a/QTfrontend/game.h	Sun Nov 28 19:03:28 2010 +0300
+++ b/QTfrontend/game.h	Sun Nov 28 12:55:57 2010 -0500
@@ -53,6 +53,8 @@
     void StartNet();
     void StartTraining(const QString & file);
     void StartCampaign(const QString & file);
+    void KillAllTeams();
+    GameState gameState;
 
  protected:
     virtual QStringList setArguments();
@@ -89,7 +91,6 @@
     GameCFGWidget * gamecfg;
     TeamSelWidget* m_pTeamSelWidget;
     GameType gameType;
-    GameState gameState;
 
     void commonConfig();
     void SendConfig();
--- a/QTfrontend/hwform.cpp	Sun Nov 28 19:03:28 2010 +0300
+++ b/QTfrontend/hwform.cpp	Sun Nov 28 12:55:57 2010 -0500
@@ -509,8 +509,13 @@
 
     if(id == ID_PAGE_NETGAME) // joining a room
         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
-    else if(id == ID_PAGE_ROOMSLIST) // joining the lobby
+// joining the lobby 
+    else if(id == ID_PAGE_ROOMSLIST) {
+        if ( game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
+            game->KillAllTeams();
+        }
         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
+    }
 }
 
 void HWForm::GoToPage(quint8 id)
@@ -936,7 +941,7 @@
         case gsStarted: {
             Music(false);
             if (wBackground) wBackground->stopAnimation();
-            GoToPage(ID_PAGE_INGAME);
+            if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoToPage(ID_PAGE_INGAME);
             ui.pageGameStats->clear();
             if (pRegisterServer)
             {
@@ -950,7 +955,7 @@
         case gsFinished: {
             //setVisible(true);
             setFocusPolicy(Qt::StrongFocus);
-            GoBack();
+            if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoBack();
             Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
             if (wBackground) wBackground->startAnimation();
             GoToPage(ID_PAGE_GAMESTATS);
@@ -961,8 +966,11 @@
             //setVisible(true);
             setFocusPolicy(Qt::StrongFocus);
             quint8 id = ui.Pages->currentIndex();
-            if (id == ID_PAGE_INGAME) {
-                GoBack();
+            if (id == ID_PAGE_INGAME ||
+// was room chief and the game was aborted
+                (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && 
+                    (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed))) {
+                if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoBack();
                 Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
                 if (wBackground) wBackground->startAnimation();
                 if (hwnet) hwnet->gameFinished();