]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/lib/registry.qh
Merge branch 'master' into TimePath/stats
[xonotic/xonotic-data.pk3dir.git] / qcsrc / lib / registry.qh
index 40a39395bcf34884e6d9b2610d6a2c108b295cab..f2bdd1e26199984910fd35f0384985ac593de4e7 100644 (file)
@@ -61,18 +61,28 @@ REGISTRY(Registries, BITS(8))
                if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%s)", ftos(registry##_MAX)); \
                entity this = id = inst; \
                this.registered_id = #id; \
-               this.fld = registry##_COUNT; \
-               _R_SET(_##registry, registry##_COUNT, this); \
-               ++registry##_COUNT; \
-               if (!registry##_first) registry##_first = this; \
-               if (registry##_last)   registry##_last.REGISTRY_NEXT = this; \
-               registry##_last = this; \
+               REGISTRY_PUSH(registry, fld, this); \
                Register_##id##_init(this); \
                Register_##id##_init_post(this); \
        } \
        ACCUMULATE_FUNCTION(Register##registry, Register_##id) \
        REGISTER_INIT(id)
 
+#define REGISTRY_PUSH(registry, fld, it) do { \
+       it.fld = registry##_COUNT; \
+       _R_SET(_##registry, registry##_COUNT, it); \
+       ++registry##_COUNT; \
+       if (!registry##_first) registry##_first = it; \
+       if (registry##_last)   registry##_last.REGISTRY_NEXT = it; \
+       registry##_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)
+
 #define REGISTER_INIT(id) [[accumulate]] void Register_##id##_init(entity this)
 #define REGISTER_INIT_POST(id) [[accumulate]] void Register_##id##_init_post(entity this)