]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blob - qcsrc/lib/unsafe.qh
Merge branch 'master' into terencehill/menu_optimization
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / unsafe.qh
1 #ifndef UNSAFE_H
2 #define UNSAFE_H
3
4 #define reinterpret_cast(T, it) _unsafe_cast_##T(0, it)
5 #define X(T) T _unsafe_cast_##T(int dummy, ...) { return ...(0, T); }
6 X(bool)
7 X(int)
8 X(float)
9 X(entity)
10 X(string)
11 typedef float(...) rawfunc;
12 X(rawfunc)
13 #undef X
14
15 #define _strid(s) ITOF(reinterpret_cast(int, s))
16 #define strid(s) stof(sprintf("%i", s))
17
18 .int _unsafe_fld1, _unsafe_fld2;
19 int INTEGER_ONE;
20
21 #define FTOI(f) ((f) * INTEGER_ONE)
22 #define ITOF(i) ((i) / INTEGER_ONE)
23
24 STATIC_INIT(INTEGER_ONE)
25 {
26     INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1);
27 }
28
29 #endif