R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GameMessage.hpp File Reference
#include <cstddef>
#include <sstream>
#include <cstdint>
#include <cstring>
Include dependency graph for GameMessage.hpp:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  coord
 A structure representing coordinates in a 2D space. More...
 
struct  messageInfo
 A structure containing information about a game message. More...
 
struct  GameMessage
 A structure representing a game message. More...
 

Enumerations

enum  messageType : uint8_t {
  P_EMPTY , P_CONNECT , P_DISCONNECT , P_MOVE ,
  P_SHOOT , P_SPAWN , P_KILL , P_DAMAGE ,
  P_HEAL , P_BUFF , P_STATUS , P_ERROR = 0xFF
}
 Enum representing the different types of game messages. More...
 

Functions

GameMessage deserialize (std::istringstream &is)
 Deserializes a GameMessage object from a binary stream.
 
void serialize (const GameMessage &message, std::ostringstream &os)
 Serializes a GameMessage object into a binary stream.
 

Enumeration Type Documentation

◆ messageType

enum messageType : uint8_t

Enum representing the different types of game messages.

The messageType enum defines various message types used for communication in the game, such as events like spawning, movement, damage, and status updates.

Enumerator
P_EMPTY 
P_CONNECT 

Represents a connecting player event.

P_DISCONNECT 

Represents a disconnecting player event.

P_MOVE 

Represents a movement event.

P_SHOOT 

Represents a player shooting event.

P_SPAWN 

Represents a spawn event.

P_KILL 

Represents a kill event.

P_DAMAGE 

Represents a damage event.

P_HEAL 

Represents a healing event.

P_BUFF 

Represents a buff event.

P_STATUS 

Represents a status event.

P_ERROR 

Represents an error occurred.

Definition at line 14 of file GameMessage.hpp.

Function Documentation

◆ deserialize()

GameMessage deserialize ( std::istringstream & is)

Deserializes a GameMessage object from a binary stream.

This function reads binary data from the provided input stream and reconstructs a GameMessage object. The binary data should have been written using the serialize function.

Parameters
isThe input stream from which the binary data will be read.
Returns
GameMessage The reconstructed GameMessage object.

Definition at line 54 of file GameMessage.cpp.

◆ serialize()

void serialize ( const GameMessage & message,
std::ostringstream & os )

Serializes a GameMessage object into a binary stream.

This function writes the GameMessage object's data to the provided output stream in binary format. The serialized data can later be read using the deserialize function.

Parameters
messageThe GameMessage object to serialize.
osThe output stream to which the binary data will be written.

Definition at line 3 of file GameMessage.cpp.