]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Stop using stats for itemstime
authorTimePath <andrew.hardaker1995@gmail.com>
Mon, 24 Aug 2015 01:28:07 +0000 (11:28 +1000)
committerTimePath <andrew.hardaker1995@gmail.com>
Mon, 24 Aug 2015 01:28:07 +0000 (11:28 +1000)
Also fixes large armor being tracked instead of mega armor

qcsrc/client/hud.qc
qcsrc/common/mutators/all.inc
qcsrc/common/mutators/mutator/itemstime.qc [new file with mode: 0644]
qcsrc/common/stats.qh
qcsrc/dpdefs/csprogsdefs.qh
qcsrc/dpdefs/progsdefs.qh
qcsrc/server/defs.qh
qcsrc/server/mutators/mutator_superspec.qc
qcsrc/server/t_items.qc

index cfa00a1affafcc0184ee11ff20f5aebaa4b7e400..4310efbe982dfae6b83e5fdf9ca3880b8dd2d3c6 100644 (file)
@@ -4906,17 +4906,6 @@ void HUD_ItemsTime(void)
                        (autocvar_hud_panel_itemstime == 1 && spectatee_status != 0)
                ||      (autocvar_hud_panel_itemstime == 2 && (spectatee_status != 0 || warmup_stage))
                        )) { return; }
-
-               ItemsTime_time[0] = getstatf(STAT_ARMOR_LARGE_TIME);
-               ItemsTime_time[1] = getstatf(STAT_HEALTH_MEGA_TIME);
-               ItemsTime_time[2] = getstatf(STAT_INVISIBLE_TIME);
-               ItemsTime_time[3] = getstatf(STAT_SPEED_TIME);
-               ItemsTime_time[4] = getstatf(STAT_EXTRALIFE_TIME);
-               ItemsTime_time[5] = getstatf(STAT_STRENGTH_TIME);
-               ItemsTime_time[6] = getstatf(STAT_SHIELD_TIME);
-               ItemsTime_time[7] = getstatf(STAT_FUELREGEN_TIME);
-               ItemsTime_time[8] = getstatf(STAT_JETPACK_TIME);
-               ItemsTime_time[9] = getstatf(STAT_SUPERWEAPONS_TIME);
        }
        else
        {
index 4cb1a6ceaa33c7ecbabec2b6d9a01c27681cda28..44a2a4be1d1e8c2dc7354d100c026d18b332c6d4 100644 (file)
@@ -1 +1,2 @@
 #include "mutator/damagetext.qc"
+#include "mutator/itemstime.qc"
diff --git a/qcsrc/common/mutators/mutator/itemstime.qc b/qcsrc/common/mutators/mutator/itemstime.qc
new file mode 100644 (file)
index 0000000..122212d
--- /dev/null
@@ -0,0 +1,23 @@
+REGISTER_MUTATOR(itemstime, true);
+
+#ifdef SVQC
+void IT_Write(entity e, int i, float f) {
+    if (!IS_REAL_CLIENT(e)) return;
+    msg_entity = e;
+    WriteByte(MSG_ONE, SVC_TEMPENTITY);
+    WriteMutator(MSG_ONE, itemstime);
+    WriteByte(MSG_ONE, i);
+    WriteFloat(MSG_ONE, f);
+}
+#endif
+
+#ifdef CSQC
+MUTATOR_HOOKFUNCTION(itemstime, CSQC_Parse_TempEntity) {
+    if (MUTATOR_RETURNVALUE) return false;
+    if (!ReadMutatorEquals(mutator_argv_int_0, itemstime)) return false;
+    int i = ReadByte();
+    float f = ReadFloat();
+    ItemsTime_time[i] = f;
+    return true;
+}
+#endif
index 83afc1890be65daac0af553778941b2c7749c0b7..74aa0e75fad498f4cb543430af2e119212fa93cd 100644 (file)
@@ -109,16 +109,16 @@ const int STAT_OK_AMMO_CHARGE         = 85;
 const int STAT_OK_AMMO_CHARGEPOOL     = 86;
 const int STAT_FROZEN                 = 87;
 const int STAT_REVIVE_PROGRESS        = 88;
-const int STAT_ARMOR_LARGE_TIME       = 89;
-const int STAT_HEALTH_MEGA_TIME       = 90;
-const int STAT_INVISIBLE_TIME         = 91;
-const int STAT_SPEED_TIME             = 92;
-const int STAT_EXTRALIFE_TIME         = 93;
-const int STAT_STRENGTH_TIME          = 94;
-const int STAT_SHIELD_TIME            = 95;
-const int STAT_FUELREGEN_TIME         = 96;
-const int STAT_JETPACK_TIME           = 97;
-const int STAT_SUPERWEAPONS_TIME      = 98;
+// 89 empty?
+// 90 empty?
+// 91 empty?
+// 92 empty?
+// 93 empty?
+// 94 empty?
+// 95 empty?
+// 96 empty?
+// 97 empty?
+// 98 empty?
 const int STAT_ROUNDLOST              = 99;
 
 /* The following stats change depending on the gamemode, so can share the same ID */
index b10ef09baf75fadba2367fb6f5225c8bcec58b90..b42292c8523812c82b44a2c7df68e8b4e490ebc8 100644 (file)
@@ -21,4 +21,6 @@
 
 #pragma noref 0
 
+#define ReadFloat() ReadCoord()
+
 #endif
index c2440d3dabffba98aaf3a1324d321267a224dd46..3592c7015b53dc37726e7f6e86a35a3c6cb123be 100644 (file)
@@ -21,4 +21,6 @@
 
 #pragma noref 0
 
+#define WriteFloat(to, f) WriteCoord(to, f)
+
 #endif
index cab4d569fc6061a4628873cbb5f5358be128352a..46fba8347a8d788ea2ab6c84fa0449c79c9b448c 100644 (file)
@@ -513,16 +513,18 @@ const float ACTIVE_TOGGLE         = 3;
 .void (float act_state) setactive;
 .entity realowner;
 
-.float item_armor_large_time;
-.float item_health_mega_time;
-.float item_invisible_time;
-.float item_speed_time;
-.float item_extralife_time;
-.float item_strength_time;
-.float item_shield_time;
-.float item_fuelregen_time;
-.float item_jetpack_time;
-.float item_superweapons_time;
+enum {
+       item_armor_large_time,
+       item_health_mega_time,
+       item_invisible_time,
+       item_speed_time,
+       item_extralife_time,
+       item_strength_time,
+       item_shield_time,
+       item_fuelregen_time,
+       item_jetpack_time,
+       item_superweapons_time
+};
 
 //float serverflags;
 
index 267a0f71da0fa390f543015f7b5305754b8ee5e0..bc8600fb49ff34798af910ed25a9134768a6f69f 100644 (file)
@@ -123,7 +123,7 @@ MUTATOR_HOOKFUNCTION(superspec_ItemTouch)
 
                if((self.autospec_flags & ASF_SHIELD && _item.invincible_finished) ||
                        (self.autospec_flags & ASF_STRENGTH && _item.strength_finished) ||
-                       (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorLarge) ||
+                       (self.autospec_flags & ASF_MEGA_AR && _item.itemdef == ITEM_ArmorMega) ||
                        (self.autospec_flags & ASF_MEGA_HP && _item.itemdef == ITEM_HealthMega) ||
                        (self.autospec_flags & ASF_FLAG_GRAB && _item.classname == "item_flag_team"))
                {
index 2abee7931262b8762d075cb86f1a9870294ae0f6..0dd5c9c2b1ae8e656a6e23146c524228372545c8 100644 (file)
@@ -439,16 +439,6 @@ void Item_ItemsTime_Init()
 
 STATIC_INIT(ItemsTime_Init) {
     // items time
-    addstat(STAT_ARMOR_LARGE_TIME, AS_FLOAT, item_armor_large_time);
-    addstat(STAT_HEALTH_MEGA_TIME, AS_FLOAT, item_health_mega_time);
-    addstat(STAT_INVISIBLE_TIME, AS_FLOAT, item_invisible_time);
-    addstat(STAT_SPEED_TIME, AS_FLOAT, item_speed_time);
-    addstat(STAT_EXTRALIFE_TIME, AS_FLOAT, item_extralife_time);
-    addstat(STAT_STRENGTH_TIME, AS_FLOAT, item_strength_time);
-    addstat(STAT_SHIELD_TIME, AS_FLOAT, item_shield_time);
-    addstat(STAT_FUELREGEN_TIME, AS_FLOAT, item_fuelregen_time);
-    addstat(STAT_JETPACK_TIME, AS_FLOAT, item_jetpack_time);
-    addstat(STAT_SUPERWEAPONS_TIME, AS_FLOAT, item_superweapons_time);
     Item_ItemsTime_Init();
 }
 
@@ -465,31 +455,32 @@ void Item_ItemsTime_ResetTimes()
        it_jetpack_time     = (it_jetpack_time     == -1) ? -1 : 0;
        it_superweapons_time= (it_superweapons_time== -1) ? -1 : 0;
 }
+void IT_Write(entity, int, float);
 void Item_ItemsTime_ResetTimesForPlayer(entity e)
 {
-       e.item_armor_large_time = (it_armor_large_time == -1) ? -1 : 0;
-       e.item_health_mega_time = (it_health_mega_time == -1) ? -1 : 0;
-       e.item_invisible_time   = (it_invisible_time   == -1) ? -1 : 0;
-       e.item_speed_time       = (it_speed_time       == -1) ? -1 : 0;
-       e.item_extralife_time   = (it_extralife_time   == -1) ? -1 : 0;
-       e.item_strength_time    = (it_strength_time    == -1) ? -1 : 0;
-       e.item_shield_time      = (it_shield_time      == -1) ? -1 : 0;
-       e.item_fuelregen_time   = (it_fuelregen_time   == -1) ? -1 : 0;
-       e.item_jetpack_time     = (it_jetpack_time     == -1) ? -1 : 0;
-       e.item_superweapons_time= (it_superweapons_time== -1) ? -1 : 0;
+    IT_Write(e, item_armor_large_time , (it_armor_large_time  == -1) ? -1 : 0);
+    IT_Write(e, item_health_mega_time , (it_health_mega_time  == -1) ? -1 : 0);
+    IT_Write(e, item_invisible_time   , (it_invisible_time    == -1) ? -1 : 0);
+    IT_Write(e, item_speed_time       , (it_speed_time        == -1) ? -1 : 0);
+    IT_Write(e, item_extralife_time   , (it_extralife_time    == -1) ? -1 : 0);
+    IT_Write(e, item_strength_time    , (it_strength_time     == -1) ? -1 : 0);
+    IT_Write(e, item_shield_time      , (it_shield_time       == -1) ? -1 : 0);
+    IT_Write(e, item_fuelregen_time   , (it_fuelregen_time    == -1) ? -1 : 0);
+    IT_Write(e, item_jetpack_time     , (it_jetpack_time      == -1) ? -1 : 0);
+    IT_Write(e, item_superweapons_time, (it_superweapons_time == -1) ? -1 : 0);
 }
 void Item_ItemsTime_SetTimesForPlayer(entity e)
 {
-       e.item_armor_large_time = it_armor_large_time;
-       e.item_health_mega_time = it_health_mega_time;
-       e.item_invisible_time = it_invisible_time;
-       e.item_speed_time = it_speed_time;
-       e.item_extralife_time = it_extralife_time;
-       e.item_strength_time = it_strength_time;
-       e.item_shield_time = it_shield_time;
-       e.item_fuelregen_time = it_fuelregen_time;
-       e.item_jetpack_time = it_jetpack_time;
-       e.item_superweapons_time = it_superweapons_time;
+    IT_Write(e, item_armor_large_time , it_armor_large_time );
+    IT_Write(e, item_health_mega_time , it_health_mega_time );
+    IT_Write(e, item_invisible_time   , it_invisible_time   );
+    IT_Write(e, item_speed_time       , it_speed_time       );
+    IT_Write(e, item_extralife_time   , it_extralife_time   );
+    IT_Write(e, item_strength_time    , it_strength_time    );
+    IT_Write(e, item_shield_time      , it_shield_time      );
+    IT_Write(e, item_fuelregen_time   , it_fuelregen_time   );
+    IT_Write(e, item_jetpack_time     , it_jetpack_time     );
+    IT_Write(e, item_superweapons_time, it_superweapons_time);
 }
 
 void Item_ItemsTime_SetTime(entity e, float t)
@@ -516,12 +507,12 @@ void Item_ItemsTime_SetTime(entity e, float t)
        {
                switch(e.items)
                {
-                       case IT_HEALTH:
-                               // if(e.itemdef == ITEM_MegaHealth) // e.items == IT_HEALTH unequivocally identifies it
+                       case ITEM_HealthMega.m_itemid:
+                               // if(e.itemdef == ITEM_HealthMega) // e.items == IT_HEALTH unequivocally identifies it
                                        it_health_mega_time = t;
                                break;
-                       case IT_ARMOR:
-                               if(e.itemdef == ITEM_ArmorLarge) // e.items == IT_ARMOR doesn't unequivocally identifies it
+                       case ITEM_ArmorMega.m_itemid:
+                               if(e.itemdef == ITEM_ArmorMega) // e.items == IT_ARMOR doesn't unequivocally identifies it
                                        it_armor_large_time = t;
                                break;
                        case IT_STRENGTH://"item-strength"
@@ -614,7 +605,7 @@ void Item_Respawn (void)
                sound (self, CH_TRIGGER, "misc/itemrespawn.wav", VOL_BASE, ATTEN_NORM); // play respawn sound
        setorigin (self, self.origin);
 
-       if(self.flags & FL_POWERUP || self.itemdef == ITEM_ArmorLarge || self.items == IT_HEALTH || (self.weapons & WEPSET_SUPERWEAPONS))
+       if(self.flags & FL_POWERUP || self.itemdef == ITEM_ArmorMega || self.items == IT_HEALTH || (self.weapons & WEPSET_SUPERWEAPONS))
        {
                float t = Item_ItemsTime_UpdateTime(self, 0);
                Item_ItemsTime_SetTime(self, t);
@@ -656,7 +647,7 @@ void Item_RespawnCountdown (void)
                                                {name = "item_health_mega"; rgb = '1 0 0';}
                                        break;
                                case ITEM_ArmorMega.m_itemid:
-                                       if (self.itemdef == ITEM_ArmorLarge)
+                                       if (self.itemdef == ITEM_ArmorMega)
                                                {name = "item_armor_large"; rgb = '0 1 0';}
                                        break;
                        }
@@ -725,7 +716,7 @@ void Item_RespawnThink()
 
 void Item_ScheduleRespawnIn(entity e, float t)
 {
-       if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS) || e.itemdef == ITEM_ArmorLarge || e.items == IT_HEALTH)
+       if((e.flags & FL_POWERUP) || (e.weapons & WEPSET_SUPERWEAPONS) || e.itemdef == ITEM_ArmorMega || e.items == IT_HEALTH)
        {
                e.think = Item_RespawnCountdown;
                e.nextthink = time + max(0, t - ITEM_RESPAWN_TICKS);