From bdf78c0b56764a84f9261ab04e76241e2a1d836d Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 11 Aug 2015 11:27:31 +1000 Subject: [PATCH] Adjust item definition syntax --- qcsrc/common/items/item.qh | 9 ++-- qcsrc/common/items/item/ammo.qc | 43 +++++++++---------- qcsrc/common/items/item/armor.qc | 34 +++++++-------- qcsrc/common/items/item/buff.qc | 2 +- qcsrc/common/items/item/health.qc | 34 +++++++-------- qcsrc/common/items/item/jetpack.qc | 26 +++++------ qcsrc/common/items/item/powerup.qc | 19 ++++---- .../server/mutators/mutator_instagib_items.qc | 16 +++---- 8 files changed, 91 insertions(+), 92 deletions(-) diff --git a/qcsrc/common/items/item.qh b/qcsrc/common/items/item.qh index 354bed2ba..43231cc1f 100644 --- a/qcsrc/common/items/item.qh +++ b/qcsrc/common/items/item.qh @@ -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 diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc index 032fcc3fe..276e6bbe6 100644 --- a/qcsrc/common/items/item/ammo.qc +++ b/qcsrc/common/items/item/ammo.qc @@ -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 diff --git a/qcsrc/common/items/item/armor.qc b/qcsrc/common/items/item/armor.qc index 8fed098ac..295ff117e 100644 --- a/qcsrc/common/items/item/armor.qc +++ b/qcsrc/common/items/item/armor.qc @@ -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 diff --git a/qcsrc/common/items/item/buff.qc b/qcsrc/common/items/item/buff.qc index d9420d1c3..27a9b9ecd 100644 --- a/qcsrc/common/items/item/buff.qc +++ b/qcsrc/common/items/item/buff.qc @@ -1,3 +1,3 @@ #include "buff.qh" -REGISTER_ITEM(DefaultBuff, Buff, LAMBDA()) +REGISTER_ITEM(DefaultBuff, Buff, ); diff --git a/qcsrc/common/items/item/health.qc b/qcsrc/common/items/item/health.qc index 08b422de1..bd0558690 100644 --- a/qcsrc/common/items/item/health.qc +++ b/qcsrc/common/items/item/health.qc @@ -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 diff --git a/qcsrc/common/items/item/jetpack.qc b/qcsrc/common/items/item/jetpack.qc index 9ff4ed05c..45a256b1b 100644 --- a/qcsrc/common/items/item/jetpack.qc +++ b/qcsrc/common/items/item/jetpack.qc @@ -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 diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc index f10a97e54..86e3a7d66 100644 --- a/qcsrc/common/items/item/powerup.qc +++ b/qcsrc/common/items/item/powerup.qc @@ -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 \ @@ -11,29 +11,28 @@ , 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 diff --git a/qcsrc/server/mutators/mutator_instagib_items.qc b/qcsrc/server/mutators/mutator_instagib_items.qc index 40340b172..f2a0050e0 100644 --- a/qcsrc/server/mutators/mutator_instagib_items.qc +++ b/qcsrc/server/mutators/mutator_instagib_items.qc @@ -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 -- 2.39.2