first commit

This commit is contained in:
2025-02-04 19:11:03 +01:00
commit cfeea10634
43 changed files with 2448 additions and 0 deletions

View File

@@ -0,0 +1,163 @@
#include <sp/common/DataBuffer.h>
#include <fstream>
#include <iomanip>
#include <sstream>
#include <sp/misc/Format.h>
#include <sp/misc/Log.h>
namespace sp {
DataBuffer::DataBuffer() : m_ReadOffset(0) {}
DataBuffer::DataBuffer(const DataBuffer& other) : m_Buffer(other.m_Buffer), m_ReadOffset(other.m_ReadOffset) {}
DataBuffer::DataBuffer(DataBuffer&& other) : m_Buffer(std::move(other.m_Buffer)), m_ReadOffset(std::move(other.m_ReadOffset)) {}
DataBuffer::DataBuffer(const std::string& str) : m_Buffer(str.begin(), str.end()), m_ReadOffset(0) {}
DataBuffer::DataBuffer(const DataBuffer& other, Data::difference_type offset) : m_ReadOffset(0) {
m_Buffer.reserve(other.GetSize() - static_cast<std::size_t>(offset));
std::copy(other.m_Buffer.begin() + offset, other.m_Buffer.end(), std::back_inserter(m_Buffer));
}
DataBuffer& DataBuffer::operator<<(const std::string& str) {
std::size_t strlen = str.length() + 1; // including null character
Resize(GetSize() + strlen);
std::memcpy(m_Buffer.data() + GetSize() - strlen, str.data(), strlen);
return *this;
}
DataBuffer& DataBuffer::operator<<(const DataBuffer& data) {
m_Buffer.insert(m_Buffer.end(), data.begin(), data.end());
return *this;
}
DataBuffer& DataBuffer::operator>>(std::string& str) {
std::size_t stringSize = strlen(reinterpret_cast<const char*>(m_Buffer.data()) + m_ReadOffset) + 1; // including null character
str.resize(stringSize);
std::copy(m_Buffer.begin() + static_cast<difference_type>(m_ReadOffset),
m_Buffer.begin() + static_cast<difference_type>(m_ReadOffset + stringSize), str.begin());
m_ReadOffset += stringSize;
str.resize(stringSize - 1);
return *this;
}
DataBuffer& DataBuffer::operator>>(DataBuffer& data) {
data.Resize(GetSize() - m_ReadOffset);
std::copy(m_Buffer.begin() + static_cast<difference_type>(m_ReadOffset), m_Buffer.end(), data.begin());
m_ReadOffset = m_Buffer.size();
return *this;
}
void DataBuffer::WriteSome(const char* buffer, std::size_t amount) {
std::size_t end_pos = m_Buffer.size();
m_Buffer.resize(m_Buffer.size() + amount);
std::memcpy(m_Buffer.data() + end_pos, buffer, amount);
}
void DataBuffer::WriteSome(const std::uint8_t* buffer, std::size_t amount) {
std::size_t end_pos = m_Buffer.size();
m_Buffer.resize(m_Buffer.size() + amount);
std::memcpy(m_Buffer.data() + end_pos, buffer, amount);
}
void DataBuffer::ReadSome(char* buffer, std::size_t amount) {
assert(m_ReadOffset + amount <= GetSize());
std::copy_n(m_Buffer.begin() + static_cast<difference_type>(m_ReadOffset), amount, buffer);
m_ReadOffset += amount;
}
void DataBuffer::ReadSome(std::uint8_t* buffer, std::size_t amount) {
assert(m_ReadOffset + amount <= GetSize());
std::copy_n(m_Buffer.begin() + static_cast<difference_type>(m_ReadOffset), amount, buffer);
m_ReadOffset += amount;
}
void DataBuffer::ReadSome(DataBuffer& buffer, std::size_t amount) {
assert(m_ReadOffset + amount <= GetSize());
buffer.Resize(amount);
std::copy_n(m_Buffer.begin() + static_cast<difference_type>(m_ReadOffset), amount, buffer.begin());
m_ReadOffset += amount;
}
DataBuffer& DataBuffer::operator=(const DataBuffer& other) {
m_Buffer = other.m_Buffer;
m_ReadOffset = other.m_ReadOffset;
return *this;
}
DataBuffer& DataBuffer::operator=(DataBuffer&& other) {
m_Buffer = std::move(other.m_Buffer);
m_ReadOffset = std::move(other.m_ReadOffset);
return *this;
}
void DataBuffer::SetReadOffset(std::size_t pos) {
assert(pos <= GetSize());
m_ReadOffset = pos;
}
std::size_t DataBuffer::GetSize() const {
return m_Buffer.size();
}
std::size_t DataBuffer::GetRemaining() const {
return m_Buffer.size() - m_ReadOffset;
}
DataBuffer::iterator DataBuffer::begin() {
return m_Buffer.begin();
}
DataBuffer::iterator DataBuffer::end() {
return m_Buffer.end();
}
DataBuffer::const_iterator DataBuffer::begin() const {
return m_Buffer.begin();
}
DataBuffer::const_iterator DataBuffer::end() const {
return m_Buffer.end();
}
std::ostream& operator<<(std::ostream& os, const DataBuffer& buffer) {
for (unsigned char u : buffer)
os << std::hex << std::setfill('0') << std::setw(2) << static_cast<int>(u) << " ";
os << std::dec;
return os;
}
bool DataBuffer::ReadFile(const std::string& fileName) {
try {
std::ifstream file(fileName, std::istream::binary);
std::ostringstream ss;
ss << file.rdbuf();
const std::string& s = ss.str();
m_Buffer = DataBuffer::Data(s.begin(), s.end());
m_ReadOffset = 0;
} catch (std::exception& e) {
utils::LOGE(utils::Format("[IO] Failed to read file %s ! reason : %s", fileName.c_str(), e.what()));
return false;
}
return m_Buffer.size() > 0;
}
bool DataBuffer::WriteFile(const std::string& fileName) const {
try {
std::ofstream file(fileName, std::ostream::binary);
file.write(reinterpret_cast<const char*>(m_Buffer.data()), static_cast<std::streamsize>(m_Buffer.size()));
file.flush();
} catch (std::exception& e) {
utils::LOGE(utils::Format("[IO] Failed to read file %s ! reason : %s", fileName.c_str(), e.what()));
return false;
}
return true;
}
} // namespace sp

52
src/sp/common/VarInt.cpp Normal file
View File

@@ -0,0 +1,52 @@
#include <sp/common/VarInt.h>
#include <stdexcept>
#include <sp/common/DataBuffer.h>
namespace sp {
static constexpr int SEGMENT_BITS = 0x7F;
static constexpr int CONTINUE_BIT = 0x80;
std::size_t VarInt::GetSerializedLength() const {
DataBuffer buffer;
buffer << *this;
return buffer.GetSize();
}
DataBuffer& operator<<(DataBuffer& out, const VarInt& var) {
std::uint64_t value = var.m_Value;
while (true) {
if ((value & ~static_cast<std::uint64_t>(SEGMENT_BITS)) == 0) {
out << static_cast<std::uint8_t>(value);
return out;
}
out << static_cast<std::uint8_t>((value & SEGMENT_BITS) | CONTINUE_BIT);
value >>= 7;
}
}
DataBuffer& operator>>(DataBuffer& in, VarInt& var) {
var.m_Value = 0;
unsigned int position = 0;
std::uint8_t currentByte;
while (true) {
in.ReadSome(&currentByte, 1);
var.m_Value |= static_cast<std::uint64_t>(currentByte & SEGMENT_BITS) << position;
if ((currentByte & CONTINUE_BIT) == 0)
break;
position += 7;
if (position >= 8 * sizeof(var.m_Value))
throw std::runtime_error("VarInt is too big");
}
return in;
}
} // namespace sp

37
src/sp/misc/Log.cpp Normal file
View File

@@ -0,0 +1,37 @@
#include <sp/misc/Log.h>
#ifdef SP_ANDROID_LOGGING
#include <android/log.h>
#else
#include <iostream>
#endif
namespace sp {
namespace utils {
void LOG(const std::string& msg) {
#ifdef SP_ANDROID_LOGGING
__android_log_print(ANDROID_LOG_INFO, "TRACKERS", "%s", msg.c_str());
#else
std::cout << msg << "\n";
#endif
}
void LOGD(const std::string& msg) {
#if !defined(NDEBUG)
LOG(msg);
#endif
}
void LOGE(const std::string& err) {
#ifdef SP_ANDROID_LOGGING
__android_log_print(ANDROID_LOG_ERROR, "TRACKERS", "%s", err.c_str());
#else
std::cerr << err << "\n";
#endif
}
} // namespace utils
} // namespace sp

14
src/sp/misc/Test.cpp Normal file
View File

@@ -0,0 +1,14 @@
#include <sp/misc/Format.h>
#include <sp/misc/Log.h>
#include <sp/misc/Test.h>
namespace sp {
namespace test {
void LogAssert(const char* expression, const char* file, int line, const char* function) {
utils::LOGE(utils::Format("%s:%i: %s: Assertion failed !", file, line, function));
utils::LOGE(utils::Format(" %i |\t%s;", line, expression));
}
} // namespace test
} // namespace sp

View File

@@ -0,0 +1,24 @@
#include <sp/protocol/command/CommandFactory.h>
#include <array>
#include <cassert>
#include <functional>
namespace sp {
namespace protocol {
namespace CommandFactory {
using CommandCreator = std::function<std::shared_ptr<Command>()>;
#define DeclareCommand(CommandName, ...) std::make_shared<commands::CommandName>(),
static std::array<std::shared_ptr<Command>, static_cast<std::size_t>(CommandType::COMMAND_COUNT)> Commands = {DeclareAllCommand()};
const std::shared_ptr<Command>& CreateReadOnlyCommand(CommandType a_Type) {
assert(a_Type < CommandType::COMMAND_COUNT);
return Commands[static_cast<std::size_t>(a_Type)];
}
} // namespace CommandFactory
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,229 @@
#include <sp/protocol/command/CommandSerializer.h>
#include <sp/protocol/command/CommandFactory.h>
#include <sp/protocol/command/CommandVisitor.h>
#include <sp/misc/Format.h>
#include <sp/misc/Log.h>
namespace sp {
namespace protocol {
namespace CommandSerializer {
#define DeclareCommand(CommandName, ...) \
void Visit(const commands::CommandName& a_Command) override { \
const auto& commandData = a_Command.m_Data; \
SerializeCommandData(commandData); \
} \
\
void SerializeCommandData(const commands::CommandName::CommandDataType& a_Command);
class Serializer : public CommandVisitor {
private:
DataBuffer& m_Buffer;
public:
Serializer(DataBuffer& a_Buffer) : m_Buffer(a_Buffer) {}
void Serialize(const Command& a_Command) {
m_Buffer << static_cast<CommandID>(a_Command.GetType());
Check(a_Command);
}
DeclareAllCommand()
};
#undef DeclareCommand
#define DeclareCommand(CommandName, ...) \
void Visit(const commands::CommandName& a_Command) override { \
auto commandPtr = CommandFactory::CreateCommand<commands::CommandName>(); \
auto& commandData = commandPtr->m_Data; \
\
DeserializeCommandData(commandData); \
\
m_Command = std::move(commandPtr); \
} \
\
void DeserializeCommandData(commands::CommandName::CommandDataType& a_Command);
class Deserializer : public CommandVisitor {
private:
DataBuffer& m_Buffer;
CommandPtr m_Command;
public:
Deserializer(DataBuffer& a_Buffer) : m_Buffer(a_Buffer) {}
bool Deserialize(const CommandPtr& a_Command) {
try {
Check(*a_Command.get());
} catch (std::exception& e) {
utils::LOGE(utils::Format("[CommandSerializer::Deserializer] %s", e.what()));
return false;
}
return true;
}
CommandPtr& GetCommand() {
return m_Command;
}
DeclareAllCommand()
};
DataBuffer Serialize(const Command& a_Command) {
DataBuffer buffer;
Serializer serializer(buffer);
serializer.Serialize(a_Command);
return buffer;
}
std::shared_ptr<Command> Deserialize(DataBuffer& a_Data) {
CommandID commandId;
a_Data >> commandId;
if (commandId >= static_cast<CommandID>(CommandType::COMMAND_COUNT))
return nullptr;
CommandType commandType = CommandType(commandId);
// for double-dispatch
const CommandPtr& emptyCommand = CommandFactory::CreateReadOnlyCommand(commandType);
Deserializer deserializer(a_Data);
if (deserializer.Deserialize(emptyCommand)) {
CommandPtr command = std::move(deserializer.GetCommand());
return command;
}
return nullptr;
}
//---------------------------------------------
// Command serializer implementation
//----------------------------------------------
void Serializer::SerializeCommandData(const cdata::End& a_Command) {}
void Deserializer::DeserializeCommandData(cdata::End& a_Command) {}
void Serializer::SerializeCommandData(const cdata::PlaceTower& a_Command) {
m_Buffer << static_cast<std::uint8_t>((static_cast<std::uint8_t>(a_Command.m_Type) << 4 | a_Command.m_Placer & 0xF))
<< a_Command.m_Position;
}
void Deserializer::DeserializeCommandData(cdata::PlaceTower& a_Command) {
std::uint8_t union1;
m_Buffer >> union1 >> a_Command.m_Position;
a_Command.m_Type = sp::TowerType(union1 >> 4);
a_Command.m_Placer = union1 & 0xF;
}
void Serializer::SerializeCommandData(const cdata::PlayerJoin& a_Command) {
m_Buffer << a_Command.m_ID << a_Command.m_Name;
}
void Deserializer::DeserializeCommandData(cdata::PlayerJoin& a_Command) {
m_Buffer >> a_Command.m_ID >> a_Command.m_Name;
}
void Serializer::SerializeCommandData(const cdata::SpawnTroop& a_Command) {
m_Buffer << static_cast<std::uint8_t>(static_cast<std::uint8_t>(a_Command.m_Type) << 3 | a_Command.m_Level & 0x7)
<< a_Command.m_Position << a_Command.m_Sender;
}
void Deserializer::DeserializeCommandData(cdata::SpawnTroop& a_Command) {
std::uint8_t union1;
m_Buffer >> union1 >> a_Command.m_Position >> a_Command.m_Sender;
a_Command.m_Type = sp::EntityType(union1 >> 3);
a_Command.m_Level = union1 & 0x7;
}
void Serializer::SerializeCommandData(const cdata::TeamChange& a_Command) {
m_Buffer << static_cast<std::uint8_t>(a_Command.m_Player << 1 | static_cast<std::uint8_t>(a_Command.m_NewTeam));
}
void Deserializer::DeserializeCommandData(cdata::TeamChange& a_Command) {
std::uint8_t union1;
m_Buffer >> union1;
a_Command.m_Player = union1 >> 1;
a_Command.m_NewTeam = sp::Team(union1 & 1);
}
void Serializer::SerializeCommandData(const cdata::UpgradeTower& a_Command) {
m_Buffer << static_cast<std::uint16_t>(a_Command.m_Tower << 4 | a_Command.m_Upgrade & 0xF);
}
void Deserializer::DeserializeCommandData(cdata::UpgradeTower& a_Command) {
std::uint16_t union1;
m_Buffer >> union1;
a_Command.m_Tower = union1 >> 4;
a_Command.m_Upgrade = union1 & 0xF;
}
void Serializer::SerializeCommandData(const cdata::UseItem& a_Command) {
m_Buffer << static_cast<std::uint8_t>(static_cast<std::uint8_t>(a_Command.m_Item) << 4 | a_Command.m_User & 0xF)
<< a_Command.m_Position;
}
void Deserializer::DeserializeCommandData(cdata::UseItem& a_Command) {
std::uint8_t union1;
m_Buffer >> union1 >> a_Command.m_Position;
a_Command.m_Item = sp::ShopItem(union1 >> 4);
a_Command.m_User = union1 & 0xF;
}
} // namespace CommandSerializer
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,11 @@
#include <sp/protocol/command/CommandVisitor.h>
namespace sp {
namespace protocol {
void CommandVisitor::Check(const Command& a_Command) {
a_Command.Accept(*this);
}
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,18 @@
#define SP_INSTANCIATE_COMMANDS
#include <sp/protocol/command/Commands.h>
#include <sp/protocol/command/CommandVisitor.h>
namespace sp {
namespace protocol {
template <CommandType CT, typename Data>
commands::ConcreteCommand<CT, Data>::ConcreteCommand(const CommandDataType& a_Data) : m_Data(a_Data) {}
template <CommandType CT, typename Data>
void commands::ConcreteCommand<CT, Data>::Accept(CommandVisitor& a_Visitor) const {
a_Visitor.Visit(*this);
}
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,26 @@
#include <sp/protocol/packet/PacketFactory.h>
#include <array>
#include <cassert>
#include <functional>
namespace sp {
namespace protocol {
namespace PacketFactory {
using PacketCreator = std::function<std::unique_ptr<Packet>()>;
#define DeclarePacket(PacketName, ...) std::make_unique<packets::PacketName>(),
static std::array<std::unique_ptr<Packet>, static_cast<std::size_t>(PacketType::PACKET_COUNT)> Packets = {
DeclareAllPacket()
};
const std::unique_ptr<Packet>& CreateReadOnlyPacket(PacketType a_Type) {
assert(a_Type < PacketType::PACKET_COUNT);
return Packets[static_cast<std::size_t>(a_Type)];
}
} // namespace PacketFactory
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,262 @@
#include <sp/protocol/packet/PacketSerializer.h>
#include <sp/protocol/command/CommandSerializer.h>
#include <sp/protocol/packet/PacketFactory.h>
#include <sp/protocol/packet/PacketVisitor.h>
#include <sp/misc/Format.h>
#include <sp/misc/Log.h>
namespace sp {
namespace protocol {
namespace PacketSerializer {
#define DeclarePacket(PacketName, ...) \
void Visit(const packets::PacketName& a_Packet) override { \
const auto& packetData = a_Packet.m_Data; \
SerializePacketData(packetData); \
} \
\
void SerializePacketData(const packets::PacketName::PacketDataType& a_Packet);
class Serializer : public PacketVisitor {
private:
DataBuffer& m_Buffer;
public:
Serializer(DataBuffer& a_Buffer) : m_Buffer(a_Buffer) {}
void Serialize(const Packet& a_Packet) {
m_Buffer << static_cast<PacketID>(a_Packet.GetType());
Check(a_Packet);
}
DeclareAllPacket()
};
#undef DeclarePacket
#define DeclarePacket(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:
DataBuffer& m_Buffer;
PacketPtr m_Packet;
public:
Deserializer(DataBuffer& a_Buffer) : m_Buffer(a_Buffer) {}
bool Deserialize(const PacketPtr& a_Packet) {
try {
Check(*a_Packet.get());
} catch (std::exception& e) {
utils::LOGE(utils::Format("[PacketSerializer::Deserializer] %s", e.what()));
return false;
}
return true;
}
PacketPtr& GetPacket() {
return m_Packet;
}
DeclareAllPacket()
};
DataBuffer Serialize(const Packet& a_Packet) {
DataBuffer buffer;
Serializer serializer(buffer);
serializer.Serialize(a_Packet);
return buffer;
}
std::unique_ptr<Packet> Deserialize(DataBuffer& a_Data) {
PacketID packetId;
a_Data >> packetId;
if (packetId >= static_cast<PacketID>(PacketType::PACKET_COUNT))
return nullptr;
PacketType packetType = PacketType(packetId);
// for double-dispatch
const PacketPtr& emptyPacket = PacketFactory::CreateReadOnlyPacket(packetType);
Deserializer deserializer(a_Data);
if (deserializer.Deserialize(emptyPacket)) {
PacketPtr packet = std::move(deserializer.GetPacket());
return packet;
}
return nullptr;
}
//---------------------------------------------
// Packet serializer implementation
//----------------------------------------------
void Serializer::SerializePacketData(const pdata::PlayerLogin& a_Packet) {
m_Buffer << a_Packet.m_PlayerName;
}
void Deserializer::DeserializePacketData(pdata::PlayerLogin& a_Packet) {
m_Buffer >> a_Packet.m_PlayerName;
}
void Serializer::SerializePacketData(const pdata::LoggingSuccess& a_Packet) {
m_Buffer << a_Packet.m_PlayerId;
}
void Deserializer::DeserializePacketData(pdata::LoggingSuccess& a_Packet) {
m_Buffer >> a_Packet.m_PlayerId;
}
void Serializer::SerializePacketData(const pdata::PlayerJoin& a_Packet) {
m_Buffer << a_Packet.m_Player;
}
void Deserializer::DeserializePacketData(pdata::PlayerJoin& a_Packet) {
m_Buffer >> a_Packet.m_Player;
}
void Serializer::SerializePacketData(const pdata::PlayerLeave& a_Packet) {
m_Buffer << a_Packet.m_PlayerId;
}
void Deserializer::DeserializePacketData(pdata::PlayerLeave& a_Packet) {
m_Buffer >> a_Packet.m_PlayerId;
}
void Serializer::SerializePacketData(const pdata::KeepAlive& a_Packet) {
m_Buffer << a_Packet.m_KeepAliveId;
}
void Deserializer::DeserializePacketData(pdata::KeepAlive& a_Packet) {
m_Buffer >> a_Packet.m_KeepAliveId;
}
void Serializer::SerializePacketData(const pdata::Disconnect& a_Packet) {
m_Buffer << a_Packet.m_Reason;
}
void Deserializer::DeserializePacketData(pdata::Disconnect& a_Packet) {
m_Buffer >> a_Packet.m_Reason;
}
void Serializer::SerializePacketData(const pdata::ChatMessage& a_Packet) {
m_Buffer << a_Packet.m_Text;
}
void Deserializer::DeserializePacketData(pdata::ChatMessage& a_Packet) {
m_Buffer >> a_Packet.m_Text;
}
void Serializer::SerializePacketData(const pdata::LockSteps& a_Packet) {
m_Buffer << a_Packet.m_FirstFrameNumber;
for (int i = 0; i < LOCKSTEP_BUFFER_SIZE; i++) {
auto& lockStep = a_Packet.m_LockSteps[i];
m_Buffer << VarInt{lockStep.size()};
for (int j = 0; j < lockStep.size(); i++) {
auto command = lockStep[j];
m_Buffer << CommandSerializer::Serialize(*command);
}
}
}
void Deserializer::DeserializePacketData(pdata::LockSteps& a_Packet) {
m_Buffer >> a_Packet.m_FirstFrameNumber;
for (int i = 0; i < LOCKSTEP_BUFFER_SIZE; i++) {
VarInt lockStepSize;
m_Buffer >> lockStepSize;
for (std::size_t j = 0; j < lockStepSize.GetValue(); i++) {
auto command = CommandSerializer::Deserialize(m_Buffer);
if (command) {
a_Packet.m_LockSteps[i].push_back(command);
} else {
throw std::runtime_error("Failed to deserialise command");
}
}
}
}
void Serializer::SerializePacketData(const pdata::BeginGame& a_Packet) {
m_Buffer << a_Packet.m_Map << a_Packet.m_BlueTeam << a_Packet.m_RedTeam << a_Packet.m_Map;
}
void Deserializer::DeserializePacketData(pdata::BeginGame& a_Packet) {
m_Buffer >> a_Packet.m_Map >> a_Packet.m_BlueTeam >> a_Packet.m_RedTeam >> a_Packet.m_Map;
}
} // namespace PacketSerializer
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,11 @@
#include <sp/protocol/packet/PacketVisitor.h>
namespace sp {
namespace protocol {
void PacketVisitor::Check(const Packet& a_Packet) {
a_Packet.Accept(*this);
}
} // namespace protocol
} // namespace sp

View File

@@ -0,0 +1,23 @@
#define SP_INSTANCIATE_PACKETS
#include <sp/protocol/packet/Packets.h>
#include <sp/protocol/packet/PacketVisitor.h>
namespace sp {
namespace protocol {
template <PacketType PT, typename Data>
packets::ConcretePacket<PT, Data>::ConcretePacket(const PacketDataType& a_Data) : m_Data(a_Data) {}
template <PacketType PT, typename Data>
void packets::ConcretePacket<PT, Data>::Accept(PacketVisitor& a_Visitor) const {
a_Visitor.Visit(*this);
}
#define DeclarePacket(PacketName, packetSendType, packetSenderType) \
static_assert(static_cast<unsigned>(PacketSendType::packetSendType) && static_cast<unsigned>(PacketSenderType::packetSenderType));
DeclareAllPacket()
} // namespace protocol
} // namespace sp