]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/unsafe.qh
Merge branch 'master' into Mirio/balance
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / unsafe.qh
index f8fa38280dd709742bf96fc99c07cfb2be31a5b4..97e1c7958493f1c5ba6caa3403c7b9ea9e84020d 100644 (file)
@@ -1,15 +1,26 @@
-#ifndef UNSAFE_H
-#define UNSAFE_H
+#pragma once
 
 #define reinterpret_cast(T, it) _unsafe_cast_##T(0, it)
 #define X(T) T _unsafe_cast_##T(int dummy, ...) { return ...(0, T); }
+X(bool)
+X(int)
 X(float)
 X(entity)
 X(string)
-typedef float(...) rawfunc;
+USING(rawfunc, float(...));
 X(rawfunc)
 #undef X
 
-#define strid(s) etof(reinterpret_cast(entity, s))
+#define _strid(s) ITOF(reinterpret_cast(int, s))
+#define strid(s) stof(sprintf("%i", s))
 
-#endif
+.int _unsafe_fld1, _unsafe_fld2;
+int INTEGER_ONE;
+
+#define FTOI(f) ((f) * INTEGER_ONE)
+#define ITOF(i) ((i) / INTEGER_ONE)
+
+STATIC_INIT(INTEGER_ONE)
+{
+    INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1);
+}