]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/common/util-pre.qh
Reclaim the `new` keyword for entity classes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util-pre.qh
1 #ifndef UTIL_PRE_H
2 #define UTIL_PRE_H
3
4 #ifndef NOCOMPAT
5     #define COMPAT_NO_MOD_IS_XONOTIC
6 #endif
7
8 #ifndef QCC_SUPPORT_ACCUMULATE
9     #ifdef GMQCC
10         #define QCC_SUPPORT_ACCUMULATE
11     #endif
12 #endif
13
14 #ifndef QCC_SUPPORT_NIL
15     #ifdef GMQCC
16         #define QCC_SUPPORT_NIL
17     #endif
18 #endif
19
20 #ifndef QCC_SUPPORT_INT
21     #define int float
22
23     #define stoi(s) stof(s)
24     #define stob(s) stof(s)
25     #define itos(i) ftos(i)
26 #else
27     #define stoi(s) ((int) stof(s))
28     #define stob(s) ((bool) stof(s))
29     #define itos(i) ftos(i)
30 #endif
31
32 #ifndef QCC_SUPPORT_BOOL
33     #define bool float
34
35     // Boolean Constants
36     const int true      = 1;
37     const int false = 0;
38 #endif
39
40 #ifndef QCC_SUPPORT_ENTITYCLASS
41     #define entityclass(name) typedef entity name
42     #define class(name)
43     #define new(class) spawn()
44 #else
45     #define entityclass(name) entityclass name {}
46     #define class(name) [[class(name)]]
47     #define new(class) ((class) spawn())
48 #endif
49
50 // Transitional aliases
51 [[deprecated("use true")]] [[alias("true")]] const bool TRUE;
52 [[deprecated("use false")]] [[alias("false")]] const bool FALSE;
53
54 #endif