Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CReplayTurnManager Class Reference

Implementation of CLocalTurnManager for replay games. More...

#include <ReplayTurnManager.h>

Inheritance diagram for CReplayTurnManager:
Collaboration diagram for CReplayTurnManager:

Public Member Functions

 CReplayTurnManager (CSimulation2 &simulation, IReplayLogger &replay)
 
void StoreReplayCommand (u32 turn, int player, const std::string &command)
 
void StoreReplayTurnLength (u32 turn, u32 turnLength)
 
void StoreReplayHash (u32 turn, const std::string &hash, bool quick)
 
void StoreFinalReplayTurn (u32 turn)
 
- Public Member Functions inherited from CLocalTurnManager
 CLocalTurnManager (CSimulation2 &simulation, IReplayLogger &replay)
 
void OnSimulationMessage (CSimulationMessage *msg) override
 Called by networking code when a simulation message is received. More...
 
void PostCommand (JS::HandleValue data) override
 Called by simulation code, to add a new command to be distributed to all clients and executed soon. More...
 
void PostCommand (player_id_t playerid, JS::HandleValue data)
 
- Public Member Functions inherited from CTurnManager
 CTurnManager (CSimulation2 &simulation, u32 defaultTurnLength, u32 commandDelay, int clientId, IReplayLogger &replay)
 Construct for a given network session ID. More...
 
virtual ~CTurnManager ()
 
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...
 
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 PostCommand (JS::HandleValue 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 (JS::HandleValue GUIMetadata)
 
void QuickLoad ()
 
u32 GetCurrentTurn () const
 
u32 GetPendingTurns () const
 

Private Member Functions

void NotifyFinishedUpdate (u32 turn) override
 Called when this client has finished a simulation update. More...
 
void DoTurn (u32 turn)
 

Private Attributes

bool m_HasSyncError = false
 
std::map< u32, std::vector< std::pair< player_id_t, std::string > > > m_ReplayCommands
 
std::map< u32, u32m_ReplayTurnLengths
 
std::map< u32, std::pair< std::string, bool > > m_ReplayHash
 

Static Private Attributes

static const CStr EventNameReplayFinished = "ReplayFinished"
 
static const CStr EventNameReplayOutOfSync = "ReplayOutOfSync"
 

Additional Inherited Members

- Protected Member Functions inherited from CLocalTurnManager
void NotifyFinishedOwnCommands (u32 turn) override
 Called when this client has finished sending all its commands scheduled for the given turn. More...
 
virtual void NotifyFinishedUpdate (u32 turn) override
 Called when this client has finished a simulation update. More...
 
- Protected Member Functions inherited from CTurnManager
void AddCommand (int client, int player, JS::HandleValue data, u32 turn)
 Store a command to be executed at a given turn. More...
 
virtual void NotifyFinishedOwnCommands (u32 turn)=0
 Called when this client has finished sending all its commands scheduled for the given turn. More...
 
virtual void NotifyFinishedUpdate (u32 turn)=0
 Called when this client has finished a simulation update. More...
 
bool TurnNeedsFullHash (u32 turn) const
 Returns whether we should compute a complete state hash for the given turn, instead of a quick less-complete hash. More...
 
- Protected Attributes inherited from CTurnManager
CSimulation2m_Simulation2
 
u32 m_CurrentTurn
 The turn that we have most recently executed. More...
 
u32 m_CommandDelay
 
u32 m_ReadyTurn
 The latest turn for which we have received all commands from all clients. More...
 
u32 m_TurnLength
 
std::deque< std::map< u32, std::vector< SimulationCommand > > > m_QueuedCommands
 Commands queued at each turn (index 0 is for m_CurrentTurn+1) More...
 
int m_PlayerId
 
uint m_ClientId
 
float m_DeltaSimTime
 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). More...
 
IReplayLoggerm_Replay
 
u32 m_FinalTurn
 

Detailed Description

Implementation of CLocalTurnManager for replay games.

Constructor & Destructor Documentation

◆ CReplayTurnManager()

CReplayTurnManager::CReplayTurnManager ( CSimulation2 simulation,
IReplayLogger replay 
)

Member Function Documentation

◆ DoTurn()

void CReplayTurnManager::DoTurn ( u32  turn)
private

◆ NotifyFinishedUpdate()

void CReplayTurnManager::NotifyFinishedUpdate ( u32  turn)
overrideprivatevirtual

Called when this client has finished a simulation update.

Reimplemented from CLocalTurnManager.

◆ StoreFinalReplayTurn()

void CReplayTurnManager::StoreFinalReplayTurn ( u32  turn)

◆ StoreReplayCommand()

void CReplayTurnManager::StoreReplayCommand ( u32  turn,
int  player,
const std::string &  command 
)

◆ StoreReplayHash()

void CReplayTurnManager::StoreReplayHash ( u32  turn,
const std::string &  hash,
bool  quick 
)

◆ StoreReplayTurnLength()

void CReplayTurnManager::StoreReplayTurnLength ( u32  turn,
u32  turnLength 
)

Member Data Documentation

◆ EventNameReplayFinished

const CStr CReplayTurnManager::EventNameReplayFinished = "ReplayFinished"
staticprivate

◆ EventNameReplayOutOfSync

const CStr CReplayTurnManager::EventNameReplayOutOfSync = "ReplayOutOfSync"
staticprivate

◆ m_HasSyncError

bool CReplayTurnManager::m_HasSyncError = false
private

◆ m_ReplayCommands

std::map<u32, std::vector<std::pair<player_id_t, std::string> > > CReplayTurnManager::m_ReplayCommands
private

◆ m_ReplayHash

std::map<u32, std::pair<std::string, bool> > CReplayTurnManager::m_ReplayHash
private

◆ m_ReplayTurnLengths

std::map<u32, u32> CReplayTurnManager::m_ReplayTurnLengths
private

The documentation for this class was generated from the following files: