R-Type  2
Doom but in better
Loading...
Searching...
No Matches
GameMessage.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <cstddef>
4#include <sstream>
5#include <cstdint>
6#include <cstring>
7
28
34struct coord {
35 float x;
36 float y;
37};
38
46 uint8_t status;
48 uint32_t cli_id;
49 char username[9];
51};
52
64
74GameMessage deserialize(std::istringstream& is);
75
85void serialize(const GameMessage& message, std::ostringstream& os);
messageType
Enum representing the different types of game messages.
@ P_SHOOT
Represents a player shooting event.
@ P_CONNECT
Represents a connecting player event.
@ P_BUFF
Represents a buff event.
@ P_ERROR
Represents an error occurred.
@ P_HEAL
Represents a healing event.
@ P_DAMAGE
Represents a damage event.
@ P_KILL
Represents a kill event.
@ P_STATUS
Represents a status event.
@ P_EMPTY
@ P_SPAWN
Represents a spawn event.
@ P_MOVE
Represents a movement event.
@ P_DISCONNECT
Represents a disconnecting player event.
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.
A structure representing a game message.
messageType type
The type of message (e.g., SPAWN, MOVE, etc.).
messageInfo msg
Additional information about the event (status, asset ID, and coordinates).
std::size_t id
The unique identifier for the entity or object involved in the event.
A structure representing coordinates in a 2D space.
float x
The X coordinate.
float y
The Y coordinate.
A structure containing information about a game message.
uint8_t status
Status of the event (e.g., success or failure).
uint32_t cli_id
Id of the player's client.
coord coords
Coordinates associated with the event, such as the position of an entity.
char username[9]
Username of player connecting.
int asset_id
ID representing the game asset related to the event (e.g., entity or object).