]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/registry.qh
Stats: port vectors
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / registry.qh
index 59ddf25ff87ee30c627f14fc4cfd25b4ec23b072..8ad8be56e213f7704276f9b3e77dd2b479181aa5 100644 (file)
                entity this = inst; \
                ns##_##id = this; \
                this.registered_id = #id; \
-               this.fld = array##_COUNT; \
-               _##array[array##_COUNT++] = this; \
-               if (!array##_first) array##_first = this; \
-               if (array##_last)   array##_last.REGISTRY_NEXT = this; \
-               array##_last = this; \
+               REGISTRY_PUSH(array, fld, this); \
                Register_##ns##_##id##_init(this); \
                Register_##ns##_##id##_init_post(this); \
        } \
        ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id) \
        REGISTER_INIT(ns, id)
 
+#define REGISTRY_PUSH(array, fld, it) do { \
+       it.fld = array##_COUNT; \
+       _##array[array##_COUNT++] = it; \
+       if (!array##_first) array##_first = it; \
+       if (array##_last)   array##_last.REGISTRY_NEXT = it; \
+       array##_last = it; \
+} while (0)
+
+#define REGISTRY_RESERVE(registry, fld, id, suffix) do { \
+       entity e = new(registry_reserved); \
+       e.registered_id = #id #suffix; \
+       REGISTRY_PUSH(registry, fld, e); \
+} while (0)
+
 /** internal next pointer */
 #define REGISTRY_NEXT enemy
 .entity REGISTRY_NEXT;