Common network turn system (used by clients and offline games).
More...
#include <NetTurnManager.h>
|
| CNetTurnManager (CSimulation2 &simulation, u32 defaultTurnLength, int clientId, IReplayLogger &replay) |
| Construct for a given network session ID. More...
|
|
virtual | ~CNetTurnManager () |
|
void | ResetState (u32 newCurrentTurn, u32 newReadyTurn) |
|
void | SetPlayerID (int playerId) |
| Set the current user's player ID, which will be added into command messages. More...
|
|
bool | Update (float simFrameLength, size_t maxTurns) |
| Advance the simulation by a certain time. More...
|
|
bool | UpdateFastForward () |
| Advance the simulation by as much as possible. More...
|
|
bool | WillUpdate (float simFrameLength) |
| Returns whether Update(simFrameLength, ...) will process at least one new turn. More...
|
|
void | Interpolate (float simFrameLength, float realFrameLength) |
| Advance the graphics by a certain time. More...
|
|
virtual void | OnSimulationMessage (CSimulationMessage *msg)=0 |
| Called by networking code when a simulation message is received. More...
|
|
virtual void | OnSyncError (u32 turn, const std::string &expectedHash) |
| Called when there has been an out-of-sync error. More...
|
|
virtual void | PostCommand (CScriptValRooted data)=0 |
| Called by simulation code, to add a new command to be distributed to all clients and executed soon. More...
|
|
void | FinishedAllCommands (u32 turn, u32 turnLength) |
| Called when all commands for a given turn have been received. More...
|
|
void | EnableTimeWarpRecording (size_t numTurns) |
| Enables the recording of state snapshots every numTurns , which can be jumped back to via RewindTimeWarp(). More...
|
|
void | RewindTimeWarp () |
| Jumps back to the latest recorded state snapshot (if any). More...
|
|
void | QuickSave () |
|
void | QuickLoad () |
|
u32 | GetCurrentTurn () |
|
Common network turn system (used by clients and offline games).
Definition at line 52 of file NetTurnManager.h.
virtual CNetTurnManager::~CNetTurnManager |
( |
| ) |
|
|
inlinevirtual |
void CNetTurnManager::EnableTimeWarpRecording |
( |
size_t |
numTurns | ) |
|
Enables the recording of state snapshots every numTurns
, which can be jumped back to via RewindTimeWarp().
If numTurns
is 0 then recording is disabled.
Definition at line 300 of file NetTurnManager.cpp.
void CNetTurnManager::FinishedAllCommands |
( |
u32 |
turn, |
|
|
u32 |
turnLength |
|
) |
| |
Called when all commands for a given turn have been received.
This allows Update to progress to that turn.
Definition at line 275 of file NetTurnManager.cpp.
u32 CNetTurnManager::GetCurrentTurn |
( |
| ) |
|
|
inline |
void CNetTurnManager::Interpolate |
( |
float |
simFrameLength, |
|
|
float |
realFrameLength |
|
) |
| |
Advance the graphics by a certain time.
- Parameters
-
simFrameLength | Length of the previous frame, in simulation seconds |
realFrameLength | Length of the previous frame, in real time seconds |
Definition at line 250 of file NetTurnManager.cpp.
virtual void CNetTurnManager::NotifyFinishedOwnCommands |
( |
u32 |
turn | ) |
|
|
protectedpure virtual |
virtual void CNetTurnManager::NotifyFinishedUpdate |
( |
u32 |
turn | ) |
|
|
protectedpure virtual |
void CNetTurnManager::OnSyncError |
( |
u32 |
turn, |
|
|
const std::string & |
expectedHash |
|
) |
| |
|
virtual |
void CNetTurnManager::QuickLoad |
( |
| ) |
|
void CNetTurnManager::QuickSave |
( |
| ) |
|
void CNetTurnManager::ResetState |
( |
u32 |
newCurrentTurn, |
|
|
u32 |
newReadyTurn |
|
) |
| |
void CNetTurnManager::RewindTimeWarp |
( |
| ) |
|
Jumps back to the latest recorded state snapshot (if any).
Definition at line 306 of file NetTurnManager.cpp.
void CNetTurnManager::SetPlayerID |
( |
int |
playerId | ) |
|
Set the current user's player ID, which will be added into command messages.
Definition at line 84 of file NetTurnManager.cpp.
bool CNetTurnManager::TurnNeedsFullHash |
( |
u32 |
turn | ) |
|
|
protected |
Returns whether we should compute a complete state hash for the given turn, instead of a quick less-complete hash.
Definition at line 284 of file NetTurnManager.cpp.
bool CNetTurnManager::Update |
( |
float |
simFrameLength, |
|
|
size_t |
maxTurns |
|
) |
| |
Advance the simulation by a certain time.
If this brings us past the current turn length, the next turns are processed and the function returns true. Otherwise, nothing happens and it returns false.
- Parameters
-
simFrameLength | Length of the previous frame, in simulation seconds |
maxTurns | Maximum number of turns to simulate at once |
Definition at line 102 of file NetTurnManager.cpp.
bool CNetTurnManager::UpdateFastForward |
( |
| ) |
|
Advance the simulation by as much as possible.
Intended for catching up over a small number of turns when rejoining a multiplayer match. Returns true if it advanced by at least one turn.
Definition at line 182 of file NetTurnManager.cpp.
bool CNetTurnManager::WillUpdate |
( |
float |
simFrameLength | ) |
|
Returns whether Update(simFrameLength, ...) will process at least one new turn.
- Parameters
-
simFrameLength | Length of the previous frame, in simulation seconds |
Definition at line 89 of file NetTurnManager.cpp.
uint CNetTurnManager::m_ClientId |
|
protected |
u32 CNetTurnManager::m_CurrentTurn |
|
protected |
float CNetTurnManager::m_DeltaSimTime |
|
protected |
Simulation time remaining until we ought to execute the next turn (as a negative value to add elapsed time increments to until we reach 0).
Definition at line 179 of file NetTurnManager.h.
bool CNetTurnManager::m_HasSyncError |
|
protected |
int CNetTurnManager::m_PlayerId |
|
protected |
Commands queued at each turn (index 0 is for m_CurrentTurn+1)
Definition at line 172 of file NetTurnManager.h.
std::string CNetTurnManager::m_QuickSaveMetadata |
|
private |
std::string CNetTurnManager::m_QuickSaveState |
|
private |
u32 CNetTurnManager::m_ReadyTurn |
|
protected |
The latest turn for which we have received all commands from all clients.
Definition at line 166 of file NetTurnManager.h.
size_t CNetTurnManager::m_TimeWarpNumTurns |
|
private |
std::list<std::string> CNetTurnManager::m_TimeWarpStates |
|
private |
u32 CNetTurnManager::m_TurnLength |
|
protected |
The documentation for this class was generated from the following files: