Compare commits
6 Commits
7abb31c2e1
...
d412871de5
| Author | SHA1 | Date | |
|---|---|---|---|
| d412871de5 | |||
| 072c13ca89 | |||
| 998dc7ea2e | |||
| 3eb3eadd4b | |||
| 159867e747 | |||
| f9f5f60049 |
3
.gitmodules
vendored
Normal file
3
.gitmodules
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
[submodule "doxygen/doxygen-awesome-css"]
|
||||
path = doxygen/doxygen-awesome-css
|
||||
url = https://github.com/jothepro/doxygen-awesome-css.git
|
||||
21
doxygen/footer.html
Normal file
21
doxygen/footer.html
Normal file
@@ -0,0 +1,21 @@
|
||||
<!-- HTML footer for doxygen 1.9.1-->
|
||||
<!-- start footer part -->
|
||||
<!--BEGIN GENERATE_TREEVIEW-->
|
||||
<div id="nav-path" class="navpath"><!-- id is needed for treeview function! -->
|
||||
<ul>
|
||||
$navpath
|
||||
<li class="footer">$generatedby <a href="https://www.doxygen.org/index.html"><img class="footer"
|
||||
src="$relpath^doxygen.svg" width="104" height="31" alt="doxygen" /></a> $doxygenversion </li>
|
||||
</ul>
|
||||
</div>
|
||||
<!--END GENERATE_TREEVIEW-->
|
||||
<!--BEGIN !GENERATE_TREEVIEW-->
|
||||
<hr class="footer" />
|
||||
<address class="footer"><small>
|
||||
$generatedby <a href="https://www.doxygen.org/index.html"><img class="footer" src="$relpath^doxygen.svg"
|
||||
width="104" height="31" alt="doxygen" /></a> $doxygenversion
|
||||
</small></address>
|
||||
<!--END !GENERATE_TREEVIEW-->
|
||||
</body>
|
||||
|
||||
</html>
|
||||
66
doxygen/header.html
Normal file
66
doxygen/header.html
Normal file
@@ -0,0 +1,66 @@
|
||||
<!-- HTML header for doxygen 1.9.1-->
|
||||
<!DOCTYPE html
|
||||
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||||
<html xmlns="http://www.w3.org/1999/xhtml">
|
||||
|
||||
<head>
|
||||
<meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8" />
|
||||
<meta http-equiv="X-UA-Compatible" content="IE=9" />
|
||||
<meta name="generator" content="Doxygen $doxygenversion" />
|
||||
<meta name="viewport" content="width=device-width, initial-scale=1" />
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<title>$projectname: $title</title><!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<title>$title</title><!--END !PROJECT_NAME-->
|
||||
<link href="$relpath^tabs.css" rel="stylesheet" type="text/css" />
|
||||
<script type="text/javascript" src="$relpath^jquery.js"></script>
|
||||
<script type="text/javascript" src="$relpath^dynsections.js"></script>
|
||||
$treeview
|
||||
$search
|
||||
$mathjax
|
||||
<link href="$relpath^$stylesheet" rel="stylesheet" type="text/css" />
|
||||
$extrastylesheet
|
||||
<script type="text/javascript" src="$relpath^doxygen-awesome-darkmode-toggle.js"></script>
|
||||
<script type="text/javascript">
|
||||
DoxygenAwesomeDarkModeToggle.init()
|
||||
</script>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
<div id="top"><!-- do not remove this div, it is closed by doxygen! -->
|
||||
|
||||
<!--BEGIN TITLEAREA-->
|
||||
<div id="titlearea">
|
||||
<table cellspacing="0" cellpadding="0">
|
||||
<tbody>
|
||||
<tr style="height: 56px;">
|
||||
<!--BEGIN PROJECT_LOGO-->
|
||||
<td id="projectlogo"><img alt="Logo" src="$relpath^$projectlogo" /></td>
|
||||
<!--END PROJECT_LOGO-->
|
||||
<!--BEGIN PROJECT_NAME-->
|
||||
<td id="projectalign" style="padding-left: 0.5em;">
|
||||
<div id="projectname">$projectname
|
||||
<!--BEGIN PROJECT_NUMBER--> <span id="projectnumber">$projectnumber</span><!--END PROJECT_NUMBER-->
|
||||
</div>
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<div id="projectbrief">$projectbrief</div><!--END PROJECT_BRIEF-->
|
||||
</td>
|
||||
<!--END PROJECT_NAME-->
|
||||
<!--BEGIN !PROJECT_NAME-->
|
||||
<!--BEGIN PROJECT_BRIEF-->
|
||||
<td style="padding-left: 0.5em;">
|
||||
<div id="projectbrief">$projectbrief</div>
|
||||
</td>
|
||||
<!--END PROJECT_BRIEF-->
|
||||
<!--END !PROJECT_NAME-->
|
||||
<!--BEGIN DISABLE_INDEX-->
|
||||
<!--BEGIN SEARCHENGINE-->
|
||||
<td>$searchbox</td>
|
||||
<!--END SEARCHENGINE-->
|
||||
<!--END DISABLE_INDEX-->
|
||||
</tr>
|
||||
</tbody>
|
||||
</table>
|
||||
</div>
|
||||
<!--END TITLEAREA-->
|
||||
<!-- end header part -->
|
||||
5
doxygen/stylesheet.css
Normal file
5
doxygen/stylesheet.css
Normal file
@@ -0,0 +1,5 @@
|
||||
/* The standard CSS for doxygen 1.9.1 */
|
||||
|
||||
body, table, div, p, dl {
|
||||
font: 400 14px/22px Roboto,sans-serif;
|
||||
}
|
||||
@@ -1,8 +1,20 @@
|
||||
#pragma once
|
||||
|
||||
#include <Nazara/Network/ENetPeer.hpp>
|
||||
#include <blitz/protocol/PacketSerializer.h>
|
||||
#include <blitz/protocol/Packets.h>
|
||||
/**
|
||||
* \file EnetConnexion.h
|
||||
* \brief File containing the blitz::network::EnetConnexion class
|
||||
*/
|
||||
|
||||
#include <Nazara/Core/ByteArray.hpp>
|
||||
#include <NazaraUtils/Signal.hpp>
|
||||
#include <blitz/protocol/PacketData.h>
|
||||
#include <blitz/protocol/PacketDeclare.h>
|
||||
|
||||
namespace Nz {
|
||||
|
||||
class ENetPeer;
|
||||
|
||||
} // namespace Nz
|
||||
|
||||
namespace blitz {
|
||||
namespace network {
|
||||
@@ -12,11 +24,11 @@ class EnetServer;
|
||||
|
||||
|
||||
|
||||
#define DeclarePacket(Name, NFlag) \
|
||||
void Send##Name(const blitz::protocol::data::Name& a_##Name) const { \
|
||||
m_Peer->Send(0, NFlag, protocol::PacketSerializer::Serialize(protocol::packets::Name(a_##Name))); \
|
||||
} \
|
||||
NazaraSignal(On##Name, const blitz::protocol::data::Name&)
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
/** Sends a PacketName over the network */ \
|
||||
void Send##PacketName(const blitz::protocol::data::PacketName& a_##PacketName) const; \
|
||||
/** Use On##PacketName.Connect() to process a PacketName incoming from network */ \
|
||||
NazaraSignal(On##PacketName, const blitz::protocol::data::PacketName&);
|
||||
|
||||
|
||||
|
||||
@@ -26,13 +38,9 @@ class EnetConnexion {
|
||||
public:
|
||||
EnetConnexion(Nz::ENetPeer* a_Peer = nullptr);
|
||||
|
||||
bool IsConnected() const {
|
||||
if (!m_Peer)
|
||||
return false;
|
||||
return m_Peer->IsConnected();
|
||||
}
|
||||
bool IsConnected() const;
|
||||
|
||||
DeclareAllPacket()
|
||||
DeclareAllPacket();
|
||||
|
||||
private:
|
||||
Nz::ENetPeer* m_Peer;
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
#include <Nazara/Network/ENetHost.hpp>
|
||||
#include <blitz/common/NonCopyable.h>
|
||||
#include <blitz/network/EnetConnexion.h>
|
||||
#include <blitz/protocol/Packets.h>
|
||||
#include <cstdint>
|
||||
#include <map>
|
||||
#include <thread>
|
||||
@@ -19,7 +18,7 @@ class EnetServer : private NonCopyable {
|
||||
|
||||
void Destroy();
|
||||
|
||||
void BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags);
|
||||
// void BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags);
|
||||
|
||||
EnetConnexion* GetConnexion(std::uint16_t a_PeerId);
|
||||
|
||||
|
||||
@@ -1,19 +1,49 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file PacketDeclare.h
|
||||
* \brief Holds the definitions of the packets (but not their content)
|
||||
*/
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
|
||||
/**
|
||||
* \enum PacketSender
|
||||
* \brief Indicate who should send a packet
|
||||
*/
|
||||
enum class PacketSender {
|
||||
/** Sent by clients and server */
|
||||
Both,
|
||||
/** Sent by clients to the server */
|
||||
Client,
|
||||
/** Sent by server to the clients */
|
||||
Server,
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* \def DeclareAllPacket
|
||||
* \brief Avoids repetitive operations on packets
|
||||
*/
|
||||
#define DeclareAllPacket() \
|
||||
DeclarePacket(PlayerLogin, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(UpdateHealth, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(LoggingSuccess, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerDeath, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerJoin, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerLeave, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerStats, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerList, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(ServerConfig, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(ServerTps, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(UpdateGameState, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(KeepAlive, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(Disconnect, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(ChatMessage, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerPositionAndRotation, Nz::ENetPacketFlag::Reliable); \
|
||||
DeclarePacket(PlayerShoot, Nz::ENetPacketFlag::Reliable);
|
||||
DeclarePacket(ChatMessage, Reliable, Both) \
|
||||
DeclarePacket(Disconnect, Reliable, Both) \
|
||||
DeclarePacket(KeepAlive, Reliable, Both) \
|
||||
DeclarePacket(LoggingSuccess, Reliable, Server) \
|
||||
DeclarePacket(PlayerDeath, Reliable, Server) \
|
||||
DeclarePacket(PlayerJoin, Reliable, Server) \
|
||||
DeclarePacket(PlayerLeave, Reliable, Server) \
|
||||
DeclarePacket(PlayerList, Reliable, Server) \
|
||||
DeclarePacket(PlayerLogin, Reliable, Client) \
|
||||
DeclarePacket(PlayerPositionAndRotation, Reliable, Both) \
|
||||
DeclarePacket(PlayerShoot, Reliable, Both) \
|
||||
DeclarePacket(PlayerStats, Reliable, Server) \
|
||||
DeclarePacket(ServerConfig, Reliable, Server) \
|
||||
DeclarePacket(ServerTps, Reliable, Server) \
|
||||
DeclarePacket(UpdateGameState, Reliable, Server) \
|
||||
DeclarePacket(UpdateHealth, Reliable, Client)
|
||||
|
||||
|
||||
} // namespace protocol
|
||||
} // namespace blitz
|
||||
@@ -1,20 +1,33 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file PacketVisitor.h
|
||||
* \brief File containing the blitz::protocol::PacketVisitor class
|
||||
*/
|
||||
|
||||
#include <blitz/protocol/Packets.h>
|
||||
#include <blitz/protocol/PacketDeclare.h>
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
/** This function is called when the packet processed by PacketVisitor::Check is a PacketName */ \
|
||||
virtual void Visit(const packets::PacketName&) {}
|
||||
|
||||
class PacketVisitor {
|
||||
/**
|
||||
* \class PacketVisitor
|
||||
* \brief This class uses double-dispatch in order to find the real type of a packet
|
||||
*/
|
||||
class PacketVisitor : private NonCopyable {
|
||||
protected:
|
||||
PacketVisitor() {}
|
||||
virtual ~PacketVisitor() {}
|
||||
|
||||
public:
|
||||
/**
|
||||
* \brief Calls the right PacketVisitor::Visit method corresponding to the real type of the packet
|
||||
* \param packet the Packet to visit
|
||||
*/
|
||||
void Check(const Packet& packet);
|
||||
|
||||
DeclareAllPacket()
|
||||
|
||||
@@ -1,54 +1,52 @@
|
||||
#pragma once
|
||||
|
||||
/**
|
||||
* \file Packets.h
|
||||
* \brief File containing the definitions of the packets
|
||||
*/
|
||||
|
||||
#include <blitz/common/NonCopyable.h>
|
||||
#include <blitz/protocol/PacketData.h>
|
||||
#include <blitz/protocol/PacketDeclare.h>
|
||||
#include <string>
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
|
||||
class PacketVisitor;
|
||||
|
||||
/** A Packet id is 8 bits wide */
|
||||
using PacketID = std::uint8_t;
|
||||
|
||||
#define DeclarePacket(PacketName, ...) /** PacketName */ PacketName,
|
||||
|
||||
/**
|
||||
* \enum PacketType
|
||||
* \brief Map a Packet to an id
|
||||
*/
|
||||
enum class PacketType : PacketID {
|
||||
// client --> server
|
||||
|
||||
PlayerLogin = 0,
|
||||
UpdateHealth,
|
||||
|
||||
// client <-- server
|
||||
|
||||
LoggingSuccess,
|
||||
PlayerDeath,
|
||||
PlayerJoin,
|
||||
PlayerLeave,
|
||||
PlayerList,
|
||||
PlayerStats,
|
||||
ServerConfig,
|
||||
ServerTps,
|
||||
UpdateGameState,
|
||||
|
||||
// client <--> server
|
||||
|
||||
KeepAlive,
|
||||
Disconnect,
|
||||
ChatMessage,
|
||||
PlayerPositionAndRotation,
|
||||
PlayerShoot,
|
||||
DeclareAllPacket()
|
||||
|
||||
/** The number of packets */
|
||||
PACKET_COUNT
|
||||
};
|
||||
|
||||
|
||||
#undef DeclarePacket
|
||||
|
||||
|
||||
|
||||
class Packet {
|
||||
class Packet : private NonCopyable {
|
||||
public:
|
||||
/**
|
||||
* \return The real type of the packet
|
||||
*/
|
||||
virtual PacketType GetType() const = 0;
|
||||
|
||||
private:
|
||||
/** Use a PacketVisitor to make double-dispatch possible */
|
||||
virtual void Accept(PacketVisitor& a_Visitor) const = 0;
|
||||
|
||||
friend class PacketVisitor;
|
||||
};
|
||||
|
||||
|
||||
@@ -58,16 +56,21 @@ class Packet {
|
||||
namespace packets {
|
||||
|
||||
/**
|
||||
* \class ConcretePacket
|
||||
* \brief A Packet associated with an id and holding data
|
||||
* \tparam PT The packet type
|
||||
* \tparam Data The structure holding the data of the packet
|
||||
* \tparam Data The structure holding the data of the packet (in blitz::protocol::data namespace)
|
||||
*/
|
||||
template <PacketType PT, typename Data>
|
||||
class ConcretePacket : public Packet {
|
||||
public:
|
||||
/** The type of the struct holding the data */
|
||||
using PacketDataType = Data;
|
||||
|
||||
/** The structure holding the actual data */
|
||||
PacketDataType m_Data;
|
||||
|
||||
/** Construct the packet with data of type PacketDataType */
|
||||
ConcretePacket(const PacketDataType& a_Data = {});
|
||||
|
||||
constexpr PacketType GetType() const override {
|
||||
@@ -76,8 +79,6 @@ class ConcretePacket : public Packet {
|
||||
|
||||
private:
|
||||
void Accept(PacketVisitor& a_Visitor) const override;
|
||||
|
||||
friend class PacketVisitor;
|
||||
};
|
||||
|
||||
|
||||
@@ -90,9 +91,10 @@ class ConcretePacket : public Packet {
|
||||
#ifdef BLITZ_INSTANCIATE_PACKETS
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
using PacketName = ConcretePacket<PacketType::PacketName, data::PacketName>; \
|
||||
template class ConcretePacket<PacketType::PacketName, data::PacketName>
|
||||
template class ConcretePacket<PacketType::PacketName, data::PacketName>;
|
||||
#else
|
||||
#define DeclarePacket(PacketName, ...) using PacketName = ConcretePacket<PacketType::PacketName, data::PacketName>
|
||||
#define DeclarePacket(PacketName, ...) /** Defines the PacketName packet */ \
|
||||
using PacketName = ConcretePacket<PacketType::PacketName, data::PacketName>;
|
||||
#endif
|
||||
|
||||
DeclareAllPacket()
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include <blitz/network/EnetConnexion.h>
|
||||
|
||||
#include <Nazara/Network/ENetPeer.hpp>
|
||||
#include <blitz/protocol/PacketSerializer.h>
|
||||
#include <blitz/protocol/PacketVisitor.h>
|
||||
|
||||
@@ -20,12 +21,14 @@ class PacketDispatcher : public protocol::PacketVisitor {
|
||||
public:
|
||||
PacketDispatcher(EnetConnexion& a_Connexion) : m_Connexion(a_Connexion) {}
|
||||
|
||||
DeclareAllPacket();
|
||||
DeclareAllPacket()
|
||||
|
||||
private:
|
||||
EnetConnexion& m_Connexion;
|
||||
};
|
||||
|
||||
#undef DeclarePacket
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -36,6 +39,12 @@ void EnetConnexion::SetPeer(Nz::ENetPeer* a_Peer) {
|
||||
m_Peer = a_Peer;
|
||||
}
|
||||
|
||||
bool EnetConnexion::IsConnected() const {
|
||||
if (!m_Peer)
|
||||
return false;
|
||||
return m_Peer->IsConnected();
|
||||
}
|
||||
|
||||
void EnetConnexion::Recieve(Nz::ByteArray& a_Data) {
|
||||
auto packet = protocol::PacketSerializer::Deserialize(a_Data);
|
||||
if (!packet)
|
||||
@@ -44,5 +53,12 @@ void EnetConnexion::Recieve(Nz::ByteArray& a_Data) {
|
||||
dispatcher.Check(*packet.get());
|
||||
}
|
||||
|
||||
#define DeclarePacket(Name, NFlag, ...) \
|
||||
void EnetConnexion::Send##Name(const blitz::protocol::data::Name& a_##Name) const { \
|
||||
m_Peer->Send(0, Nz::ENetPacketFlag::NFlag, protocol::PacketSerializer::Serialize(protocol::packets::Name(a_##Name))); \
|
||||
}
|
||||
|
||||
DeclareAllPacket()
|
||||
|
||||
} // namespace network
|
||||
} // namespace blitz
|
||||
|
||||
@@ -76,9 +76,9 @@ EnetConnexion* EnetServer::GetConnexion(std::uint16_t a_PeerId) {
|
||||
return &it->second;
|
||||
}
|
||||
|
||||
void EnetServer::BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags) {
|
||||
// m_Host.Broadcast(0, a_Flags, std::move(a_Data));
|
||||
}
|
||||
/*void EnetServer::BroadcastPacket(const protocol::Packet& a_Packet, Nz::ENetPacketFlags a_Flags) {
|
||||
m_Host.Broadcast(0, a_Flags, std::move(a_Data));
|
||||
}*/
|
||||
|
||||
void EnetServer::RemoveConnexion(std::uint16_t a_PeerId) {
|
||||
m_Connexion.erase(a_PeerId);
|
||||
|
||||
@@ -9,23 +9,12 @@ namespace PacketFactory {
|
||||
|
||||
using PacketCreator = std::function<std::unique_ptr<Packet>()>;
|
||||
|
||||
#define DeclarePacket(PacketName, ...) std::make_unique<packets::PacketName>(),
|
||||
|
||||
static const std::array<std::unique_ptr<Packet>, static_cast<std::size_t>(PacketType::PACKET_COUNT)> Packets = {
|
||||
std::make_unique<packets::PlayerLogin>(),
|
||||
std::make_unique<packets::UpdateHealth>(),
|
||||
std::make_unique<packets::LoggingSuccess>(),
|
||||
std::make_unique<packets::PlayerDeath>(),
|
||||
std::make_unique<packets::PlayerJoin>(),
|
||||
std::make_unique<packets::PlayerLeave>(),
|
||||
std::make_unique<packets::PlayerList>(),
|
||||
std::make_unique<packets::PlayerStats>(),
|
||||
std::make_unique<packets::ServerConfig>(),
|
||||
std::make_unique<packets::ServerTps>(),
|
||||
std::make_unique<packets::UpdateGameState>(),
|
||||
std::make_unique<packets::KeepAlive>(),
|
||||
std::make_unique<packets::Disconnect>(),
|
||||
std::make_unique<packets::ChatMessage>(),
|
||||
std::make_unique<packets::PlayerPositionAndRotation>(),
|
||||
std::make_unique<packets::PlayerShoot>(),
|
||||
|
||||
DeclareAllPacket()
|
||||
|
||||
};
|
||||
|
||||
const std::unique_ptr<Packet>& CreateReadOnlyPacket(PacketType a_Type) {
|
||||
|
||||
@@ -11,29 +11,16 @@ namespace protocol {
|
||||
|
||||
namespace PacketSerializer {
|
||||
|
||||
#define VisitSerialize(ClassName) \
|
||||
void Visit(const ClassName& a_Packet) override { \
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
void Visit(const packets::PacketName& a_Packet) override { \
|
||||
const auto& packetData = a_Packet.m_Data; \
|
||||
SerializePacketData(packetData); \
|
||||
} \
|
||||
\
|
||||
void SerializePacketData(const ClassName::PacketDataType& a_Packet)
|
||||
|
||||
#define VisitDeserialize(ClassName) \
|
||||
void Visit(const ClassName& a_Packet) override { \
|
||||
auto packetPtr = PacketFactory::CreatePacket<ClassName>(); \
|
||||
auto& packetData = packetPtr->m_Data; \
|
||||
\
|
||||
DeserializePacketData(packetData); \
|
||||
\
|
||||
m_Packet = std::move(packetPtr); \
|
||||
} \
|
||||
\
|
||||
void DeserializePacketData(ClassName::PacketDataType& a_Packet)
|
||||
void SerializePacketData(const packets::PacketName::PacketDataType& a_Packet);
|
||||
|
||||
|
||||
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
VisitSerialize(packets::PacketName)
|
||||
|
||||
class Serializer : public PacketVisitor {
|
||||
private:
|
||||
@@ -51,8 +38,24 @@ class Serializer : public PacketVisitor {
|
||||
};
|
||||
|
||||
#undef DeclarePacket
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
VisitDeserialize(packets::PacketName)
|
||||
void Visit(const packets::PacketName& a_Packet) override { \
|
||||
auto packetPtr = PacketFactory::CreatePacket<packets::PacketName>(); \
|
||||
auto& packetData = packetPtr->m_Data; \
|
||||
\
|
||||
DeserializePacketData(packetData); \
|
||||
\
|
||||
m_Packet = std::move(packetPtr); \
|
||||
} \
|
||||
\
|
||||
void DeserializePacketData(packets::PacketName::PacketDataType& a_Packet);
|
||||
|
||||
|
||||
|
||||
class Deserializer : public PacketVisitor {
|
||||
private:
|
||||
|
||||
Reference in New Issue
Block a user