summaryrefslogtreecommitdiff
path: root/include/pso/TMenuList.h
blob: d06562205e69c3e072961ca88369156c298f3d36 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
#ifndef TMENULIST_H
#define TMENULIST_H

#include "pso/forward.h"
#include "pso/protocol.h"
#include "pso/macros.h"
#include "pso/TArray.h"
#include "pso/TPlyGuildCardTag.h"
#include <global_types.h>

template <typename T>
class TMenuListEntry : public TPlyGuildCardTag {
public:
	TMenuListEntry() : TPlyGuildCardTag() {};

	void bswap() {
		TPlyGuildCardTag::bswap();
		entry.bswap();
	};
public:
	T entry;
} __packed__;

template <typename T, int num_entries, int num_pad_entries>
class TMenuList {
public:
	void bswap() {
		header.bswap();
		if (num_pad_entries) {
			for (int i = 0; i < num_pad_entries; i++) {
				pad_entries[i].bswap();
			}
		}
		if (num_entries) {
			for (int i = 0; i < num_entries; i++) {
				entries[i].bswap();
			}
		}
	};
public:
	packet_header header;
	TMenuListEntry<T> pad_entries[num_pad_entries];
	TMenuListEntry<T> entries[num_entries];
} __packed__;

template <typename T, int num_entries>
class TMenuList<T, num_entries, 0> {
public:
	void bswap() {
		header.bswap();
		for (int i = 0; i < num_entries; i++) {
			entries[i].bswap();
		}
	};
public:
	packet_header header;
	TMenuListEntry<T> entries[num_entries];
} __packed__;

template <typename T, int num_pad_entries>
class TMenuList<T, 0, num_pad_entries> {
public:
	void bswap() {
		header.bswap();
		for (int i = 0; i < num_pad_entries; i++) {
			pad_entries[i].bswap();
		}
	};
public:
	packet_header header;
	TMenuListEntry<T> pad_entries[num_pad_entries];
} __packed__;

#endif