Changeset View
Changeset View
Standalone View
Standalone View
source/network/NetServerTurnManager.cpp
Show All 11 Lines | |||||
* GNU General Public License for more details. | * GNU General Public License for more details. | ||||
* | * | ||||
* You should have received a copy of the GNU General Public License | * You should have received a copy of the GNU General Public License | ||||
* along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>. | ||||
*/ | */ | ||||
#include "precompiled.h" | #include "precompiled.h" | ||||
#include "NetMessage.h" | |||||
#include "NetServerTurnManager.h" | #include "NetServerTurnManager.h" | ||||
#include "NetServer.h" | #include "NetServer.h" | ||||
#include "simulation2/system/TurnManager.h" | #include "simulation2/system/TurnManager.h" | ||||
#if 0 | #if 0 | ||||
#define NETSERVERTURN_LOG(...) debug_printf(__VA_ARGS__) | #define NETSERVERTURN_LOG(...) debug_printf(__VA_ARGS__) | ||||
#else | #else | ||||
Show All 37 Lines | void CNetServerTurnManager::CheckClientsReady() | ||||
++m_ReadyTurn; | ++m_ReadyTurn; | ||||
NETSERVERTURN_LOG("CheckClientsReady: ready for turn %d\n", m_ReadyTurn); | NETSERVERTURN_LOG("CheckClientsReady: ready for turn %d\n", m_ReadyTurn); | ||||
// Tell all clients that the next turn is ready | // Tell all clients that the next turn is ready | ||||
CEndCommandBatchMessage msg; | CEndCommandBatchMessage msg; | ||||
msg.m_TurnLength = m_TurnLength; | msg.m_TurnLength = m_TurnLength; | ||||
msg.m_Turn = m_ReadyTurn; | msg.m_Turn = m_ReadyTurn; | ||||
m_NetServer.Broadcast(&msg, { NSS_INGAME }); | m_NetServer.Broadcast(msg, { NSS_INGAME }); | ||||
ENSURE(m_SavedTurnLengths.size() == m_ReadyTurn); | ENSURE(m_SavedTurnLengths.size() == m_ReadyTurn); | ||||
m_SavedTurnLengths.push_back(m_TurnLength); | m_SavedTurnLengths.push_back(m_TurnLength); | ||||
} | } | ||||
void CNetServerTurnManager::NotifyFinishedClientUpdate(int client, const CStrW& playername, u32 turn, const CStr& hash) | void CNetServerTurnManager::NotifyFinishedClientUpdate(int client, const CStrW& playername, u32 turn, const CStr& hash) | ||||
{ | { | ||||
// Clients must advance one turn at a time | // Clients must advance one turn at a time | ||||
Show All 38 Lines | for (const std::pair<u32, std::map<int, std::string>>& clientStateHash : m_ClientStateHashes) | ||||
// Tell everyone about it | // Tell everyone about it | ||||
if (m_HasSyncError) | if (m_HasSyncError) | ||||
{ | { | ||||
CSyncErrorMessage msg; | CSyncErrorMessage msg; | ||||
msg.m_Turn = clientStateHash.first; | msg.m_Turn = clientStateHash.first; | ||||
msg.m_HashExpected = expected; | msg.m_HashExpected = expected; | ||||
for (const CStrW& playername : OOSPlayerNames) | for (const CStrW& playername : OOSPlayerNames) | ||||
{ | { | ||||
CSyncErrorMessage::S_m_PlayerNames h; | msg.m_PlayerNames.push_back(playername); | ||||
leper: Could nuke the `{}`. | |||||
h.m_Name = playername; | |||||
msg.m_PlayerNames.push_back(h); | |||||
} | } | ||||
m_NetServer.Broadcast(&msg, { NSS_INGAME }); | m_NetServer.Broadcast(msg, { NSS_INGAME }); | ||||
break; | break; | ||||
} | } | ||||
} | } | ||||
// Delete the saved hashes for all turns that we've already verified | // Delete the saved hashes for all turns that we've already verified | ||||
m_ClientStateHashes.erase(m_ClientStateHashes.begin(), m_ClientStateHashes.lower_bound(newest+1)); | m_ClientStateHashes.erase(m_ClientStateHashes.begin(), m_ClientStateHashes.lower_bound(newest+1)); | ||||
} | } | ||||
Show All 32 Lines |
Wildfire Games · Phabricator
Could nuke the {}.