ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/traits.h
(Generate patch)

Comparing deliantra/server/include/traits.h (file contents):
Revision 1.1 by root, Thu Aug 31 09:19:34 2006 UTC vs.
Revision 1.8 by root, Wed Dec 20 09:14:22 2006 UTC

1#ifndef TRAITS_H__ 1#ifndef TRAITS_H__
2#define TRAITS_H__ 2#define TRAITS_H__
3 3
4struct client_container;
5struct client;
4struct pl; 6struct player;
5struct object; 7struct object;
6struct mapstruct; 8struct maptile;
7struct archt; 9struct archetype;
8struct region; 10struct region;
9struct party; 11struct party;
10struct mapstruct; 12struct treasurelist;
11 13
12// could have used templates, but a more traditional C api 14// could have used templates, but a more traditional C api
13// uses more explicit typing which is ok for this purpose. 15// uses more explicit typing which is ok for this purpose.
14enum data_type 16enum data_type
15{ 17{
20 DT_DOUBLE, 22 DT_DOUBLE,
21 DT_STRING, // 0-terminated string 23 DT_STRING, // 0-terminated string
22 DT_DATA, // string + length 24 DT_DATA, // string + length
23 DT_OBJECT, 25 DT_OBJECT,
24 DT_MAP, 26 DT_MAP,
27 DT_CLIENT,
25 DT_PLAYER, 28 DT_PLAYER,
26 DT_ARCH, 29 DT_ARCH,
27 DT_PARTY, 30 DT_PARTY,
28 DT_REGION, 31 DT_REGION,
29 32
33template<typename T> 36template<typename T>
34struct cftype { }; 37struct cftype { };
35 38
36template<> 39template<>
37struct cftype<int> { 40struct cftype<int> {
38 enum { dt = DT_INT }; 41 static const data_type dt = DT_INT;
39}; 42};
40 43
41template<> 44template<>
42struct cftype<sint64> { 45struct cftype<sint64> {
43 enum { dt = DT_INT64 }; 46 static const data_type dt = DT_INT64;
44}; 47};
45 48
46template<> 49template<>
47struct cftype<double> { 50struct cftype<double> {
48 enum { dt = DT_DOUBLE }; 51 static const data_type dt = DT_DOUBLE;
49}; 52};
50 53
51template<> 54template<>
52struct cftype<const char *> { 55struct cftype<const char *> {
53 enum { dt = DT_STRING }; 56 static const data_type dt = DT_STRING;
54}; 57};
55 58
56template<> 59template<>
57struct cftype<object> { 60struct cftype<object> {
58 enum { dt = DT_OBJECT }; 61 static const data_type dt = DT_OBJECT;
59}; 62};
60 63
61template<> 64template<>
62struct cftype<struct pl> { 65struct cftype<client> {
63 enum { dt = DT_PLAYER }; 66 static const data_type dt = DT_CLIENT;
64}; 67};
65 68
66template<> 69template<>
67struct cftype<mapstruct> { 70struct cftype<player> {
68 enum { dt = DT_MAP }; 71 static const data_type dt = DT_PLAYER;
69}; 72};
70 73
71template<> 74template<>
75struct cftype<maptile> {
76 static const data_type dt = DT_MAP;
77};
78
79template<>
72struct cftype<struct archt> { 80struct cftype<archetype> {
73 enum { dt = DT_ARCH }; 81 static const data_type dt = DT_ARCH;
74}; 82};
75 83
76template<> 84template<>
77struct cftype<party> { 85struct cftype<party> {
78 enum { dt = DT_PARTY }; 86 static const data_type dt = DT_PARTY;
79}; 87};
80 88
81template<> 89template<>
82struct cftype<region> { 90struct cftype<region> {
83 enum { dt = DT_REGION }; 91 static const data_type dt = DT_REGION;
92};
93
94template<>
95struct cftype<treasurelist> {
96 static const data_type dt = DT_REGION;
84}; 97};
85 98
86#endif 99#endif
87 100

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines