From: TimePath Date: Sun, 1 Nov 2015 11:10:56 +0000 (+1100) Subject: lib: etof and ftoe X-Git-Tag: xonotic-v0.8.2~1743 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=3f01af4a3f5d694062231a5ab86aea9f22ce0142;p=xonotic%2Fxonotic-data.pk3dir.git lib: etof and ftoe --- diff --git a/qcsrc/lib/misc.qh b/qcsrc/lib/misc.qh index db7819b8c..e0ac0a478 100644 --- a/qcsrc/lib/misc.qh +++ b/qcsrc/lib/misc.qh @@ -23,6 +23,20 @@ #define OVERLOAD(F, ...) OVERLOAD_(F,##__VA_ARGS__)(__VA_ARGS__) #endif +#if defined(CSQC) + #define etof(e) num_for_edict(e) + #define ftoe(i) entitybyindex(i) +#elif defined(SVQC) + #define etof(e) num_for_edict(e) + #define ftoe(i) edict_num(i) +#elif defined(MENUQC) + // already defined +#endif + +#undef etof +// avoid bounds checks +#define etof(e) stof(sprintf("%i", e)) + #define GET(name) name##get #define GETTER(type, name) type GET(name)() { return name; } #define PROPERTY(type, name) type name; GETTER(type, name)