]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Adjust item definition syntax
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 11 Aug 2015 01:27:31 +0000 (11:27 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 11 Aug 2015 01:27:31 +0000 (11:27 +1000)
qcsrc/common/items/item.qh
qcsrc/common/items/item/ammo.qc
qcsrc/common/items/item/armor.qc
qcsrc/common/items/item/buff.qc
qcsrc/common/items/item/health.qc
qcsrc/common/items/item/jetpack.qc
qcsrc/common/items/item/powerup.qc
qcsrc/server/mutators/mutator_instagib_items.qc

index 354bed2ba74ed2e24498a9f62c1a2d18c20a5ca6..43231cc1f10b8426b0a5cb2bb9b5040de99472ae 100644 (file)
@@ -14,13 +14,14 @@ int ITEM_COUNT;
 /** If you register a new item, make sure to add it to all.inc */
 #define REGISTER_ITEM(id, class, body)          \
     entity ITEM_##id;                           \
+    void RegisterItems_init_##id(entity this) { body } \
     void RegisterItems_##id() {                 \
-        const entity this = NEW(class);         \
+        entity this = NEW(class);               \
         ITEM_##id = this;                       \
         this.m_id = ITEM_COUNT;                 \
         ITEMS[ITEM_COUNT++] = this;             \
-        body                                    \
+        RegisterItems_init_##id(this);          \
     }                                           \
-    ACCUMULATE_FUNCTION(RegisterItems, RegisterItems_##id)
-
+    ACCUMULATE_FUNCTION(RegisterItems, RegisterItems_##id) \
+    [[accumulate]] void RegisterItems_init_##id(entity this)
 #endif
index 032fcc3feaaca2c43187d1815d0691f92241c12a..276e6bbe6310d1c083ea28669ae82602e24a203a 100644 (file)
@@ -5,65 +5,64 @@
 
 #define WITH(it) this.m_##it;
 #define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...)                                                 \
+#define DEFINE(id)                                                      \
     REGISTER_ITEM(id, Ammo, LAMBDA(                                     \
         IF(SV, CONFIGURE                                                \
         ,   respawntime         =       GET(g_pickup_respawntime_ammo)  \
         ,   respawntimejitter   = GET(g_pickup_respawntimejitter_ammo)  \
         )                                                               \
-        UNWORDS(__VA_ARGS__)                                            \
     ))
 
-DEFINE(Bullets
-    ,APPLY(CONFIGURE
+DEFINE(Bullets) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/a_bullets.mdl"
     ,   name                =   "bullets"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   2000
     ,   itemid              =   IT_NAILS
     )
-)
-DEFINE(Cells
-    ,APPLY(CONFIGURE
+}
+DEFINE(Cells) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/a_cells.md3"
     ,   name                =   "cells"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   2000
     ,   itemid              =   IT_CELLS
     )
-)
-DEFINE(Plasma
-    ,APPLY(CONFIGURE
+}
+DEFINE(Plasma) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/a_cells.md3"
     ,   name                =   "plasma"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   2000
     ,   itemid              =   IT_PLASMA
     )
-)
-DEFINE(Rockets
-    ,APPLY(CONFIGURE
+}
+DEFINE(Rockets) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/a_rockets.md3"
     ,   name                =   "rockets"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   3000
     ,   itemid              =   IT_ROCKETS
     )
-)
-DEFINE(Shells
-    ,APPLY(CONFIGURE
+}
+DEFINE(Shells) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/a_shells.md3"
     ,   name                =   "shells"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   500
     ,   itemid              =   IT_SHELLS
     )
-)
+}
 
 #undef WITH
 #undef CONFIGURE
index 8fed098ac190f5b7229fb94a1961f8368ddd852b..295ff117ede61ba415595a536af0f3942ddab511 100644 (file)
@@ -5,63 +5,63 @@
 
 #define WITH(it) this.m_##it;
 #define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...) REGISTER_ITEM(id, Armor, UNWORDS(__VA_ARGS__))
+#define DEFINE(id) REGISTER_ITEM(id, Armor, )
 
-DEFINE(ArmorSmall
-    ,APPLY(CONFIGURE
+DEFINE(ArmorSmall) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/item_armor_small.md3"
     ,   sound               =   "misc/armor1.wav"
     ,   name                =   "5 Armor"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_LOW
     ,   itemid              =   IT_ARMOR_SHARD
     ,   respawntime         =         GET(g_pickup_respawntime_short)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_short)
     )
-)
+}
 
-DEFINE(ArmorMedium
-    ,APPLY(CONFIGURE
+DEFINE(ArmorMedium) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/item_armor_medium.md3"
     ,   sound               =   "misc/armor10.wav"
     ,   name                =   "25 Armor"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_MID
     ,   itemid              =   IT_ARMOR
     ,   respawntime         =         GET(g_pickup_respawntime_medium)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_medium)
     )
-)
+}
 
-DEFINE(ArmorBig
-    ,APPLY(CONFIGURE
+DEFINE(ArmorBig) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/item_armor_big.md3"
     ,   sound               =   "misc/armor17_5.wav"
     ,   name                =   "50 Armor"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH?
     ,   itemid              =   IT_ARMOR
     ,   respawntime         =         GET(g_pickup_respawntime_long)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_long)
     )
-)
+}
 
-DEFINE(ArmorLarge
-    ,APPLY(CONFIGURE
+DEFINE(ArmorLarge) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/item_armor_large.md3"
     ,   sound               =   "misc/armor25.wav"
     ,   name                =   "100 Armor"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_HIGH
     ,   itemid              =   IT_ARMOR
     ,   respawntime         =         GET(g_pickup_respawntime_long)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_long)
     )
-)
+}
 
 #undef WITH
 #undef CONFIGURE
index d9420d1c3ce44ea69d055e285c7e82e23a8a3945..27a9b9ecdfb14efa1b183edfd6cc2c0338bac24c 100644 (file)
@@ -1,3 +1,3 @@
 #include "buff.qh"
 
-REGISTER_ITEM(DefaultBuff, Buff, LAMBDA())
+REGISTER_ITEM(DefaultBuff, Buff, );
index 08b422de1efdfddcaef9badd716264813774bca5..bd055869094ae11c9888deae16efc14ebb7eb610 100644 (file)
@@ -5,63 +5,63 @@
 
 #define WITH(it) this.m_##it;
 #define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...) REGISTER_ITEM(id, Health, UNWORDS(__VA_ARGS__))
+#define DEFINE(id) REGISTER_ITEM(id, Health, )
 
-DEFINE(HealthSmall
-    ,APPLY(CONFIGURE
+DEFINE(HealthSmall)  {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_h1.md3"
     ,   sound               =   "misc/minihealth.wav"
     ,   name                =   "5 Health"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_LOW
     ,   itemid              =   IT_5HP
     ,   respawntime         =         GET(g_pickup_respawntime_short)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_short)
     )
-)
+}
 
-DEFINE(HealthMedium
-    ,APPLY(CONFIGURE
+DEFINE(HealthMedium) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_h25.md3"
     ,   sound               =   "misc/mediumhealth.wav"
     ,   name                =   "25 Health"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_MID
     ,   itemid              =   IT_25HP
     ,   respawntime         =         GET(g_pickup_respawntime_short)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_short)
     )
-)
+}
 
-DEFINE(HealthLarge
-    ,APPLY(CONFIGURE
+DEFINE(HealthLarge) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_h50.md3"
     ,   sound               =   "misc/mediumhealth.wav"
     ,   name                =   "50 Health"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_MID
     ,   itemid              =   IT_25HP
     ,   respawntime         =         GET(g_pickup_respawntime_medium)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_medium)
     )
-)
+}
 
-DEFINE(HealthMega
-    ,APPLY(CONFIGURE
+DEFINE(HealthMega) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_h100.md3"
     ,   sound               =   "misc/megahealth.wav"
     ,   name                =   "100 Health"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_HIGH
     ,   itemid              =   IT_HEALTH
     ,   respawntime         =         GET(g_pickup_respawntime_long)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_long)
     )
-)
+}
 
 #undef WITH
 #undef CONFIGURE
index 9ff4ed05cbcd344a30433c27a4b562a8717b16a5..45a256b1bbe4919876e2288a90ee9dd5b3467acc 100644 (file)
@@ -5,14 +5,14 @@
 
 #define WITH(it) this.m_##it;
 #define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...) REGISTER_ITEM(id, Pickup, UNWORDS(__VA_ARGS__))
+#define DEFINE(id) REGISTER_ITEM(id, Pickup, )
 
-DEFINE(Jetpack
-    ,APPLY(CONFIGURE
+DEFINE(Jetpack) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_jetpack.md3"
     ,   name                =   "Jet pack"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_LOW
     ,   itemflags           =   FL_POWERUP
     ,   itemid              =   IT_JETPACK
@@ -20,28 +20,28 @@ DEFINE(Jetpack
     ,   respawntime         =         GET(g_pickup_respawntime_powerup)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
     )
-)
+}
 
-DEFINE(JetpackFuel
-    ,APPLY(CONFIGURE
+DEFINE(JetpackFuel) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_fuel.md3"
     ,   name                =   "Fuel"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_LOW
     ,   itemid              =   IT_FUEL
     ,   pickupevalfunc      =   commodity_pickupevalfunc
     ,   respawntime         =         GET(g_pickup_respawntime_ammo)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_ammo)
     )
-)
+}
 
-DEFINE(JetpackRegen
-    ,APPLY(CONFIGURE
+DEFINE(JetpackRegen) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_fuelregen.md3"
     ,   name                =   "Fuel regenerator"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_LOW
     ,   itemflags           =   FL_POWERUP
     ,   itemid              =   IT_FUEL_REGEN
@@ -49,7 +49,7 @@ DEFINE(JetpackRegen
     ,   respawntime         =         GET(g_pickup_respawntime_powerup)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
     )
-)
+}
 
 #undef WITH
 #undef CONFIGURE
index f10a97e54ff8770b2660ecad293f5cc70d0a67b0..86e3a7d66b88a2782ce4273f09fa73ef80c7db22 100644 (file)
@@ -3,7 +3,7 @@
 
 #define WITH(it) this.m_##it;
 #define CONFIGURE(...) MAP(WITH, __VA_ARGS__)
-#define DEFINE(id, ...)                                                     \
+#define DEFINE(id)                                                          \
     REGISTER_ITEM(id, Ammo, LAMBDA(                                         \
         IF(SV, CONFIGURE                                                    \
         ,   botvalue            =   100000                                  \
         ,   respawntime         =         GET(g_pickup_respawntime_powerup) \
         ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup) \
         )                                                                   \
-        UNWORDS(__VA_ARGS__)                                          \
     ))
 
-DEFINE(Strength
-    ,APPLY(CONFIGURE
+DEFINE(Strength) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_strength.md3"
     ,   sound               =   "misc/powerup.wav"
     ,   name                =   "Strength Powerup"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   itemid              =   IT_STRENGTH
     )
-)
-DEFINE(Shield
-    ,APPLY(CONFIGURE
+}
+DEFINE(Shield) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_invincible.md3"
     ,   sound               =   "misc/powerup_shield.wav"
     ,   name                =   "Shield"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   itemid              =   IT_INVINCIBLE
     )
-)
+}
 
 #undef WITH
 #undef CONFIGURE
index 40340b172323926540cf91313ce7fa5f2d00f201..f2a0050e0ed77593994fa58a615710dc03189126 100644 (file)
@@ -8,34 +8,34 @@ float instagib_respawntimejitter_ammo = 0;
 GETTER(float, instagib_respawntime_ammo)
 GETTER(float, instagib_respawntimejitter_ammo)
 
-REGISTER_ITEM(VaporizerCells, Pickup, APPLY(UNWORDS
-    ,APPLY(CONFIGURE
+REGISTER_ITEM(VaporizerCells, Pickup, ) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/a_cells.md3"
     ,   sound               =   "misc/itempickup.wav"
     ,   name                =   "Vaporizer Ammo"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   100
     ,   itemid              =   IT_CELLS
     ,   respawntime         =         GET(instagib_respawntime_ammo)
     ,   respawntimejitter   =   GET(instagib_respawntimejitter_ammo)
     )
-))
+}
 
-REGISTER_ITEM(ExtraLife, Pickup, APPLY(UNWORDS
-    ,APPLY(CONFIGURE
+REGISTER_ITEM(ExtraLife, Pickup, ) {
+    APPLY(CONFIGURE
     ,   model               =   "models/items/g_h100.md3"
     ,   sound               =   "misc/megahealth.wav"
     ,   name                =   "Extralife"
     )
-    ,IF(SV, CONFIGURE
+    IF(SV, CONFIGURE
     ,   botvalue            =   BOT_PICKUP_RATING_HIGH
     ,   itemflags           =   FL_POWERUP
     ,   itemid              =   IT_NAILS
     ,   respawntime         =         GET(g_pickup_respawntime_powerup)
     ,   respawntimejitter   =   GET(g_pickup_respawntimejitter_powerup)
     )
-))
+}
 
 #undef WITH
 #undef CONFIGURE