Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CNetServerTurnManager Class Reference

The server-side counterpart to CNetClientTurnManager. More...

#include <NetServerTurnManager.h>

Collaboration diagram for CNetServerTurnManager:

Classes

struct  Client
 

Public Member Functions

 CNetServerTurnManager (CNetServerWorker &server)
 
void NotifyFinishedClientCommands (CNetServerSession &session, turn_id_t turn)
 
void NotifyFinishedClientUpdate (CNetServerSession &session, turn_id_t turn, const CStr &hash)
 
void InitialiseClient (int client, turn_id_t turn, bool observer)
 Inform the turn manager of a new client. More...
 
void UninitialiseClient (int client)
 Inform the turn manager that a previously-initialised client has left the game. More...
 
void SetTurnLength (std::uint32_t msecs)
 
turn_id_t GetReadyTurn ()
 Returns the latest turn for which all clients are ready; they will have already been told to execute this turn. More...
 
std::uint32_t GetSavedTurnLength (turn_id_t turn)
 Returns the turn length that was used for the given turn. More...
 

Private Member Functions

 NONCOPYABLE (CNetServerTurnManager)
 
void CheckClientsReady ()
 

Private Attributes

std::unordered_map< int, Client > m_ClientsData
 
bool m_HasSyncError = false
 
std::map< turn_id_t, std::map< int, std::string > > m_ClientStateHashes
 
turn_id_t m_ReadyTurn
 The latest turn for which we have received all commands from all clients. More...
 
std::uint32_t m_TurnLength
 
std::vector< std::uint32_t > m_SavedTurnLengths
 
CNetServerWorker & m_NetServer
 

Detailed Description

The server-side counterpart to CNetClientTurnManager.

Records the turn state of each client, and sends turn advancement messages when clients are ready.

Thread-safety:

  • This is constructed and used by CNetServerWorker in the network server thread.

Constructor & Destructor Documentation

◆ CNetServerTurnManager()

CNetServerTurnManager::CNetServerTurnManager ( CNetServerWorker &  server)

Member Function Documentation

◆ CheckClientsReady()

void CNetServerTurnManager::CheckClientsReady ( )
private

◆ GetReadyTurn()

turn_id_t CNetServerTurnManager::GetReadyTurn ( )
inline

Returns the latest turn for which all clients are ready; they will have already been told to execute this turn.

◆ GetSavedTurnLength()

std::uint32_t CNetServerTurnManager::GetSavedTurnLength ( turn_id_t  turn)

Returns the turn length that was used for the given turn.

Requires turn <= GetReadyTurn().

◆ InitialiseClient()

void CNetServerTurnManager::InitialiseClient ( int  client,
turn_id_t  turn,
bool  observer 
)

Inform the turn manager of a new client.

Parameters
observer- whether this client is an observer.

◆ NONCOPYABLE()

CNetServerTurnManager::NONCOPYABLE ( CNetServerTurnManager  )
private

◆ NotifyFinishedClientCommands()

void CNetServerTurnManager::NotifyFinishedClientCommands ( CNetServerSession &  session,
turn_id_t  turn 
)

◆ NotifyFinishedClientUpdate()

void CNetServerTurnManager::NotifyFinishedClientUpdate ( CNetServerSession &  session,
turn_id_t  turn,
const CStr &  hash 
)

◆ SetTurnLength()

void CNetServerTurnManager::SetTurnLength ( std::uint32_t  msecs)

◆ UninitialiseClient()

void CNetServerTurnManager::UninitialiseClient ( int  client)

Inform the turn manager that a previously-initialised client has left the game.

Member Data Documentation

◆ m_ClientsData

std::unordered_map<int, Client> CNetServerTurnManager::m_ClientsData
private

◆ m_ClientStateHashes

std::map<turn_id_t, std::map<int, std::string> > CNetServerTurnManager::m_ClientStateHashes
private

◆ m_HasSyncError

bool CNetServerTurnManager::m_HasSyncError = false
private

◆ m_NetServer

CNetServerWorker& CNetServerTurnManager::m_NetServer
private

◆ m_ReadyTurn

turn_id_t CNetServerTurnManager::m_ReadyTurn
private

The latest turn for which we have received all commands from all clients.

◆ m_SavedTurnLengths

std::vector<std::uint32_t> CNetServerTurnManager::m_SavedTurnLengths
private

◆ m_TurnLength

std::uint32_t CNetServerTurnManager::m_TurnLength
private

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