]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/registry.qh
Objectify buffs
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / registry.qh
index c87d7184cd2c47d176e1f59b154d1bae82e35616..3bf8f40992325a8c90873b5fe64c9ac20518eadc 100644 (file)
@@ -1,19 +1,28 @@
 #ifndef REGISTRY_H
 #define REGISTRY_H
 
+#include "oo.qh"
+
 #define REGISTER_INIT(ns, id) [[accumulate]] void Register_##ns##_##id##_init(entity this)
+#define REGISTER_INIT_POST(ns, id) [[accumulate]] void Register_##ns##_##id##_init_post(entity this)
 
 #define REGISTER(initfunc, ns, array, counter, id, class, fld)  \
     entity ns##_##id;                                           \
     REGISTER_INIT(ns, id) { }                                   \
+    REGISTER_INIT_POST(ns, id) { }                              \
     void Register_##ns##_##id() {                               \
         entity this = NEW(class);                               \
         ns##_##id = this;                                       \
-        this.fld = ns##_COUNT;                                  \
+        this.fld = counter;                                     \
         array[counter++] = this;                                \
         Register_##ns##_##id##_init(this);                      \
+        Register_##ns##_##id##_init_post(this);                 \
     }                                                           \
     ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id)         \
     REGISTER_INIT(ns, id)
 
+void __static_init() { }
+#define static_init() CALL_ACCUMULATED_FUNCTION(__static_init)
+#define REGISTER_REGISTRY(func) ACCUMULATE_FUNCTION(__static_init, func)
+
 #endif