diff --git a/source/network/NetClient.cpp b/source/network/NetClient.cpp index eb7802a371..1ce1e541be 100644 --- a/source/network/NetClient.cpp +++ b/source/network/NetClient.cpp @@ -181,11 +181,11 @@ void CNetClient::SetAndOwnSession(CNetClientSession* session) void CNetClient::DestroyConnection() { - // Send network messages from the current frame before connection is destroyed. + // Attempt to send network messages from the current frame before connection is destroyed. if (m_ClientTurnManager) { - m_ClientTurnManager->OnDestroyConnection(); // End sending of commands for scheduled turn. - Flush(); // Make sure the messages are sent. + m_ClientTurnManager->OnDestroyConnection(); + Flush(); } SAFE_DELETE(m_Session); } diff --git a/source/network/NetClientTurnManager.cpp b/source/network/NetClientTurnManager.cpp index 58bd507b1a..d94c75fc4f 100644 --- a/source/network/NetClientTurnManager.cpp +++ b/source/network/NetClientTurnManager.cpp @@ -95,7 +95,10 @@ void CNetClientTurnManager::NotifyFinishedUpdate(u32 turn) void CNetClientTurnManager::OnDestroyConnection() { - NotifyFinishedOwnCommands(m_CurrentTurn + COMMAND_DELAY); + // Attempt to flush messages before leaving. + // Notice the sending is not reliable and rarely makes it to the Server. + if (m_NetClient.GetCurrState() == NCS_INGAME) + NotifyFinishedOwnCommands(m_CurrentTurn + COMMAND_DELAY); } void CNetClientTurnManager::OnSimulationMessage(CSimulationMessage* msg)