]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Registry: remove per-item post-initialization
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Mar 2016 03:13:41 +0000 (14:13 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 22 Mar 2016 03:13:41 +0000 (14:13 +1100)
qcsrc/common/minigames/cl_minigames.qh
qcsrc/common/minigames/sv_minigames.qh
qcsrc/common/mutators/mutator/buffs/all.qh
qcsrc/lib/registry.qh

index 596d9204c96c30aad48b72101421584aed9464a9..e3c7df18f34f778c58f1ba6d911d4711a6367d7e 100644 (file)
@@ -120,7 +120,7 @@ REGISTRY_CHECK(Minigames)
     void name##_hud_board(vector, vector); \
     void name##_hud_status(vector, vector); \
     int name##_client_event(entity, string, ...); \
-    REGISTER_INIT_POST(MINIGAME_##name) { \
+    REGISTER_INIT(MINIGAME_##name) { \
         this.netname = strzone(strtolower(#name)); \
         this.message = nicename; \
         this.minigame_hud_board = name##_hud_board; \
index ecef028560062a64b672032eb12087c53c76c609..1e00fd1b3be536a4360454b967532724857db03d 100644 (file)
@@ -53,7 +53,7 @@ REGISTRY_CHECK(Minigames)
 #define REGISTER_MINIGAME(name,nicename) \
     REGISTER(Minigames, MINIGAME_##name, m_id, new_pure(minigame_descriptor)); \
     int name##_server_event(entity, string, ...); \
-    REGISTER_INIT_POST(MINIGAME_##name) { \
+    REGISTER_INIT(MINIGAME_##name) { \
         this.netname = strzone(strtolower(#name)); \
         this.message = nicename; \
                this.minigame_event = name##_server_event; \
index b45cb0621d87b85918358ada79411cf54905fdac..8e1319b39bdcfeb16e6b7f164735b773f7a71fde 100644 (file)
@@ -13,13 +13,7 @@ REGISTER_REGISTRY(Buffs)
 REGISTRY_CHECK(Buffs)
 
 #define REGISTER_BUFF(id) \
-    REGISTER(Buffs, BUFF_##id, m_id, NEW(Buff)); \
-    REGISTER_INIT_POST(BUFF_##id) { \
-        this.netname = this.m_name; \
-        this.m_itemid = BIT(this.m_id - 1); \
-        this.m_sprite = strzone(strcat("buff-", this.m_name)); \
-    } \
-    REGISTER_INIT(BUFF_##id)
+    REGISTER(Buffs, BUFF_##id, m_id, NEW(Buff))
 
 #include <common/items/item/pickup.qh>
 CLASS(Buff, Pickup)
@@ -39,6 +33,14 @@ CLASS(Buff, Pickup)
 #endif
 ENDCLASS(Buff)
 
+STATIC_INIT(REGISTER_BUFFS) {
+    FOREACH(Buffs, true, {
+        it.netname = it.m_name; \
+        it.m_itemid = BIT(it.m_id - 1); \
+        it.m_sprite = strzone(strcat("buff-", it.m_name)); \
+    });
+}
+
 #ifdef SVQC
        // .int buffs = _STAT(BUFFS);
        void buff_Init(entity ent);
index 434473a862147d46fc5676fce61631b409106fc7..2b96cf7c4655316047e2d9d44d6f2526c42c6999 100644 (file)
@@ -51,8 +51,7 @@ REGISTRY(Registries, BITS(8))
  * Must be followed by a semicolon or a function body with a `this` parameter.
  * Wrapper macros may perform actions after user initialization like so:
  *     #define REGISTER_FOO(id) \
- *         REGISTER(Foos, FOO, id, m_id, NEW(Foo)); \
- *         REGISTER_INIT_POST(FOO, id) { \
+ *         REGISTER(Foos, FOO, id, m_id, NEW(Foo)) { \
  *             print("Registering foo #", this.m_id + 1, "\n"); \
  *         } \
  *         REGISTER_INIT(FOO, id)
@@ -70,7 +69,6 @@ REGISTRY(Registries, BITS(8))
 #define REGISTER_4(registry, id, fld, inst) \
        entity id; \
        REGISTER_INIT(id) {} \
-       REGISTER_INIT_POST(id) {} \
        void Register_##id() \
        { \
                if (registry##_COUNT >= registry##_MAX) LOG_FATALF("Registry capacity exceeded (%d)", registry##_MAX); \
@@ -78,7 +76,6 @@ REGISTRY(Registries, BITS(8))
                this.registered_id = #id; \
                REGISTRY_PUSH(registry, fld, this); \
                Register_##id##_init(this); \
-               Register_##id##_init_post(this); \
        } \
        ACCUMULATE_FUNCTION(_Register##registry, Register_##id) \
        REGISTER_INIT(id)
@@ -99,7 +96,6 @@ REGISTRY(Registries, BITS(8))
 } MACRO_END
 
 #define REGISTER_INIT(id) [[accumulate]] void Register_##id##_init(entity this)
-#define REGISTER_INIT_POST(id) [[accumulate]] void Register_##id##_init_post(entity this)
 
 /** internal next pointer */
 #define REGISTRY_NEXT enemy