mirror of
https://gitea.wildfiregames.com/0ad/0ad
synced 2026-06-16 05:13:58 -07:00
Send messages in queue before closing connection, patch by boeseRaupe. Fixes #2420
This was SVN commit r14732.
This commit is contained in:
parent
035078c317
commit
fa85527baf
4 changed files with 17 additions and 1 deletions
|
|
@ -144,6 +144,12 @@ void CNetClient::SetAndOwnSession(CNetClientSession* session)
|
|||
|
||||
void CNetClient::DestroyConnection()
|
||||
{
|
||||
// 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.
|
||||
}
|
||||
SAFE_DELETE(m_Session);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -419,6 +419,11 @@ void CNetClientTurnManager::NotifyFinishedUpdate(u32 turn)
|
|||
m_NetClient.SendMessage(&msg);
|
||||
}
|
||||
|
||||
void CNetClientTurnManager::OnDestroyConnection()
|
||||
{
|
||||
NotifyFinishedOwnCommands(m_CurrentTurn + COMMAND_DELAY);
|
||||
}
|
||||
|
||||
void CNetClientTurnManager::OnSimulationMessage(CSimulationMessage* msg)
|
||||
{
|
||||
// Command received from the server - store it for later execution
|
||||
|
|
|
|||
|
|
@ -200,6 +200,11 @@ public:
|
|||
virtual void OnSimulationMessage(CSimulationMessage* msg);
|
||||
|
||||
virtual void PostCommand(CScriptValRooted data);
|
||||
|
||||
/**
|
||||
* Notifiy the server that all commands are sent to prepare the connection for termination.
|
||||
*/
|
||||
void OnDestroyConnection();
|
||||
|
||||
protected:
|
||||
virtual void NotifyFinishedOwnCommands(u32 turn);
|
||||
|
|
|
|||
|
|
@ -654,8 +654,8 @@ static void ShutdownSDL()
|
|||
|
||||
void EndGame()
|
||||
{
|
||||
SAFE_DELETE(g_NetServer);
|
||||
SAFE_DELETE(g_NetClient);
|
||||
SAFE_DELETE(g_NetServer);
|
||||
SAFE_DELETE(g_Game);
|
||||
|
||||
ISoundManager::CloseGame();
|
||||
|
|
|
|||
Loading…
Reference in a new issue