From a740a503e89958fb5e06e27c2a46da62c43d03cc Mon Sep 17 00:00:00 2001 From: Persson-dev Date: Wed, 21 Aug 2024 12:28:40 +0200 Subject: [PATCH] add packet declare syntax check --- include/blitz/protocol/PacketDeclare.h | 8 +++++++- src/blitz/protocol/Packets.cpp | 4 ++++ 2 files changed, 11 insertions(+), 1 deletion(-) diff --git a/include/blitz/protocol/PacketDeclare.h b/include/blitz/protocol/PacketDeclare.h index 101671c..dd19355 100644 --- a/include/blitz/protocol/PacketDeclare.h +++ b/include/blitz/protocol/PacketDeclare.h @@ -14,13 +14,19 @@ namespace protocol { */ enum class PacketSenderType { /** Sent by clients and server */ - Both, + Both = 1, /** Sent by clients to the server */ Client, /** Sent by server to the clients */ Server, }; +enum class PacketSendType { + Reliable = 1, + Unreliable, + UnreliableOrdered, +}; + /** * \def DeclareAllPacket diff --git a/src/blitz/protocol/Packets.cpp b/src/blitz/protocol/Packets.cpp index 84913b0..38fdeeb 100644 --- a/src/blitz/protocol/Packets.cpp +++ b/src/blitz/protocol/Packets.cpp @@ -14,5 +14,9 @@ void packets::ConcretePacket::Accept(PacketVisitor& a_Visitor) const { a_Visitor.Visit(*this); } +#define DeclarePacket(PacketName, packetSendType, packetSenderType) static_assert(static_cast(PacketSendType::packetSendType) && static_cast(PacketSenderType::packetSenderType)); + +DeclareAllPacket() + } // namespace protocol } // namespace blitz