1 | #ifndef TRAITS_H__ |
1 | #ifndef TRAITS_H__ |
2 | #define TRAITS_H__ |
2 | #define TRAITS_H__ |
3 | |
3 | |
|
|
4 | #include <inttypes.h> |
|
|
5 | |
|
|
6 | typedef int8_t sint8; |
|
|
7 | typedef uint8_t uint8; |
|
|
8 | typedef int16_t sint16; |
|
|
9 | typedef uint16_t uint16; |
|
|
10 | typedef int32_t sint32; |
|
|
11 | typedef uint32_t uint32; |
|
|
12 | typedef int64_t sint64; |
|
|
13 | typedef uint64_t uint64; |
|
|
14 | |
|
|
15 | struct client_container; |
4 | struct client; |
16 | struct client; |
5 | struct player; |
17 | struct player; |
6 | struct object; |
18 | struct object; |
7 | struct maptile; |
19 | struct maptile; |
|
|
20 | struct mapspace; |
8 | struct archetype; |
21 | struct archetype; |
9 | struct region; |
22 | struct region; |
10 | struct party; |
23 | struct party; |
11 | struct treasurelist; |
24 | struct treasurelist; |
12 | |
25 | |
… | |
… | |
19 | DT_INT, |
32 | DT_INT, |
20 | DT_INT64, |
33 | DT_INT64, |
21 | DT_DOUBLE, |
34 | DT_DOUBLE, |
22 | DT_STRING, // 0-terminated string |
35 | DT_STRING, // 0-terminated string |
23 | DT_DATA, // string + length |
36 | DT_DATA, // string + length |
|
|
37 | DT_ATTACHABLE, // will go |
24 | DT_OBJECT, |
38 | DT_OBJECT, |
25 | DT_MAP, |
39 | DT_MAP, |
26 | DT_CLIENT, |
40 | DT_CLIENT, |
27 | DT_PLAYER, |
41 | DT_PLAYER, |
28 | DT_ARCH, |
42 | DT_ARCH, |
… | |
… | |
30 | DT_REGION, |
44 | DT_REGION, |
31 | |
45 | |
32 | NUM_DATA_TYPES |
46 | NUM_DATA_TYPES |
33 | }; |
47 | }; |
34 | |
48 | |
35 | template<typename T> |
|
|
36 | struct cftype { }; |
|
|
37 | |
|
|
38 | template<> |
|
|
39 | struct cftype<int> { |
|
|
40 | static const data_type dt = DT_INT; |
|
|
41 | }; |
|
|
42 | |
|
|
43 | template<> |
|
|
44 | struct cftype<sint64> { |
|
|
45 | static const data_type dt = DT_INT64; |
|
|
46 | }; |
|
|
47 | |
|
|
48 | template<> |
|
|
49 | struct cftype<double> { |
|
|
50 | static const data_type dt = DT_DOUBLE; |
|
|
51 | }; |
|
|
52 | |
|
|
53 | template<> |
|
|
54 | struct cftype<const char *> { |
|
|
55 | static const data_type dt = DT_STRING; |
|
|
56 | }; |
|
|
57 | |
|
|
58 | template<> |
|
|
59 | struct cftype<object> { |
|
|
60 | static const data_type dt = DT_OBJECT; |
|
|
61 | }; |
|
|
62 | |
|
|
63 | template<> |
|
|
64 | struct cftype<client> { |
|
|
65 | static const data_type dt = DT_CLIENT; |
|
|
66 | }; |
|
|
67 | |
|
|
68 | template<> |
|
|
69 | struct cftype<player> { |
|
|
70 | static const data_type dt = DT_PLAYER; |
|
|
71 | }; |
|
|
72 | |
|
|
73 | template<> |
|
|
74 | struct cftype<maptile> { |
|
|
75 | static const data_type dt = DT_MAP; |
|
|
76 | }; |
|
|
77 | |
|
|
78 | template<> |
|
|
79 | struct cftype<archetype> { |
|
|
80 | static const data_type dt = DT_ARCH; |
|
|
81 | }; |
|
|
82 | |
|
|
83 | template<> |
|
|
84 | struct cftype<party> { |
|
|
85 | static const data_type dt = DT_PARTY; |
|
|
86 | }; |
|
|
87 | |
|
|
88 | template<> |
|
|
89 | struct cftype<region> { |
|
|
90 | static const data_type dt = DT_REGION; |
|
|
91 | }; |
|
|
92 | |
|
|
93 | template<> |
|
|
94 | struct cftype<treasurelist> { |
|
|
95 | static const data_type dt = DT_REGION; |
|
|
96 | }; |
|
|
97 | |
|
|
98 | #endif |
49 | #endif |
99 | |
50 | |