From ac4533f7df63ef11ed367eaa1917c2b8e4f02b43 Mon Sep 17 00:00:00 2001 From: elexis Date: Mon, 30 May 2016 17:59:02 +0000 Subject: [PATCH] Network cleanup, refs #3752. Replace a TODO comment asking why something is set with a comment answering that. This was SVN commit r18268. --- source/network/NetServer.cpp | 1 + source/network/NetTurnManager.cpp | 11 +++++++---- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/source/network/NetServer.cpp b/source/network/NetServer.cpp index 2f807f780b..1c36f1b6fe 100644 --- a/source/network/NetServer.cpp +++ b/source/network/NetServer.cpp @@ -1072,6 +1072,7 @@ bool CNetServerWorker::OnInGame(void* context, CFsmEvent* event) } else if (message->GetType() == (uint)NMT_END_COMMAND_BATCH) { + // The turn-length field is ignored CEndCommandBatchMessage* endMessage = static_cast (message); server.m_ServerTurnManager->NotifyFinishedClientCommands(session->GetHostID(), endMessage->m_Turn); } diff --git a/source/network/NetTurnManager.cpp b/source/network/NetTurnManager.cpp index 9f7a4e0b60..23843b5256 100644 --- a/source/network/NetTurnManager.cpp +++ b/source/network/NetTurnManager.cpp @@ -422,10 +422,15 @@ void CNetClientTurnManager::NotifyFinishedOwnCommands(u32 turn) { NETTURN_LOG((L"NotifyFinishedOwnCommands(%d)\n", turn)); - // Send message to the server CEndCommandBatchMessage msg; - msg.m_TurnLength = DEFAULT_TURN_LENGTH_MP; // TODO: why do we send this? + msg.m_Turn = turn; + + // The turn-length field of the CEndCommandBatchMessage is currently only relevant + // when sending it from the server to the clients. + // It could be used to verify that the client simulated the correct turn length. + msg.m_TurnLength = 0; + m_NetClient.SendMessage(&msg); } @@ -607,7 +612,6 @@ void CNetServerTurnManager::CheckClientsReady() return; // wasn't ready for m_ReadyTurn+1 } - // Advance the turn ++m_ReadyTurn; NETTURN_LOG((L"CheckClientsReady: ready for turn %d\n", m_ReadyTurn)); @@ -618,7 +622,6 @@ void CNetServerTurnManager::CheckClientsReady() msg.m_Turn = m_ReadyTurn; m_NetServer.Broadcast(&msg); - // Save the turn length in case it's needed later ENSURE(m_SavedTurnLengths.size() == m_ReadyTurn); m_SavedTurnLengths.push_back(m_TurnLength); }