QTfrontend/game.cpp
branchflibqtfrontend
changeset 8210 ad178654142a
parent 8133 2d0f56423eb3
child 8276 d4e113e745a9
equal deleted inserted replaced
8208:171da01bd04d 8210:ad178654142a
    50 {
    50 {
    51     SetGameState(gsDestroyed);
    51     SetGameState(gsDestroyed);
    52 
    52 
    53     if(m_conn)
    53     if(m_conn)
    54         flib_gameconn_destroy(m_conn);
    54         flib_gameconn_destroy(m_conn);
    55 }
       
    56 
       
    57 void HWGame::onClientDisconnect()
       
    58 {/*
       
    59     switch (gameType)
       
    60     {
       
    61         case gtDemo:
       
    62             // for video recording we need demo anyway
       
    63             emit HaveRecord(rtNeither, demo);
       
    64             break;
       
    65         case gtNet:
       
    66             emit HaveRecord(rtDemo, demo);
       
    67             break;
       
    68         default:
       
    69             if (gameState == gsInterrupted || gameState == gsHalted)
       
    70                 emit HaveRecord(rtSave, demo);
       
    71             else if (gameState == gsFinished)
       
    72                 emit HaveRecord(rtDemo, demo);
       
    73             else
       
    74                 emit HaveRecord(rtNeither, demo);
       
    75     }*/
       
    76     SetGameState(gsStopped);
       
    77 }
    55 }
    78 
    56 
    79 void HWGame::commonConfig()
    57 void HWGame::commonConfig()
    80 {
    58 {
    81     QByteArray buf;
    59     QByteArray buf;
   414 {
   392 {
   415     gameState = state;
   393     gameState = state;
   416     emit GameStateChanged(state);
   394     emit GameStateChanged(state);
   417     if (gameType == gtCampaign)
   395     if (gameType == gtCampaign)
   418     {
   396     {
   419       emit CampStateChanged(1);
   397       emit campStateChanged(1);
   420     }
   398     }
   421 }
   399 }
   422 
   400 
   423 void HWGame::abort()
   401 void HWGame::abort()
   424 {
   402 {
   450     QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0);
   428     QSettings teamfile(cfgdir->absolutePath() + "/Teams/" + campaignTeam + ".hwt", QSettings::IniFormat, 0);
   451     teamfile.setIniCodec("UTF-8");
   429     teamfile.setIniCodec("UTF-8");
   452     teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue);
   430     teamfile.setValue("Campaign " + campaign + "/" + varToWrite, varValue);
   453 }
   431 }
   454 
   432 
       
   433 
       
   434 static void HWGame::onChat(void* context, const char *msg, bool teamchat)
       
   435 {
       
   436     HWGame * game = (HWGame *) context;
       
   437 }
       
   438 
       
   439 static void HWGame::onConnect(void* context)
       
   440 {
       
   441     HWGame * game = (HWGame *) context;
       
   442 }
       
   443 
       
   444 static void HWGame::onDisconnect(void* context, int reason)
       
   445 {
       
   446     HWGame * game = (HWGame *) context;
       
   447     /*
       
   448         switch (gameType)
       
   449         {
       
   450             case gtDemo:
       
   451                 // for video recording we need demo anyway
       
   452                 emit HaveRecord(rtNeither, demo);
       
   453                 break;
       
   454             case gtNet:
       
   455                 emit HaveRecord(rtDemo, demo);
       
   456                 break;
       
   457             default:
       
   458                 if (gameState == gsInterrupted || gameState == gsHalted)
       
   459                     emit HaveRecord(rtSave, demo);
       
   460                 else if (gameState == gsFinished)
       
   461                     emit HaveRecord(rtDemo, demo);
       
   462                 else
       
   463                     emit HaveRecord(rtNeither, demo);
       
   464         }*/
       
   465      game->SetGameState(gsStopped);
       
   466 }
       
   467 
       
   468 static void HWGame::onEngineMessage(void *context, const uint8_t *em, size_t size)
       
   469 {
       
   470     HWGame * game = (HWGame *) context;
       
   471 }
       
   472 
       
   473 static void HWGame::onErrorMessage(void* context, const char *msg)
       
   474 {
       
   475     HWGame * game = (HWGame *) context;
       
   476 }
       
   477 
       
   478 static void HWGame::onGameRecorded(void *context, const uint8_t *record, size_t size, bool isSavegame)
       
   479 {
       
   480     HWGame * game = (HWGame *) context;
       
   481 }
       
   482 
   455 void HWGame::onEngineStart()
   483 void HWGame::onEngineStart()
   456 {
   484 {
       
   485     flib_gameconn_onChat(m_conn, onChat, this);
       
   486     flib_gameconn_onConnect(m_conn, onConnect, this);
       
   487     flib_gameconn_onDisconnect(m_conn, onDisconnect, this);
       
   488     flib_gameconn_onEngineMessage(m_conn, onEngineMessage, this);
       
   489     flib_gameconn_onErrorMessage(m_conn, onErrorMessage, this);
       
   490     flib_gameconn_onGameRecorded(m_conn, onGameRecorded, this);
       
   491 
   457     new FrontLibPoller((void (*)(void *))flib_gameconn_tick, m_conn, this);
   492     new FrontLibPoller((void (*)(void *))flib_gameconn_tick, m_conn, this);
   458 }
   493 }