From: TimePath Date: Tue, 12 May 2015 09:35:15 +0000 (+1000) Subject: Fix items not respawning X-Git-Tag: xonotic-v0.8.1~53^2~9 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=978c038caba30540d7fc6e540c051801ad55ce77;p=xonotic%2Fxonotic-data.pk3dir.git Fix items not respawning LMS mutator anyone? --- diff --git a/qcsrc/common/items/item/ammo.qc b/qcsrc/common/items/item/ammo.qc index 7267f8d07..b6f9abcc6 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 6d9561b15..a5c52458c 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 64fdee45b..2b4a84bcf 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 edff6e592..1bd644a7c 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 2bf0ddfd5..7270664d4 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 053261b10..0ad822939 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 0b0b1a6ed..8a8f74008 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) {