]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Improve reliability by using total damage
authorTimePath <andrew.hardaker1995@gmail.com>
Sat, 20 Dec 2014 10:39:09 +0000 (21:39 +1100)
committerTimePath <andrew.hardaker1995@gmail.com>
Sat, 20 Dec 2014 10:39:09 +0000 (21:39 +1100)
qcsrc/client/View.qc
qcsrc/server/g_world.qc

index 3fa921d29caed136b7e191bd64dcf588f2f2bebf..bec4f9e3fd8be5e48ffb55b559b0ead0195d416e 100644 (file)
@@ -423,7 +423,11 @@ float unaccounted_damage = 0;
 void UpdateDamage()
 {
        // accumulate damage with each stat update
-       float unaccounted_damage_new = getstati(STAT_DAMAGE_DEALT_TOTAL);
+       static float damage_total_prev = 0;
+       float damage_total = getstati(STAT_DAMAGE_DEALT_TOTAL);
+       float unaccounted_damage_new = COMPARE_INCREASING(damage_total, damage_total_prev);
+       damage_total_prev = damage_total;
+
        static float damage_dealt_time_prev = 0;
        float damage_dealt_time = getstatf(STAT_HIT_TIME);
        if (damage_dealt_time != damage_dealt_time_prev)
index 4b14ef3a1609e7280a1e6ee1b052494f430406d7..12118a2ff9b974733b47d74c2a603f5ae64132c4 100644 (file)
@@ -2204,27 +2204,13 @@ void EndFrame()
        float altime;
        FOR_EACH_REALCLIENT(self)
        {
-               self.damage_dealt_total = 0;
-       
-               if(IS_SPEC(self))
-               {
-                       if(self.enemy.typehitsound)
-                               self.typehit_time = time;
-                       else if(self.enemy.damage_dealt)
-                       {
-                               self.hit_time = time;
-                               self.damage_dealt_total = ceil(self.enemy.damage_dealt);
-                       }
-               }
-               else
+               entity e = IS_SPEC(self) ? self.enemy : self;
+               if(e.typehitsound)
+                       self.typehit_time = time;
+               else if(e.damage_dealt)
                {
-                       if(self.typehitsound)
-                               self.typehit_time = time;
-                       else if(self.damage_dealt)
-                       {
-                               self.hit_time = time;
-                               self.damage_dealt_total = ceil(self.damage_dealt);
-                       }
+                       self.hit_time = time;
+                       self.damage_dealt_total += ceil(e.damage_dealt);
                }
        }
        altime = time + frametime * (1 + autocvar_g_antilag_nudge);