improve packet interface
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
#pragma once
|
||||
|
||||
#include <string>
|
||||
#include <blitz/protocol/PacketData.h>
|
||||
#include <blitz/protocol/PacketDeclare.h>
|
||||
#include <string>
|
||||
|
||||
namespace blitz {
|
||||
namespace protocol {
|
||||
@@ -64,7 +65,7 @@ template <PacketType PT, typename Data>
|
||||
class ConcretePacket : public Packet {
|
||||
public:
|
||||
using PacketDataType = Data;
|
||||
|
||||
|
||||
PacketDataType m_Data;
|
||||
|
||||
ConcretePacket(const PacketDataType& a_Data = {});
|
||||
@@ -87,33 +88,16 @@ class ConcretePacket : public Packet {
|
||||
// before including this file
|
||||
// if you want to instantiate templates
|
||||
#ifdef BLITZ_INSTANCIATE_PACKETS
|
||||
#define DeclarePacket(Type) \
|
||||
using Type = ConcretePacket<PacketType::Type, data::Type>; \
|
||||
template class ConcretePacket<PacketType::Type, data::Type>
|
||||
#define DeclarePacket(PacketName, ...) \
|
||||
using PacketName = ConcretePacket<PacketType::PacketName, data::PacketName>; \
|
||||
template class ConcretePacket<PacketType::PacketName, data::PacketName>
|
||||
#else
|
||||
#define DeclarePacket(Type) using Type = ConcretePacket<PacketType::Type, data::Type>
|
||||
#define DeclarePacket(PacketName, ...) using PacketName = ConcretePacket<PacketType::PacketName, data::PacketName>
|
||||
#endif
|
||||
|
||||
DeclareAllPacket()
|
||||
|
||||
|
||||
|
||||
|
||||
DeclarePacket(PlayerLogin);
|
||||
DeclarePacket(UpdateHealth);
|
||||
DeclarePacket(LoggingSuccess);
|
||||
DeclarePacket(PlayerDeath);
|
||||
DeclarePacket(PlayerJoin);
|
||||
DeclarePacket(PlayerLeave);
|
||||
DeclarePacket(PlayerStats);
|
||||
DeclarePacket(PlayerList);
|
||||
DeclarePacket(ServerConfig);
|
||||
DeclarePacket(ServerTps);
|
||||
DeclarePacket(UpdateGameState);
|
||||
DeclarePacket(KeepAlive);
|
||||
DeclarePacket(Disconnect);
|
||||
DeclarePacket(ChatMessage);
|
||||
DeclarePacket(PlayerPositionAndRotation);
|
||||
DeclarePacket(PlayerShoot);
|
||||
#undef DeclarePacket
|
||||
|
||||
} // namespace packets
|
||||
|
||||
|
||||
Reference in New Issue
Block a user