]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/mutators/mutator/buffs/all.qh
Cleanup server mutators: remove IMPLEMENTATION macro
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / mutators / mutator / buffs / all.qh
index d34d32d071ef10f42c1d9f26ec12d6e8ff4a130e..79117c95a811f852ac7e6a6eb3ef8b29b3464486 100644 (file)
@@ -1,9 +1,5 @@
 #ifndef BUFFS_ALL_H
 #define BUFFS_ALL_H
-// Welcome to the stuff behind the scenes
-// Below, you will find the list of buffs
-// Add new buffs here!
-// Note: Buffs also need spawnfuncs, which are set below
 
 #include <common/teams.qh>
 #include <common/util.qh>
 REGISTER_WAYPOINT(Buff, _("Buff"), '1 0.5 0', 1);
 REGISTER_RADARICON(Buff, 1);
 
-REGISTRY(Buffs, BITS(4))
+REGISTRY(Buffs, BITS(5))
 #define Buffs_from(i) _Buffs_from(i, BUFF_Null)
 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)
        /** bit index */
-       ATTRIB(Buff, m_itemid, int, 0)
-       ATTRIB(Buff, m_name, string, "buff")
-       ATTRIB(Buff, m_color, vector, '1 1 1')
-       ATTRIB(Buff, m_prettyName, string, "Buff")
-       ATTRIB(Buff, m_skin, int, 0)
-       ATTRIB(Buff, m_sprite, string, "")
+       ATTRIB(Buff, m_itemid, int, 0);
+       ATTRIB(Buff, m_name, string, "buff");
+       ATTRIB(Buff, m_color, vector, '1 1 1');
+       ATTRIB(Buff, m_prettyName, string, "Buff");
+       ATTRIB(Buff, m_skin, int, 0);
+       ATTRIB(Buff, m_sprite, string, "");
        METHOD(Buff, display, void(entity this, void(string name, string icon) returns)) {
                returns(this.m_prettyName, sprintf("/gfx/hud/%s/buff_%s", cvar_string("menu_skin"), this.m_name));
        }
@@ -43,14 +33,22 @@ 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);
        void buff_Init_Compat(entity ent, entity replacement);
        #define BUFF_SPAWNFUNC(e, b, t) spawnfunc(item_buff_##e) { \
-               self.buffs = b.m_itemid; \
-               self.team = t; \
-               buff_Init(self); \
+               this.buffs = b.m_itemid; \
+               this.team = t; \
+               buff_Init(this); \
        }
        #define BUFF_SPAWNFUNCS(e, b)                       \
                        BUFF_SPAWNFUNC(e,           b,  0)          \
@@ -58,7 +56,7 @@ ENDCLASS(Buff)
                        BUFF_SPAWNFUNC(e##_team2,   b,  NUM_TEAM_2) \
                        BUFF_SPAWNFUNC(e##_team3,   b,  NUM_TEAM_3) \
                        BUFF_SPAWNFUNC(e##_team4,   b,  NUM_TEAM_4)
-       #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(self, r); }
+       #define BUFF_SPAWNFUNC_Q3TA_COMPAT(o, r) spawnfunc(item_##o) { buff_Init_Compat(this, r); }
 #else
        #define BUFF_SPAWNFUNC(e, b, t)
        #define BUFF_SPAWNFUNCS(e, b)