VOX
A little voxel engine
Loading...
Searching...
No Matches
PlayerListPacket.hpp
Go to the documentation of this file.
1#pragma once
2
3#include "IPacket.hpp"
4#include "glm/vec3.hpp"
5
7{
8public:
9 struct PlayerInfo
10 {
11 uint64_t id;
12 glm::dvec3 position;
13 };
15 PlayerListPacket(const std::vector<PlayerInfo> & players);
17
22
23 void Serialize(uint8_t * buffer) const override;
24 void Deserialize(const uint8_t * buffer) override;
25 uint32_t Size() const override;
26 bool HasDynamicSize() const override;
27 IPacket::Type GetType() const override;
28
29 std::shared_ptr<IPacket> Clone() const override;
30
31 /*******************************
32 * ATTRIBUTES
33 * *******************************/
34
35 const std::vector<PlayerInfo> & GetPlayers() const;
36
37 void SetPlayers(const std::vector<PlayerInfo> & players);
38private:
39 std::vector<PlayerInfo> m_players;
40};
an abstract class that servers as a base for all network packets
Definition: IPacket.hpp:40
Type
Definition: IPacket.hpp:48
Definition: PlayerListPacket.hpp:7
const std::vector< PlayerInfo > & GetPlayers() const
Definition: PlayerListPacket.cpp:107
PlayerListPacket & operator=(const PlayerListPacket &other)
Definition: PlayerListPacket.cpp:26
void Serialize(uint8_t *buffer) const override
will write the packet in the buffer, the buffer must at least be of size Size()
Definition: PlayerListPacket.cpp:46
~PlayerListPacket()
Definition: PlayerListPacket.cpp:7
bool HasDynamicSize() const override
Tell if the packet has a dynamic size.
Definition: PlayerListPacket.cpp:92
std::shared_ptr< IPacket > Clone() const override
Create a new instance of the packet.
Definition: PlayerListPacket.cpp:102
void SetPlayers(const std::vector< PlayerInfo > &players)
Definition: PlayerListPacket.cpp:112
PlayerListPacket()
Definition: PlayerListPacket.cpp:3
IPacket::Type GetType() const override
Get the Type of the packet.
Definition: PlayerListPacket.cpp:97
void Deserialize(const uint8_t *buffer) override
read the packet from the buffer, the buffer must at least be of size Size()
Definition: PlayerListPacket.cpp:60
uint32_t Size() const override
return the size of the packet in bytes, usually used to reserve the right amount of memory in the sen...
Definition: PlayerListPacket.cpp:87
Definition: PlayerListPacket.hpp:10
glm::dvec3 position
Definition: PlayerListPacket.hpp:12
uint64_t id
Definition: PlayerListPacket.hpp:11