X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Funsafe.qh;h=60ad3d88da517e11174910a1a1d5da29085b5b15;hb=52cdd440f6cfdc9544099ac68455e5361ace00d2;hp=6b4db2f1ac2a27bbac257bcda3a47f9a921ff5ec;hpb=023844a2ef8e9cc9d68d685183805c9f137d7974;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/unsafe.qh b/qcsrc/lib/unsafe.qh index 6b4db2f1a..60ad3d88d 100644 --- a/qcsrc/lib/unsafe.qh +++ b/qcsrc/lib/unsafe.qh @@ -1,14 +1,16 @@ -#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); } +#define X(T) \ + T _unsafe_cast_##T(int dummy, ...) { return ...(0, T); } \ + USING(T##_fld, .T); T##_fld _unsafe_cast_##T##_fld(int dummy, ...) { return ...(0, T##_fld); } X(bool) X(int) X(float) +X(vector) X(entity) X(string) -typedef float(...) rawfunc; +USING(rawfunc, float(...)); X(rawfunc) #undef X @@ -26,4 +28,4 @@ STATIC_INIT(INTEGER_ONE) INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1); } -#endif +#define ARRAY_INDEX(T, arr, idx) (reinterpret_cast(T##_fld, reinterpret_cast(int, arr[0]) + FTOI(idx)))