1
0
forked from 0ad/0ad

Fix network FSM errors when a client closes the game during the loading screen or rejoin synchronization stage, fixes #4594, refs 3199.

Fix comments claiming to ensure reliability when in reality there is
only a small likelihood of the message being received.

Broken by fa85527baf / refs #2420 which was a preparation for a3e1c68b9a
/ refs #2373, which hence didn't actually work and was circumvented by
9b136a45fc without clarification.
Might have caused #3643.
Differential Revision: https://code.wildfiregames.com/D1557
Reviewed By: Imarok
This was SVN commit r21837.
This commit is contained in:
elexis 2018-06-05 14:52:41 +00:00
parent ee9cf54149
commit 43730f15f3
2 changed files with 7 additions and 4 deletions

View File

@ -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);
}

View File

@ -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)