From 83532988dbc1ef4ea96afb9975c1872dba3494ad Mon Sep 17 00:00:00 2001 From: mrb0nk500 Date: Thu, 2 Mar 2023 15:29:37 -0400 Subject: TMenuList, TPlyGuildCardTag: Actually match both classes Didn't realize that `TMenuList`'s `operator=` was actually implicit. --- context.h | 56 +++++++++++++++++++++++++----------------- include/pso/TMenuList.h | 45 ++++++++++++++++++--------------- include/pso/TPlyGuildCardTag.h | 11 +++++++-- src/pso/TPlyGuildCardTag.cpp | 12 ++++----- 4 files changed, 74 insertions(+), 50 deletions(-) diff --git a/context.h b/context.h index b268acf..cf894ab 100644 --- a/context.h +++ b/context.h @@ -334,7 +334,15 @@ class TMenuListEntry : public TPlyGuildCardTag { T entry; void bswap(); - TMenuListEntry &operator=(const TMenuListEntry &src); + void assign(const TMenuListEntry &src); + + TMenuListEntry &operator=(const TMenuListEntry &src) { + _assign(src); + return *this; + }; + + private: + void _assign(const TMenuListEntry &src); } __packed__; template @@ -345,7 +353,7 @@ class TMenuList { TArray, num_entries> entries; void bswap(); - TMenuList &operator=(const TMenuList &src); + TMenuList &assign(const TMenuList &src); } __packed__; template @@ -355,7 +363,7 @@ class TMenuList { TArray, num_entries> entries; void bswap(); - TMenuList &operator=(const TMenuList &src); + TMenuList &assign(const TMenuList &src); } __packed__; template @@ -365,7 +373,7 @@ class TMenuList { TArray, num_pad_entries> pad_entries; void bswap(); - TMenuList &operator=(const TMenuList &src); + TMenuList &assign(const TMenuList &src); } __packed__; @@ -407,36 +415,33 @@ void TMenuListEntry::bswap() { } template -TMenuList &TMenuList::operator=(const TMenuList &src) { - header = src.header; - entries = src.entries; +TMenuList &TMenuList::assign(const TMenuList &src) { + *this = src; return *this; } template -TMenuList &TMenuList::operator=(const TMenuList &src) { - header = src.header; - pad_entries = src.pad_entries; +TMenuList &TMenuList::assign(const TMenuList &src) { + *this = src; return *this; } template -TMenuList &TMenuList::operator=(const TMenuList &src) { - header = src.header; - if (num_pad_entries) { - pad_entries = src.pad_entries; - } - if (num_entries) { - entries = src.entries; - } +TMenuList &TMenuList::assign(const TMenuList &src) { + *this = src; return *this; } template -TMenuListEntry &TMenuListEntry::operator=(const TMenuListEntry &src) { +void TMenuListEntry::_assign(const TMenuListEntry &src) { + TPlyGuildCardTag::assign(src); + entry = src.entry; +} + +template +void TMenuListEntry::assign(const TMenuListEntry &src) { TPlyGuildCardTag::operator=(src); entry = src.entry; - return *this; } // TMainTask.cpp @@ -618,14 +623,21 @@ static inline void operator|=(object_flags &a, object_flags b) { a = a | b; }; class TPlyGuildCardTag { public: - TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src); void bswap(); + void assign(const TPlyGuildCardTag &src); + void assign(const TPlyGuildCardTag *src); PRIVATE_MEMBER_ACCESSORS(gc_tag, tag); PRIVATE_MEMBER_ACCESSORS(u32, tag_u32); PRIVATE_MEMBER_ACCESSORS(u32, guildcard_number); - private: + void _assign(const TPlyGuildCardTag &src) { + m_tag.tag0 = src.tag().tag0; + m_tag.tag1 = src.tag().tag1; + m_tag.tag2 = src.tag().tag2; + m_guildcard_number = src.guildcard_number(); + }; + union { gc_tag m_tag; u32 m_tag_u32; diff --git a/include/pso/TMenuList.h b/include/pso/TMenuList.h index 0eb35e5..54ca441 100644 --- a/include/pso/TMenuList.h +++ b/include/pso/TMenuList.h @@ -14,7 +14,15 @@ class TMenuListEntry : public TPlyGuildCardTag { T entry; void bswap(); - TMenuListEntry &operator=(const TMenuListEntry &src); + void assign(const TMenuListEntry &src); + + TMenuListEntry &operator=(const TMenuListEntry &src) { + _assign(src); + return *this; + }; + + private: + void _assign(const TMenuListEntry &src); } __packed__; template @@ -25,7 +33,7 @@ class TMenuList { TArray, num_entries> entries; void bswap(); - TMenuList &operator=(const TMenuList &src); + TMenuList &assign(const TMenuList &src); } __packed__; template @@ -35,7 +43,7 @@ class TMenuList { TArray, num_entries> entries; void bswap(); - TMenuList &operator=(const TMenuList &src); + TMenuList &assign(const TMenuList &src); } __packed__; template @@ -45,7 +53,7 @@ class TMenuList { TArray, num_pad_entries> pad_entries; void bswap(); - TMenuList &operator=(const TMenuList &src); + TMenuList &assign(const TMenuList &src); } __packed__; @@ -87,36 +95,33 @@ void TMenuListEntry::bswap() { } template -TMenuList &TMenuList::operator=(const TMenuList &src) { - header = src.header; - entries = src.entries; +TMenuList &TMenuList::assign(const TMenuList &src) { + *this = src; return *this; } template -TMenuList &TMenuList::operator=(const TMenuList &src) { - header = src.header; - pad_entries = src.pad_entries; +TMenuList &TMenuList::assign(const TMenuList &src) { + *this = src; return *this; } template -TMenuList &TMenuList::operator=(const TMenuList &src) { - header = src.header; - if (num_pad_entries) { - pad_entries = src.pad_entries; - } - if (num_entries) { - entries = src.entries; - } +TMenuList &TMenuList::assign(const TMenuList &src) { + *this = src; return *this; } template -TMenuListEntry &TMenuListEntry::operator=(const TMenuListEntry &src) { +void TMenuListEntry::_assign(const TMenuListEntry &src) { + TPlyGuildCardTag::assign(src); + entry = src.entry; +} + +template +void TMenuListEntry::assign(const TMenuListEntry &src) { TPlyGuildCardTag::operator=(src); entry = src.entry; - return *this; } #endif diff --git a/include/pso/TPlyGuildCardTag.h b/include/pso/TPlyGuildCardTag.h index 57c30c5..f10b8e4 100644 --- a/include/pso/TPlyGuildCardTag.h +++ b/include/pso/TPlyGuildCardTag.h @@ -13,14 +13,21 @@ struct gc_tag { class TPlyGuildCardTag { public: - TPlyGuildCardTag &operator=(const TPlyGuildCardTag &src); void bswap(); + void assign(const TPlyGuildCardTag &src); + void assign(const TPlyGuildCardTag *src); PRIVATE_MEMBER_ACCESSORS(gc_tag, tag); PRIVATE_MEMBER_ACCESSORS(u32, tag_u32); PRIVATE_MEMBER_ACCESSORS(u32, guildcard_number); - private: + void _assign(const TPlyGuildCardTag &src) { + m_tag.tag0 = src.tag().tag0; + m_tag.tag1 = src.tag().tag1; + m_tag.tag2 = src.tag().tag2; + m_guildcard_number = src.guildcard_number(); + }; + union { gc_tag m_tag; u32 m_tag_u32; diff --git a/src/pso/TPlyGuildCardTag.cpp b/src/pso/TPlyGuildCardTag.cpp index 61bed28..d1341c5 100644 --- a/src/pso/TPlyGuildCardTag.cpp +++ b/src/pso/TPlyGuildCardTag.cpp @@ -7,10 +7,10 @@ void TPlyGuildCardTag::bswap() { bswap_16(&m_tag.tag2); } -TPlyGuildCardTag &TPlyGuildCardTag::operator=(const TPlyGuildCardTag &src) { - 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; +void TPlyGuildCardTag::assign(const TPlyGuildCardTag &src) { + _assign(src); +} + +void TPlyGuildCardTag::assign(const TPlyGuildCardTag *src) { + _assign(*src); } -- cgit v1.2.3-13-gbd6f