ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/include/traits.h
Revision: 1.32
Committed: Sat Nov 17 23:40:02 2018 UTC (5 years, 5 months ago) by root
Content type: text/plain
Branch: MAIN
CVS Tags: HEAD
Changes since 1.31: +1 -0 lines
Log Message:
copyright update 2018

File Contents

# Content
1 /*
2 * This file is part of Deliantra, the Roguelike Realtime MMORPG.
3 *
4 * Copyright (©) 2017,2018 Marc Alexander Lehmann / the Deliantra team
5 * Copyright (©) 2005,2006,2007,2008,2009,2010,2011,2012,2013,2014,2015,2016 Marc Alexander Lehmann / Robin Redeker / the Deliantra team
6 *
7 * Deliantra is free software: you can redistribute it and/or modify it under
8 * the terms of the Affero GNU General Public License as published by the
9 * Free Software Foundation, either version 3 of the License, or (at your
10 * option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the Affero GNU General Public License
18 * and the GNU General Public License along with this program. If not, see
19 * <http://www.gnu.org/licenses/>.
20 *
21 * The authors can be reached via e-mail to <support@deliantra.net>
22 */
23
24 /* define traits (actually just types at the moment) for basic types */
25
26 #ifndef TRAITS_H__
27 #define TRAITS_H__
28
29 #include <inttypes.h>
30
31 typedef int8_t sint8;
32 typedef uint8_t uint8;
33 typedef int16_t sint16;
34 typedef uint16_t uint16;
35 typedef int32_t sint32;
36 typedef uint32_t uint32;
37 typedef int64_t sint64;
38 typedef uint64_t uint64;
39
40 typedef uint32 weight_t;
41 typedef sint64 volume_t;
42 typedef uint32 tick_t;
43 typedef uint16 faceidx;
44
45 inline weight_t
46 weight_to_kg_approx (weight_t w)
47 {
48 // we divide by 1024, because otherwise we need a 64 bit multiply
49 return w >> 10;
50 }
51
52 const int sint32_digits = 11; // number of digits an sint32 uses max.
53 const int sint64_digits = 20;
54
55 typedef char *octet_string;
56 typedef char *utf8_string;
57 typedef char *any_string;
58 typedef const char *const_octet_string;
59 typedef const char *const_utf8_string;
60 typedef const char *const_any_string;
61
62 struct client_container;
63 struct client;
64 struct player;
65 struct object;
66 struct maptile;
67 struct mapspace;
68 struct archetype;
69 struct region;
70 struct party;
71 struct treasurelist;
72 struct random_map_params;
73 struct faceinfo;
74 struct mapxy;
75 struct materialtype_t;
76
77 typedef object object_ornull;
78 typedef maptile maptile_ornull;
79
80 // could have used templates, but a more traditional C api
81 // uses more explicit typing which is ok for this purpose.
82 enum data_type
83 {
84 DT_END, // no further arguments
85 DT_AV, // perl-only av that needs to be flattened out
86 DT_INT,
87 DT_INT64,
88 DT_DOUBLE,
89 DT_STRING, // 0-terminated string
90 DT_DATA, // string + length
91 DT_ATTACHABLE, // will go
92 DT_OBJECT,
93 DT_MAP,
94 DT_CLIENT,
95 DT_PLAYER,
96 DT_ARCH,
97 DT_PARTY,
98 DT_REGION,
99
100 NUM_DATA_TYPES
101 };
102
103 #endif
104