From 978c038caba30540d7fc6e540c051801ad55ce77 Mon Sep 17 00:00:00 2001 From: TimePath Date: Tue, 12 May 2015 19:35:15 +1000 Subject: [PATCH] Fix items not respawning LMS mutator anyone? --- qcsrc/common/items/item/ammo.qc | 14 +++++++------- qcsrc/common/items/item/armor.qc | 16 ++++++++-------- qcsrc/common/items/item/health.qc | 16 ++++++++-------- qcsrc/common/items/item/pickup.qh | 19 +++++++++++++++++-- qcsrc/common/items/item/powerup.qc | 18 +++++++++--------- qcsrc/common/util-pre.qh | 3 +++ qcsrc/server/t_items.qc | 2 +- 7 files changed, 53 insertions(+), 35 deletions(-) diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc index 7267f8d072..b6f9abcc6e 100644 --- a/qcsrc/common/items/item/ammo.qc +++ b/qcsrc/common/items/item/ammo.qc @@ -3,13 +3,13 @@ #define WITH(it) this.m_##it; #define CONFIGURE(...) MAP(WITH, __VA_ARGS__) -#define DEFINE(id, ...) \ - REGISTER_ITEM(id, Ammo, LAMBDA( \ - IF(SV, CONFIGURE \ - , respawntime = g_pickup_respawntime_ammo \ - , respawntimejitter = g_pickup_respawntimejitter_ammo \ - ) \ - MAP(IDENTITY, __VA_ARGS__) \ +#define DEFINE(id, ...) \ + REGISTER_ITEM(id, Ammo, LAMBDA( \ + IF(SV, CONFIGURE \ + , respawntime = GET(g_pickup_respawntime_ammo) \ + , respawntimejitter = GET(g_pickup_respawntimejitter_ammo) \ + ) \ + MAP(IDENTITY, __VA_ARGS__) \ )) DEFINE(Bullets diff --git a/qcsrc/common/items/item/armor.qc b/qcsrc/common/items/item/armor.qc index 6d9561b159..a5c52458ca 100644 --- a/qcsrc/common/items/item/armor.qc +++ b/qcsrc/common/items/item/armor.qc @@ -14,8 +14,8 @@ DEFINE(ArmorSmall ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_LOW - , respawntime = g_pickup_respawntime_short - , respawntimejitter = g_pickup_respawntimejitter_short + , respawntime = GET(g_pickup_respawntime_short) + , respawntimejitter = GET(g_pickup_respawntimejitter_short) ) ) @@ -28,8 +28,8 @@ DEFINE(ArmorMedium ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_MID - , respawntime = g_pickup_respawntime_medium - , respawntimejitter = g_pickup_respawntimejitter_medium + , respawntime = GET(g_pickup_respawntime_medium) + , respawntimejitter = GET(g_pickup_respawntimejitter_medium) ) ) @@ -42,8 +42,8 @@ DEFINE(ArmorBig ) ,IF(SV, CONFIGURE , botvalue = 20000 // FIXME: higher than BOT_PICKUP_RATING_HIGH? - , respawntime = g_pickup_respawntime_long - , respawntimejitter = g_pickup_respawntimejitter_long + , respawntime = GET(g_pickup_respawntime_long) + , respawntimejitter = GET(g_pickup_respawntimejitter_long) ) ) @@ -56,8 +56,8 @@ DEFINE(ArmorLarge ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_HIGH - , respawntime = g_pickup_respawntime_long - , respawntimejitter = g_pickup_respawntimejitter_long + , respawntime = GET(g_pickup_respawntime_long) + , respawntimejitter = GET(g_pickup_respawntimejitter_long) ) ) diff --git a/qcsrc/common/items/item/health.qc b/qcsrc/common/items/item/health.qc index 64fdee45ba..2b4a84bcf1 100644 --- a/qcsrc/common/items/item/health.qc +++ b/qcsrc/common/items/item/health.qc @@ -14,8 +14,8 @@ DEFINE(HealthSmall ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_LOW - , respawntime = g_pickup_respawntime_short - , respawntimejitter = g_pickup_respawntimejitter_short + , respawntime = GET(g_pickup_respawntime_short) + , respawntimejitter = GET(g_pickup_respawntimejitter_short) ) ) @@ -28,8 +28,8 @@ DEFINE(HealthMedium ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_MID - , respawntime = g_pickup_respawntime_short - , respawntimejitter = g_pickup_respawntimejitter_short + , respawntime = GET(g_pickup_respawntime_short) + , respawntimejitter = GET(g_pickup_respawntimejitter_short) ) ) @@ -42,8 +42,8 @@ DEFINE(HealthLarge ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_MID - , respawntime = g_pickup_respawntime_medium - , respawntimejitter = g_pickup_respawntimejitter_medium + , respawntime = GET(g_pickup_respawntime_medium) + , respawntimejitter = GET(g_pickup_respawntimejitter_medium) ) ) @@ -56,8 +56,8 @@ DEFINE(HealthMega ) ,IF(SV, CONFIGURE , botvalue = BOT_PICKUP_RATING_HIGH - , respawntime = g_pickup_respawntime_long - , respawntimejitter = g_pickup_respawntimejitter_long + , respawntime = GET(g_pickup_respawntime_long) + , respawntimejitter = GET(g_pickup_respawntimejitter_long) ) ) diff --git a/qcsrc/common/items/item/pickup.qh b/qcsrc/common/items/item/pickup.qh index edff6e5928..1bd644a7c3 100644 --- a/qcsrc/common/items/item/pickup.qh +++ b/qcsrc/common/items/item/pickup.qh @@ -11,14 +11,29 @@ CLASS(Pickup, GameItem) ATTRIB(Pickup, m_botvalue, int, 0) ATTRIB(Pickup, m_itemflags, int, 0) ATTRIB(Pickup, m_pickupevalfunc, float(entity player, entity item), generic_pickupevalfunc) - ATTRIB(Pickup, m_respawntime, int, 0) - ATTRIB(Pickup, m_respawntimejitter, int, 0) + ATTRIB(Pickup, m_respawntime, float(), func_null) + ATTRIB(Pickup, m_respawntimejitter, float(), func_null) #endif ENDCLASS(Pickup) #ifdef SVQC // For g_pickup_respawntime #include "../../../server/defs.qh" +// Getters to dynamically retrieve the values of g_pickup_respawntime* as they aren't autocvars +GETTER(float, g_pickup_respawntime_weapon) +GETTER(float, g_pickup_respawntime_superweapon) +GETTER(float, g_pickup_respawntime_ammo) +GETTER(float, g_pickup_respawntime_short) +GETTER(float, g_pickup_respawntime_medium) +GETTER(float, g_pickup_respawntime_long) +GETTER(float, g_pickup_respawntime_powerup) +GETTER(float, g_pickup_respawntimejitter_weapon) +GETTER(float, g_pickup_respawntimejitter_superweapon) +GETTER(float, g_pickup_respawntimejitter_ammo) +GETTER(float, g_pickup_respawntimejitter_short) +GETTER(float, g_pickup_respawntimejitter_medium) +GETTER(float, g_pickup_respawntimejitter_long) +GETTER(float, g_pickup_respawntimejitter_powerup) #endif bool Pickup_respondTo(entity this, int request) diff --git a/qcsrc/common/items/item/powerup.qc b/qcsrc/common/items/item/powerup.qc index 2bf0ddfd53..7270664d41 100644 --- a/qcsrc/common/items/item/powerup.qc +++ b/qcsrc/common/items/item/powerup.qc @@ -3,15 +3,15 @@ #define WITH(it) this.m_##it; #define CONFIGURE(...) MAP(WITH, __VA_ARGS__) -#define DEFINE(id, ...) \ - REGISTER_ITEM(id, Ammo, LAMBDA( \ - IF(SV, CONFIGURE \ - , botvalue = 100000 \ - , itemflags = FL_POWERUP \ - , respawntime = g_pickup_respawntime_powerup \ - , respawntimejitter = g_pickup_respawntimejitter_powerup \ - ) \ - MAP(IDENTITY, __VA_ARGS__) \ +#define DEFINE(id, ...) \ + REGISTER_ITEM(id, Ammo, LAMBDA( \ + IF(SV, CONFIGURE \ + , botvalue = 100000 \ + , itemflags = FL_POWERUP \ + , respawntime = GET(g_pickup_respawntime_powerup) \ + , respawntimejitter = GET(g_pickup_respawntimejitter_powerup) \ + ) \ + MAP(IDENTITY, __VA_ARGS__) \ )) DEFINE(Strength diff --git a/qcsrc/common/util-pre.qh b/qcsrc/common/util-pre.qh index 053261b10e..0ad822939a 100644 --- a/qcsrc/common/util-pre.qh +++ b/qcsrc/common/util-pre.qh @@ -99,6 +99,9 @@ #define IF(pred, f, ...) pred(f, __VA_ARGS__) +#define GET(name) name##get +#define GETTER(type, name) type GET(name)() { return name; } + #define BIT(n) (1 << (n)) #ifndef BRANCHLESS_BITSET #define BITSET(var, mask, flag) (flag ? (var) | (mask) : (var) &~ (mask)) diff --git a/qcsrc/server/t_items.qc b/qcsrc/server/t_items.qc index 0b0b1a6ed7..8a8f74008a 100644 --- a/qcsrc/server/t_items.qc +++ b/qcsrc/server/t_items.qc @@ -1156,7 +1156,7 @@ void StartItem (string itemmodel, string pickupsound, float defaultrespawntime, void StartItemA (entity a) { - StartItem(a.m_model, a.m_sound, a.m_respawntime, a.m_respawntimejitter, a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue); + StartItem(a.m_model, a.m_sound, a.m_respawntime(), a.m_respawntimejitter(), a.m_name, a.m_itemid, 0, a.m_itemflags, a.m_pickupevalfunc, a.m_botvalue); } void spawnfunc_item_rockets (void) { -- 2.39.2