QTfrontend/game.cpp
changeset 5906 ed9676dc8cb4
parent 5865 35387d27f73a
child 6015 daffc14a518a
equal deleted inserted replaced
5713:190d6bb075c5 5906:ed9676dc8cb4
    51 }
    51 }
    52 
    52 
    53 void HWGame::onClientDisconnect()
    53 void HWGame::onClientDisconnect()
    54 {
    54 {
    55     switch (gameType) {
    55     switch (gameType) {
    56         case gtDemo: break;
    56         case gtSave:
       
    57             if (gameState == gsInterrupted || gameState == gsHalted)
       
    58                 emit HaveRecord(false, demo);
       
    59             else if (gameState == gsFinished)
       
    60                  emit HaveRecord(true, demo);
       
    61             break;
       
    62         case gtDemo:
       
    63             break;
    57         case gtNet:
    64         case gtNet:
    58             emit HaveRecord(true, demo);
    65             emit HaveRecord(true, demo);
    59             break;
    66             break;
    60         default:
    67         default:
    61             if (gameState == gsInterrupted || gameState == gsHalted) emit HaveRecord(false, demo);
    68             if (gameState == gsInterrupted || gameState == gsHalted) emit HaveRecord(false, demo);
    82 
    89 
    83     buf += gamecfg->getFullConfig();
    90     buf += gamecfg->getFullConfig();
    84 
    91 
    85     if (m_pTeamSelWidget)
    92     if (m_pTeamSelWidget)
    86     {
    93     {
    87         QListIterator<HWTeam> it(m_pTeamSelWidget->getPlayingTeams());
    94         foreach(HWTeam team, m_pTeamSelWidget->getPlayingTeams())
    88         while(it.hasNext())
       
    89         {
    95         {
    90             HWProto::addStringToBuffer(buf, QString("eammloadt %1").arg(ammostr.mid(0, cAmmoNumber)));
    96             HWProto::addStringToBuffer(buf, QString("eammloadt %1").arg(ammostr.mid(0, cAmmoNumber)));
    91             HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber)));
    97             HWProto::addStringToBuffer(buf, QString("eammprob %1").arg(ammostr.mid(cAmmoNumber, cAmmoNumber)));
    92             HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber)));
    98             HWProto::addStringToBuffer(buf, QString("eammdelay %1").arg(ammostr.mid(2 * cAmmoNumber, cAmmoNumber)));
    93             HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
    99             HWProto::addStringToBuffer(buf, QString("eammreinf %1").arg(ammostr.mid(3 * cAmmoNumber, cAmmoNumber)));
    94             if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
   100             if(!gamecfg->schemeData(21).toBool()) HWProto::addStringToBuffer(buf, QString("eammstore"));
    95             HWProto::addStringListToBuffer(buf,
   101             HWProto::addStringListToBuffer(buf,
    96                 it.next().TeamGameConfig(gamecfg->getInitHealth()));
   102                 team.TeamGameConfig(gamecfg->getInitHealth()));
    97             ;
   103             ;
    98         }
   104         }
    99     }
   105     }
   100     RawSendIPC(buf);
   106     RawSendIPC(buf);
   101 }
   107 }
   185                 }
   191                 }
   186                 case gtQLocal: {
   192                 case gtQLocal: {
   187                     SendQuickConfig();
   193                     SendQuickConfig();
   188                     break;
   194                     break;
   189                 }
   195                 }
       
   196                 case gtSave:
   190                 case gtDemo: break;
   197                 case gtDemo: break;
   191                 case gtNet: {
   198                 case gtNet: {
   192                     SendNetConfig();
   199                     SendNetConfig();
   193                     break;
   200                     break;
   194                 }
   201                 }
   318     if (TeamCount == 5) return;
   325     if (TeamCount == 5) return;
   319     teams[TeamCount] = teamname;
   326     teams[TeamCount] = teamname;
   320     TeamCount++;
   327     TeamCount++;
   321 }
   328 }
   322 
   329 
   323 void HWGame::PlayDemo(const QString & demofilename)
   330 void HWGame::PlayDemo(const QString & demofilename, bool isSave)
   324 {
   331 {
   325     gameType = gtDemo;
   332     gameType = isSave ? gtSave : gtDemo;
   326     QFile demofile(demofilename);
   333     QFile demofile(demofilename);
   327     if (!demofile.open(QIODevice::ReadOnly))
   334     if (!demofile.open(QIODevice::ReadOnly))
   328     {
   335     {
   329         emit ErrorMessage(tr("Cannot open demofile %1").arg(demofilename));
   336         emit ErrorMessage(tr("Cannot open demofile %1").arg(demofilename));
   330         return ;
   337         return ;
   390 void HWGame::KillAllTeams()
   397 void HWGame::KillAllTeams()
   391 {
   398 {
   392     if (m_pTeamSelWidget)
   399     if (m_pTeamSelWidget)
   393     {
   400     {
   394         QByteArray buf;
   401         QByteArray buf;
   395         QListIterator<HWTeam> it(m_pTeamSelWidget->getPlayingTeams());
   402         foreach(HWTeam team, m_pTeamSelWidget->getPlayingTeams())
   396         while(it.hasNext())
   403             HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(team.TeamName));
   397             HWProto::addStringToBuffer(buf, QString("eteamgone %1").arg(it.next().TeamName));
       
   398         RawSendIPC(buf);
   404         RawSendIPC(buf);
   399     }
   405     }
   400 }
   406 }