X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Flib%2Funsafe.qh;h=60ad3d88da517e11174910a1a1d5da29085b5b15;hb=5f3fd912090c6369e5be3451f24fbef724264e06;hp=97e1c7958493f1c5ba6caa3403c7b9ea9e84020d;hpb=d271f27a5ac351a3a7b39636932f6d661492be1d;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/lib/unsafe.qh b/qcsrc/lib/unsafe.qh index 97e1c7958..60ad3d88d 100644 --- a/qcsrc/lib/unsafe.qh +++ b/qcsrc/lib/unsafe.qh @@ -1,10 +1,13 @@ #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) USING(rawfunc, float(...)); @@ -24,3 +27,5 @@ STATIC_INIT(INTEGER_ONE) { INTEGER_ONE = reinterpret_cast(int, _unsafe_fld2) - reinterpret_cast(int, _unsafe_fld1); } + +#define ARRAY_INDEX(T, arr, idx) (reinterpret_cast(T##_fld, reinterpret_cast(int, arr[0]) + FTOI(idx)))