]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
lib: etof and ftoe
authorTimePath <andrew.hardaker1995@gmail.com>
Sun, 1 Nov 2015 11:10:56 +0000 (22:10 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sun, 1 Nov 2015 11:10:56 +0000 (22:10 +1100)
qcsrc/lib/misc.qh

index db7819b8cec056a7df0be4d9569dd4848aee0744..e0ac0a478074b6778ab39b34ecf4e069e8c2d979 100644 (file)
        #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)