better fields access
This commit is contained in:
@@ -4,10 +4,15 @@
|
||||
#include <sp/protocol/Field.h>
|
||||
#include <sp/protocol/MessageBase.h>
|
||||
|
||||
enum DisconnectPacketFields {
|
||||
Reason = 0
|
||||
};
|
||||
enum DisconnectPacketFields { Reason = 0 };
|
||||
|
||||
using DisconnectFields = std::tuple<std::string /*Reason*/>;
|
||||
|
||||
DeclarePacket(Disconnect);
|
||||
DeclarePacket(Disconnect){
|
||||
public:
|
||||
PacketConstructor(Disconnect)
|
||||
|
||||
const std::string& GetReason() const {
|
||||
return GetField<Reason>();
|
||||
}
|
||||
};
|
||||
|
||||
@@ -10,11 +10,26 @@ enum KeepAlivePacketFields {
|
||||
};
|
||||
|
||||
using KeepAliveFields = std::tuple<
|
||||
std::uint64_t, //<- KeepAliveId
|
||||
std::uint64_t, //<- KeepAliveId
|
||||
sp::BitField<std::uint16_t,
|
||||
sp::Field<std::uint16_t, 12>, //<- m_Tower
|
||||
sp::Field<std::uint8_t, 4> //<- m_Upgrade
|
||||
>
|
||||
>;
|
||||
sp::Field<std::uint16_t, 12>, //<- m_Tower
|
||||
sp::Field<std::uint8_t, 4> //<- m_Upgrade
|
||||
>
|
||||
>;
|
||||
|
||||
DeclarePacket(KeepAlive);
|
||||
DeclarePacket(KeepAlive){
|
||||
public:
|
||||
PacketConstructor(KeepAlive)
|
||||
|
||||
std::uint64_t GetKeepAliveId() const {
|
||||
return GetField<KeepAlive>();
|
||||
}
|
||||
|
||||
std::uint16_t GetTowerId() const {
|
||||
return GetField<TestAlignField>().GetField<0>();
|
||||
}
|
||||
|
||||
std::uint8_t GetTowerUpgrade() const {
|
||||
return GetField<TestAlignField>().GetField<1>();
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user