Ticket #2420: sendNetworkMessagesAtGameEnd_v2.patch

File sendNetworkMessagesAtGameEnd_v2.patch, 2.0 KB (added by Michael, 10 years ago)

Moved some function calls to destructor. (Thx to Josh)

  • source/network/NetClient.cpp

     
    144144
    145145void CNetClient::DestroyConnection()
    146146{
     147    // send network messages of current frame before connection get's destroyed
     148    if (m_ClientTurnManager)
     149    {
     150        m_ClientTurnManager->OnDestroyConnection(); // end sending commands for scheduled turn
     151        Flush(); // make sure the messages are send
     152    }
    147153    SAFE_DELETE(m_Session);
    148154}
    149155
  • source/network/NetTurnManager.cpp

     
    419419    m_NetClient.SendMessage(&msg);
    420420}
    421421
     422void CNetClientTurnManager::OnDestroyConnection()
     423{
     424    NotifyFinishedOwnCommands(m_CurrentTurn + COMMAND_DELAY);
     425}
     426
    422427void CNetClientTurnManager::OnSimulationMessage(CSimulationMessage* msg)
    423428{
    424429    // Command received from the server - store it for later execution
  • source/network/NetTurnManager.h

     
    200200    virtual void OnSimulationMessage(CSimulationMessage* msg);
    201201
    202202    virtual void PostCommand(CScriptValRooted data);
     203   
     204    /**
     205     * notifiy the server that all commands for the scheduled turn are send before the connection is destroyed
     206     */
     207    void OnDestroyConnection();
    203208
    204209protected:
    205210    virtual void NotifyFinishedOwnCommands(u32 turn);
  • source/ps/GameSetup/GameSetup.cpp

     
    654654
    655655void EndGame()
    656656{
     657    SAFE_DELETE(g_NetClient);
    657658    SAFE_DELETE(g_NetServer);
    658     SAFE_DELETE(g_NetClient);
    659659    SAFE_DELETE(g_Game);
    660660
    661661    ISoundManager::CloseGame();