enum class field access

This commit is contained in:
2025-02-18 19:33:02 +01:00
parent e16ad84865
commit 66835554f1
5 changed files with 20 additions and 8 deletions

View File

@@ -4,7 +4,7 @@
#include <sp/protocol/Field.h>
#include <sp/protocol/MessageBase.h>
enum DisconnectPacketFields {
enum class DisconnectFieldsE {
Reason = 0
};
@@ -15,6 +15,6 @@ DeclarePacket(Disconnect){
PacketConstructor(Disconnect)
const std::string& GetReason() const {
return GetField<Reason>();
return GetField<DisconnectFieldsE, DisconnectFieldsE::Reason>();
}
};

View File

@@ -4,9 +4,8 @@
#include <sp/protocol/Field.h>
#include <sp/protocol/MessageBase.h>
enum KeepAlivePacketFields {
enum class KeepAliveFieldsE {
KeepAliveId = 0,
TestAlignField = 1,
};
using KeepAliveFields = std::tuple<
@@ -18,6 +17,6 @@ DeclarePacket(KeepAlive){
PacketConstructor(KeepAlive)
std::uint64_t GetKeepAliveId() const {
return GetField<KeepAlive>();
return GetField<KeepAliveFieldsE, KeepAliveFieldsE::KeepAliveId>();
}
};

View File

@@ -4,7 +4,8 @@
#include <sp/protocol/Field.h>
#include <sp/protocol/MessageBase.h>
enum UpgradeTowerPacketFields {
enum class UpgradeTowerFieldsE {
m_Tower = 0,
m_Upgrade,
};
@@ -21,10 +22,10 @@ DeclarePacket(UpgradeTower){
PacketConstructor(UpgradeTower)
std::uint16_t GetTowerId() const {
return GetField<0>().GetField<m_Tower>();
return GetField<0>().GetField<UpgradeTowerFieldsE, UpgradeTowerFieldsE::m_Tower>();
}
std::uint8_t GetTowerUpgrade() const {
return GetField<0>().GetField<m_Upgrade>();
return GetField<0>().GetField<UpgradeTowerFieldsE, UpgradeTowerFieldsE::m_Upgrade>();
}
};