]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/util-pre.qh
Merge branch 'master' into terencehill/slider_anim_improvements
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / util-pre.qh
index 053261b10efac17e04a7bc79acc356751c8e23d4..fc916d4dba37a17b182ee007f5ff9e21927a078a 100644 (file)
     const int false = 0;
 #endif
 
-#ifndef QCC_SUPPORT_ENTITYCLASS
-    #define entityclass(name) typedef entity name
-    #define class(name)
-    #define new(class) spawn()
-#else
-    #define entityclass(name) entityclass name {}
-    #define class(name) [[class(name)]]
-    #define new(class) ((class) spawn())
-#endif
-
 // Transitional aliases
 [[deprecated("use true")]] [[alias("true")]] const bool TRUE;
 [[deprecated("use false")]] [[alias("false")]] const bool FALSE;
 
+#define FOREACH_ARRAY(arr, start, end, cond, body) do { \
+    for (int i = start; i < end; ++i) {                 \
+        const noref entity it = arr[i];                 \
+        if (cond) { body }                              \
+    }                                                   \
+} while(0)
+
+#define FOREACH_LIST(list, next, cond, body) do {               \
+    noref int i = 0;                                            \
+    for (entity it = list##_first; it; (it = it.next, ++i)) {   \
+        if (cond) { body }                                      \
+    }                                                           \
+} while(0)
+
+#define FOREACH(list, cond, body) FOREACH_LIST(list, enemy, cond, body)
+
 #ifdef GMQCC
     #define OVERLOAD(F, ...) F##_##__VA_COUNT__(__VA_ARGS__)
 #else
 
 #define IDENTITY(it) it
 
+#define UNWORDS(...) MAP(IDENTITY, __VA_ARGS__)
+
+#define APPLY(f, ...) f(__VA_ARGS__)
+
 #ifdef SVQC
     #define SV(f, ...) f(__VA_ARGS__)
 #else
     #define CL(f, ...)
 #endif
 
-#define ALL(f, ...) f(__VA_ARGS__)
+#define IF(cond, f, ...) cond(f, __VA_ARGS__)
 
-#define IF(pred, f, ...) pred(f, __VA_ARGS__)
+#define GET(name) name##get
+#define GETTER(type, name) type GET(name)() { return name; }
 
 #define BIT(n) (1 << (n))
 #ifndef BRANCHLESS_BITSET
     #define BITSET(var, mask, flag) ((var) ^ (-(flag) ^ (var)) & (mask))
 #endif
 
+#define CVAR_DESCRIBE(var, desc)    localcmd(sprintf("\nset %s \"%s\" \"%s\"\n",        #var, ftos(autocvar_##var), desc))
+#define CVAR_DESCRIBESTR(var, desc) localcmd(sprintf("\nset %s \"%s\" \"%s\"\n",        #var, autocvar_##var, desc))
+#define CVAR_DESCRIBEVEC(var, desc) localcmd(sprintf("\nset %s \"%s %s %s\" \"%s\"\n",  #var, ftos(autocvar_##var##.x), ftos(autocvar_##var##.y), ftos(autocvar_##var##.z), desc))
+
 #endif