]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/registry.qh
Objectify gametypes
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / registry.qh
index 0087c1bf71b77b69cf3513fcb0da62aa42017fed..3ce8c471e5442019462b7266fda6d347668b5a9e 100644 (file)
@@ -8,11 +8,15 @@
 #define REGISTER(initfunc, ns, array, counter, id, class, fld)  \
     entity ns##_##id;                                           \
     REGISTER_INIT(ns, id) { }                                   \
+    .entity enemy; /* internal next pointer */                  \
     void Register_##ns##_##id() {                               \
         entity this = NEW(class);                               \
         ns##_##id = this;                                       \
         this.fld = counter;                                     \
         array[counter++] = this;                                \
+        if (!array##_first)    array##_first = this;            \
+        if ( array##_last)     array##_last.enemy = this;       \
+        array##_last = this;                                    \
         Register_##ns##_##id##_init(this);                      \
     }                                                           \
     ACCUMULATE_FUNCTION(initfunc, Register_##ns##_##id)         \