Ticket #2420: sendNetworkMessagesAtGameEnd_v1.patch
File sendNetworkMessagesAtGameEnd_v1.patch, 2.7 KB (added by , 10 years ago) |
---|
-
source/network/NetClient.cpp
147 147 SAFE_DELETE(m_Session); 148 148 } 149 149 150 void CNetClient::OnGameEnd() 151 { 152 // send network messages of current frame before connection get's destroyed 153 if (m_ClientTurnManager) 154 { 155 m_ClientTurnManager->OnDestroyConnection(); // end sending commands for scheduled turn 156 Flush(); // make sure the messages are send 157 } 158 } 159 150 160 void CNetClient::Poll() 151 161 { 152 162 if (m_Session) -
source/network/NetClient.h
164 164 void LoadFinished(); 165 165 166 166 void SendChatMessage(const std::wstring& text); 167 168 /** 169 * sends the commands of the current turn to the server and tells the server that there will be no more messages in this turn. 170 * should only be called once before the client disconnects 171 * (putting this in destructor is too late) 172 */ 173 void OnGameEnd(); 167 174 168 175 private: 169 176 // Net message / FSM transition handlers -
source/network/NetTurnManager.cpp
419 419 m_NetClient.SendMessage(&msg); 420 420 } 421 421 422 void CNetClientTurnManager::OnDestroyConnection() 423 { 424 NotifyFinishedOwnCommands(m_CurrentTurn + COMMAND_DELAY); 425 } 426 422 427 void CNetClientTurnManager::OnSimulationMessage(CSimulationMessage* msg) 423 428 { 424 429 // Command received from the server - store it for later execution -
source/network/NetTurnManager.h
200 200 virtual void OnSimulationMessage(CSimulationMessage* msg); 201 201 202 202 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(); 203 208 204 209 protected: 205 210 virtual void NotifyFinishedOwnCommands(u32 turn); -
source/ps/GameSetup/GameSetup.cpp
654 654 655 655 void EndGame() 656 656 { 657 // make sure that the messages last messages are sent 658 if (g_NetClient) 659 g_NetClient->OnGameEnd(); 660 657 661 SAFE_DELETE(g_NetServer); 658 662 SAFE_DELETE(g_NetClient); 659 663 SAFE_DELETE(g_Game);