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