diff options
-rw-r--r-- | context.h | 26 | ||||
-rw-r--r-- | include/pso/TMenuList.h | 28 |
2 files changed, 18 insertions, 36 deletions
@@ -341,19 +341,18 @@ template <typename T, int num_entries, int num_pad_entries> class TMenuList { public: packet_header header; - TMenuListEntry<T> pad_entries[num_pad_entries]; - TMenuListEntry<T> entries[num_entries]; + TArray<TMenuListEntry<T>, num_pad_entries> pad_entries; + TArray<TMenuListEntry<T>, num_entries> entries; void bswap(); TMenuList &operator=(const TMenuList &src); - } __packed__; template <typename T, int num_entries> class TMenuList<T, num_entries, 0> { public: packet_header header; - TMenuListEntry<T> entries[num_entries]; + TArray<TMenuListEntry<T>, num_entries> entries; void bswap(); TMenuList &operator=(const TMenuList &src); @@ -363,7 +362,7 @@ template <typename T, int num_pad_entries> class TMenuList<T, 0, num_pad_entries> { public: packet_header header; - TMenuListEntry<T> pad_entries[num_pad_entries]; + TArray<TMenuListEntry<T>, num_pad_entries> pad_entries; void bswap(); TMenuList &operator=(const TMenuList &src); @@ -407,22 +406,17 @@ void TMenuListEntry<T>::bswap() { entry.bswap(); } - template <typename T, int num_entries> TMenuList<T, num_entries, 0> &TMenuList<T, num_entries, 0>::operator=(const TMenuList<T, num_entries, 0> &src) { header = src.header; - for (int i = 0; i < num_entries; i++) { - entries[i] = src.entries[i]; - } + entries = src.entries; return *this; } template <typename T, int num_pad_entries> TMenuList<T, 0, num_pad_entries> &TMenuList<T, 0, num_pad_entries>::operator=(const TMenuList<T, 0, num_pad_entries> &src) { header = src.header; - for (int i = 0; i < num_pad_entries; i++) { - pad_entries[i] = src.pad_entries[i]; - } + pad_entries = src.pad_entries; return *this; } @@ -430,14 +424,10 @@ template <typename T, int num_entries, int num_pad_entries> TMenuList<T, num_entries, num_pad_entries> &TMenuList<T, num_entries, num_pad_entries>::operator=(const TMenuList<T, num_entries, num_pad_entries> &src) { header = src.header; if (num_pad_entries) { - for (int i = 0; i < num_pad_entries; i++) { - pad_entries[i] = src.pad_entries[i]; - } + pad_entries = src.pad_entries; } if (num_entries) { - for (int i = 0; i < num_entries; i++) { - entries[i] = src.entries[i]; - } + entries = src.entries; } return *this; } diff --git a/include/pso/TMenuList.h b/include/pso/TMenuList.h index f792462..0eb35e5 100644 --- a/include/pso/TMenuList.h +++ b/include/pso/TMenuList.h @@ -4,6 +4,7 @@ #include "pso/forward.h" #include "pso/protocol.h" #include "pso/macros.h" +#include "pso/TArray.h" #include "pso/TPlyGuildCardTag.h" #include <global_types.h> @@ -20,19 +21,18 @@ template <typename T, int num_entries, int num_pad_entries> class TMenuList { public: packet_header header; - TMenuListEntry<T> pad_entries[num_pad_entries]; - TMenuListEntry<T> entries[num_entries]; + TArray<TMenuListEntry<T>, num_pad_entries> pad_entries; + TArray<TMenuListEntry<T>, num_entries> entries; void bswap(); TMenuList &operator=(const TMenuList &src); - } __packed__; template <typename T, int num_entries> class TMenuList<T, num_entries, 0> { public: packet_header header; - TMenuListEntry<T> entries[num_entries]; + TArray<TMenuListEntry<T>, num_entries> entries; void bswap(); TMenuList &operator=(const TMenuList &src); @@ -42,7 +42,7 @@ template <typename T, int num_pad_entries> class TMenuList<T, 0, num_pad_entries> { public: packet_header header; - TMenuListEntry<T> pad_entries[num_pad_entries]; + TArray<TMenuListEntry<T>, num_pad_entries> pad_entries; void bswap(); TMenuList &operator=(const TMenuList &src); @@ -86,22 +86,17 @@ void TMenuListEntry<T>::bswap() { entry.bswap(); } - template <typename T, int num_entries> TMenuList<T, num_entries, 0> &TMenuList<T, num_entries, 0>::operator=(const TMenuList<T, num_entries, 0> &src) { header = src.header; - for (int i = 0; i < num_entries; i++) { - entries[i] = src.entries[i]; - } + entries = src.entries; return *this; } template <typename T, int num_pad_entries> TMenuList<T, 0, num_pad_entries> &TMenuList<T, 0, num_pad_entries>::operator=(const TMenuList<T, 0, num_pad_entries> &src) { header = src.header; - for (int i = 0; i < num_pad_entries; i++) { - pad_entries[i] = src.pad_entries[i]; - } + pad_entries = src.pad_entries; return *this; } @@ -109,14 +104,10 @@ template <typename T, int num_entries, int num_pad_entries> TMenuList<T, num_entries, num_pad_entries> &TMenuList<T, num_entries, num_pad_entries>::operator=(const TMenuList<T, num_entries, num_pad_entries> &src) { header = src.header; if (num_pad_entries) { - for (int i = 0; i < num_pad_entries; i++) { - pad_entries[i] = src.pad_entries[i]; - } + pad_entries = src.pad_entries; } if (num_entries) { - for (int i = 0; i < num_entries; i++) { - entries[i] = src.entries[i]; - } + entries = src.entries; } return *this; } @@ -127,4 +118,5 @@ TMenuListEntry<T> &TMenuListEntry<T>::operator=(const TMenuListEntry<T> &src) { entry = src.entry; return *this; } + #endif |