Changeset View
Changeset View
Standalone View
Standalone View
ps/trunk/source/simulation2/system/TurnManager.cpp
Show All 40 Lines | |||||
#endif | #endif | ||||
const CStr CTurnManager::EventNameSavegameLoaded = "SavegameLoaded"; | const CStr CTurnManager::EventNameSavegameLoaded = "SavegameLoaded"; | ||||
CTurnManager::CTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay) | CTurnManager::CTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay) | ||||
: m_Simulation2(simulation), m_CurrentTurn(0), m_ReadyTurn(1), m_TurnLength(defaultTurnLength), | : m_Simulation2(simulation), m_CurrentTurn(0), m_ReadyTurn(1), m_TurnLength(defaultTurnLength), | ||||
m_PlayerId(-1), m_ClientId(clientId), m_DeltaSimTime(0), m_HasSyncError(false), m_Replay(replay), | m_PlayerId(-1), m_ClientId(clientId), m_DeltaSimTime(0), m_HasSyncError(false), m_Replay(replay), | ||||
m_FinalTurn(std::numeric_limits<u32>::max()), m_TimeWarpNumTurns(0), | m_FinalTurn(std::numeric_limits<u32>::max()), m_TimeWarpNumTurns(0), | ||||
m_QuickSaveMetadata(m_Simulation2.GetScriptInterface().GetJSRuntime()) | m_QuickSaveMetadata(m_Simulation2.GetScriptInterface().GetGeneralJSContext()) | ||||
{ | { | ||||
// When we are on turn n, we schedule new commands for n+2. | // When we are on turn n, we schedule new commands for n+2. | ||||
// We know that all other clients have finished scheduling commands for n (else we couldn't have got here). | // We know that all other clients have finished scheduling commands for n (else we couldn't have got here). | ||||
// We know we have not yet finished scheduling commands for n+2. | // We know we have not yet finished scheduling commands for n+2. | ||||
// Hence other clients can be on turn n-1, n, n+1, and no other. | // Hence other clients can be on turn n-1, n, n+1, and no other. | ||||
// So they can be sending us commands scheduled for n+1, n+2, n+3. | // So they can be sending us commands scheduled for n+1, n+2, n+3. | ||||
// So we need a 3-element buffer: | // So we need a 3-element buffer: | ||||
m_QueuedCommands.resize(COMMAND_DELAY + 1); | m_QueuedCommands.resize(COMMAND_DELAY + 1); | ||||
▲ Show 20 Lines • Show All 304 Lines • Show Last 20 Lines |
Wildfire Games · Phabricator