]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Fix items not respawning
authorTimePath <andrew.hardaker1995@gmail.com>
Tue, 12 May 2015 09:35:15 +0000 (19:35 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Tue, 12 May 2015 09:35:15 +0000 (19:35 +1000)
LMS mutator anyone?

qcsrc/common/items/item/ammo.qc
qcsrc/common/items/item/armor.qc
qcsrc/common/items/item/health.qc
qcsrc/common/items/item/pickup.qh
qcsrc/common/items/item/powerup.qc
qcsrc/common/util-pre.qh
qcsrc/server/t_items.qc

index 7267f8d07288729a89d3c60429334372e62094f5..b6f9abcc6eb591102f761c6809f52d15ab7c82a6 100644 (file)
@@ -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
index 6d9561b1591166df405f185ff93c86e1dcfe7551..a5c52458cab73645d4acde4141f7009597cbe2b5 100644 (file)
@@ -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)
     )
 )
 
index 64fdee45ba703949959545075759a1e2a34356bc..2b4a84bcf13dc1a40e67b2871641ca135e684ee5 100644 (file)
@@ -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)
     )
 )
 
index edff6e5928ae746d99810e7b6d14b21df5418e3e..1bd644a7c3e5f81a8f55fe4fab524c373b5a2a69 100644 (file)
@@ -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)
index 2bf0ddfd53f029cae05bc0a95ff2e5c7e0699ddc..7270664d41f61504b98a7c50dcf782ef75c2e06c 100644 (file)
@@ -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
index 053261b10efac17e04a7bc79acc356751c8e23d4..0ad822939ab6a557b90b1e19cab625c01ca3684c 100644 (file)
@@ -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))
index 0b0b1a6ed7b7fee7c8f7883161f9b685249b5c50..8a8f74008a8f66c0ef248451b77d9537188ca0ac 100644 (file)
@@ -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) {