QTfrontend/newnetclient.cpp
changeset 395 641ed71c7c93
parent 391 e7565bb852a2
child 396 70dfd02845af
equal deleted inserted replaced
394:4c017ae1226a 395:641ed71c7c93
    77 void HWNewNet::StartGame()
    77 void HWNewNet::StartGame()
    78 {
    78 {
    79   RawSendNet(QString("START:"));
    79   RawSendNet(QString("START:"));
    80 }
    80 }
    81 
    81 
    82 void HWNewNet::SendConfigToEngine()
       
    83 {
       
    84 
       
    85 }
       
    86 
       
    87 void HWNewNet::SendNet(const QByteArray & buf)
    82 void HWNewNet::SendNet(const QByteArray & buf)
    88 {
    83 {
    89   QString msg = QString(buf.toBase64());
    84   QString msg = QString(buf.toBase64());
    90 
    85 
    91   if(msg == "AUM=") {
       
    92     SendConfigToEngine();
       
    93     return ;
       
    94   }
       
    95   //NetBuffer += buf;
    86   //NetBuffer += buf;
    96   RawSendNet(QString("GAMEMSG:%1%2").arg(delimeter).arg(msg));
    87   RawSendNet(QString("GAMEMSG:%1%2").arg(delimeter).arg(msg));
    97 }
    88 }
    98 
    89 
    99 void HWNewNet::RawSendNet(const QString & str)
    90 void HWNewNet::RawSendNet(const QString & str)
   186     ConfigAsked();
   177     ConfigAsked();
   187     return;
   178     return;
   188   }
   179   }
   189 
   180 
   190   if (lst[0] == "RUNGAME") {
   181   if (lst[0] == "RUNGAME") {
   191     HWGame* game = new HWGame(config, m_pGameCFGWidget, m_pTeamSelWidget); // FIXME: memory leak here (stackify it?)
   182   	RunGame();
   192     connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &)));
       
   193     connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
       
   194     connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &)));
       
   195     game->StartNet();
       
   196   }
   183   }
   197 
   184 
   198   if (lst[0] == "CONFIGURED") {
   185   if (lst[0] == "CONFIGURED") {
   199     lst.pop_front();
   186     lst.pop_front();
   200     if(lst.size()<5) return;
   187     if(lst.size()<5) return;
   284   onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
   271   onTurnTimeChanged(m_pGameCFGWidget->getTurnTime());
   285 }
   272 }
   286 
   273 
   287 void HWNewNet::RunGame()
   274 void HWNewNet::RunGame()
   288 {
   275 {
   289   HWGame * game = new HWGame(config, 0);
   276   HWGame* game = new HWGame(config, m_pGameCFGWidget, m_pTeamSelWidget); // FIXME: memory leak here (stackify it?)
   290   connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &)));
   277   connect(game, SIGNAL(SendNet(const QByteArray &)), this, SLOT(SendNet(const QByteArray &)));
   291   connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
   278   connect(this, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &)));
   292   connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &)));
   279   connect(this, SIGNAL(LocalCFG(const QString &)), game, SLOT(LocalCFG(const QString &)));
   293   game->StartNet();
   280   game->StartNet();
   294 }
   281 }