QTfrontend/hwform.cpp
changeset 4428 2bc3d3475edf
parent 4416 29d2d1548387
child 4429 f9a949ef955b
equal deleted inserted replaced
4427:c5193713055f 4428:2bc3d3475edf
   507     else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby
   507     else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby
   508         ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text());
   508         ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text());
   509 
   509 
   510     if(id == ID_PAGE_NETGAME) // joining a room
   510     if(id == ID_PAGE_NETGAME) // joining a room
   511         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
   511         ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text());
   512     else if(id == ID_PAGE_ROOMSLIST) // joining the lobby
   512 // joining the lobby 
       
   513     else if(id == ID_PAGE_ROOMSLIST) {
       
   514         if ( game && game->gameState == gsStarted) { // abnormal exit - kick or room destruction - send kills.
       
   515             game->KillAllTeams();
       
   516         }
   513         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
   517         ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text());
       
   518     }
   514 }
   519 }
   515 
   520 
   516 void HWForm::GoToPage(quint8 id)
   521 void HWForm::GoToPage(quint8 id)
   517 {
   522 {
   518     quint8 lastid = ui.Pages->currentIndex();
   523     quint8 lastid = ui.Pages->currentIndex();
   934 {
   939 {
   935     switch(gameState) {
   940     switch(gameState) {
   936         case gsStarted: {
   941         case gsStarted: {
   937             Music(false);
   942             Music(false);
   938             if (wBackground) wBackground->stopAnimation();
   943             if (wBackground) wBackground->stopAnimation();
   939             GoToPage(ID_PAGE_INGAME);
   944             if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoToPage(ID_PAGE_INGAME);
   940             ui.pageGameStats->clear();
   945             ui.pageGameStats->clear();
   941             if (pRegisterServer)
   946             if (pRegisterServer)
   942             {
   947             {
   943                 pRegisterServer->unregister();
   948                 pRegisterServer->unregister();
   944                 pRegisterServer = 0;
   949                 pRegisterServer = 0;
   948             break;
   953             break;
   949         }
   954         }
   950         case gsFinished: {
   955         case gsFinished: {
   951             //setVisible(true);
   956             //setVisible(true);
   952             setFocusPolicy(Qt::StrongFocus);
   957             setFocusPolicy(Qt::StrongFocus);
   953             GoBack();
   958             if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoBack();
   954             Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   959             Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   955             if (wBackground) wBackground->startAnimation();
   960             if (wBackground) wBackground->startAnimation();
   956             GoToPage(ID_PAGE_GAMESTATS);
   961             GoToPage(ID_PAGE_GAMESTATS);
   957             if (hwnet) hwnet->gameFinished();
   962             if (hwnet) hwnet->gameFinished();
   958             break;
   963             break;
   959         }
   964         }
   960         default: {
   965         default: {
   961             //setVisible(true);
   966             //setVisible(true);
   962             setFocusPolicy(Qt::StrongFocus);
   967             setFocusPolicy(Qt::StrongFocus);
   963             quint8 id = ui.Pages->currentIndex();
   968             quint8 id = ui.Pages->currentIndex();
   964             if (id == ID_PAGE_INGAME) {
   969             if (id == ID_PAGE_INGAME ||
   965                 GoBack();
   970 // was room chief and the game was aborted
       
   971                 (hwnet && hwnet->isRoomChief() && hwnet->isInRoom() && 
       
   972                     (gameState == gsInterrupted || gameState == gsStopped || gameState == gsDestroyed))) {
       
   973                 if (!hwnet || (!hwnet->isRoomChief() || !hwnet->isInRoom())) GoBack();
   966                 Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   974                 Music(ui.pageOptions->CBEnableFrontendMusic->isChecked());
   967                 if (wBackground) wBackground->startAnimation();
   975                 if (wBackground) wBackground->startAnimation();
   968                 if (hwnet) hwnet->gameFinished();
   976                 if (hwnet) hwnet->gameFinished();
   969             }
   977             }
   970         };
   978         };