Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
CSimulationMessage Class Reference

Special message type for simulation commands. More...

#include <NetMessage.h>

Inheritance diagram for CSimulationMessage:
Collaboration diagram for CSimulationMessage:

Public Member Functions

 CSimulationMessage (const Script::Interface &scriptInterface)
 
 CSimulationMessage (const Script::Interface &scriptInterface, std::uint32_t client, std::int32_t player, std::uint32_t turn, JS::HandleValue data)
 
 CSimulationMessage (const CSimulationMessage &orig)
 The compiler can't create a copy constructor because of the PersistentRooted member, so we have to write it manually. More...
 
virtual std::uint8_t * Serialize (std::uint8_t *pBuffer) const
 Serialize the message into the specified buffer parameter. More...
 
virtual const std::uint8_t * Deserialize (const std::uint8_t *pStart, const std::uint8_t *pEnd)
 Deserializes the message from the specified buffer. More...
 
virtual size_t GetSerializedLength () const
 Retrieves the size in bytes of the serialized message. More...
 
virtual CStr ToString () const
 Returns a string representation for the message. More...
 
- Public Member Functions inherited from CNetMessage
 CNetMessage ()
 
 CNetMessage (NetMessageType type)
 
virtual ~CNetMessage ()
 
NetMessageType GetType () const
 Retrieves the message type. More...
 
virtual std::uint8_t * Serialize (std::uint8_t *pBuffer) const
 Serialize the message into the specified buffer parameter. More...
 
virtual const std::uint8_t * Deserialize (const std::uint8_t *pStart, const std::uint8_t *pEnd)
 Deserializes the message from the specified buffer. More...
 
virtual size_t GetSerializedLength () const
 Retrieves the size in bytes of the serialized message. More...
 
virtual CStr ToString () const
 Returns a string representation for the message. More...
 
- Public Member Functions inherited from ISerializable
virtual ~ISerializable ()
 
virtual size_t GetSerializedLength () const =0
 Return the length of the serialized form of this object. More...
 
virtual std::uint8_t * Serialize (std::uint8_t *buffer) const =0
 Serialize the object into the passed buffer. More...
 
virtual const std::uint8_t * Deserialize (const std::uint8_t *buffer, const std::uint8_t *end)=0
 Deserialize the object (i.e. More...
 

Public Attributes

std::uint32_t m_Client
 
std::int32_t m_Player
 
std::int32_t m_Turn
 
JS::PersistentRooted< JS::Value > m_Data
 

Private Attributes

const Script::Interface & m_ScriptInterface
 

Detailed Description

Special message type for simulation commands.

These commands are exposed as arbitrary JS objects, associated with a specific player.

Constructor & Destructor Documentation

◆ CSimulationMessage() [1/3]

CSimulationMessage::CSimulationMessage ( const Script::Interface &  scriptInterface)

◆ CSimulationMessage() [2/3]

CSimulationMessage::CSimulationMessage ( const Script::Interface &  scriptInterface,
std::uint32_t  client,
std::int32_t  player,
std::uint32_t  turn,
JS::HandleValue  data 
)

◆ CSimulationMessage() [3/3]

CSimulationMessage::CSimulationMessage ( const CSimulationMessage &  orig)

The compiler can't create a copy constructor because of the PersistentRooted member, so we have to write it manually.

NOTE: It doesn't clone the m_Data member and the copy will reference the same JS::Value!

Member Function Documentation

◆ Deserialize()

const std::uint8_t * CSimulationMessage::Deserialize ( const std::uint8_t *  pStart,
const std::uint8_t *  pEnd 
)
virtual

Deserializes the message from the specified buffer.

Parameters
pStartMessage start within the serialized buffer
pEndMessage end within the serialized buffer
Returns
The position in the buffer right after the message or NULL if an error occurred

Reimplemented from CNetMessage.

◆ GetSerializedLength()

size_t CSimulationMessage::GetSerializedLength ( ) const
virtual

Retrieves the size in bytes of the serialized message.

Before calling Serialize, the memory size for the buffer where to serialize the message object can be found by calling this method.

Returns
The size of serialized message

Reimplemented from CNetMessage.

◆ Serialize()

std::uint8_t * CSimulationMessage::Serialize ( std::uint8_t *  pBuffer) const
virtual

Serialize the message into the specified buffer parameter.

The size required by the buffer parameter can be found by a call to GetSerializedLength method. The information contained within the message must be serialized before the message is sent. By default only the message type and its size are serialized in the buffer parameter.

Parameters
pBufferBuffer where to serialize the message
Returns
The position in the buffer right after the serialized message

Reimplemented from CNetMessage.

◆ ToString()

CStr CSimulationMessage::ToString ( ) const
virtual

Returns a string representation for the message.

Returns
The message as a string

Reimplemented from CNetMessage.

Member Data Documentation

◆ m_Client

std::uint32_t CSimulationMessage::m_Client

◆ m_Data

JS::PersistentRooted<JS::Value> CSimulationMessage::m_Data

◆ m_Player

std::int32_t CSimulationMessage::m_Player

◆ m_ScriptInterface

const Script::Interface& CSimulationMessage::m_ScriptInterface
private

◆ m_Turn

std::int32_t CSimulationMessage::m_Turn

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