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.2 by root, Thu Aug 31 17:54:14 2006 UTC vs.
Revision 1.5 by root, Thu Dec 14 05:09:32 2006 UTC

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

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines