From 7add9178473b74f5a922997d93bbca7d09e6a5c5 Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 2 Mar 2023 15:25:43 -0400 Subject: TPlyGuildCardTag: Make variable members private, and add accessors for them --- context.h | 24 +++++++++++++++++++----- include/pso/TPlyGuildCardTag.h | 27 +++++++++++++++++---------- src/pso/TPlyGuildCardTag.cpp | 12 ++++++------ 3 files changed, 42 insertions(+), 21 deletions(-) diff --git a/context.h b/context.h index fb4b418..b268acf 100644 --- a/context.h +++ b/context.h @@ -534,6 +534,13 @@ struct packet_header { void bswap(); } __packed__; +// pso/TPlyGuildCardTag.h +struct gc_tag { + u8 tag0; + u8 tag1; + u16 tag2; +}; + // TTcpSocket.cpp, but they're really from AVE-TCP struct at_ip4_opt { u8 ttl; @@ -610,13 +617,20 @@ static inline void operator|=(object_flags &a, object_flags b) { a = a | b; }; // Class defs. class TPlyGuildCardTag { - public: - u8 tag0; - u8 tag1; - u16 tag2; - u32 guildcard_number; +public: TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src); void bswap(); + + PRIVATE_MEMBER_ACCESSORS(gc_tag, tag); + PRIVATE_MEMBER_ACCESSORS(u32, tag_u32); + PRIVATE_MEMBER_ACCESSORS(u32, guildcard_number); + +private: + union { + gc_tag m_tag; + u32 m_tag_u32; + }; + u32 m_guildcard_number; } __packed__; // pso/PSOV3EncryptionTCP.h diff --git a/include/pso/TPlyGuildCardTag.h b/include/pso/TPlyGuildCardTag.h index a29e977..57c30c5 100644 --- a/include/pso/TPlyGuildCardTag.h +++ b/include/pso/TPlyGuildCardTag.h @@ -5,19 +5,26 @@ #include "pso/macros.h" #include +struct gc_tag { + u8 tag0; + u8 tag1; + u16 tag2; +}; + class TPlyGuildCardTag { public: - union { - struct { - u8 tag0; - u8 tag1; - u16 tag2; - } tag; - u32 tag_u32; - }; - u32 guildcard_number; - TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src); void bswap(); + + PRIVATE_MEMBER_ACCESSORS(gc_tag, tag); + PRIVATE_MEMBER_ACCESSORS(u32, tag_u32); + PRIVATE_MEMBER_ACCESSORS(u32, guildcard_number); + +private: + union { + gc_tag m_tag; + u32 m_tag_u32; + }; + u32 m_guildcard_number; } __packed__; #endif diff --git a/src/pso/TPlyGuildCardTag.cpp b/src/pso/TPlyGuildCardTag.cpp index e874485..61bed28 100644 --- a/src/pso/TPlyGuildCardTag.cpp +++ b/src/pso/TPlyGuildCardTag.cpp @@ -3,14 +3,14 @@ #include void TPlyGuildCardTag::bswap() { - bswap_32(&guildcard_number); - bswap_16(&tag.tag2); + bswap_32(&m_guildcard_number); + bswap_16(&m_tag.tag2); } TPlyGuildCardTag &TPlyGuildCardTag::operator=(const TPlyGuildCardTag &src) { - tag.tag0 = src.tag.tag0; - tag.tag1 = src.tag.tag1; - tag.tag2 = src.tag.tag2; - guildcard_number = src.guildcard_number; + m_tag.tag0 = src.tag().tag0; + m_tag.tag1 = src.tag().tag1; + m_tag.tag2 = src.tag().tag2; + m_guildcard_number = src.guildcard_number(); return *this; } -- cgit v1.2.3-13-gbd6f