]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/server/accuracy.qc
Merge branch 'master' into terencehill/music_player
[xonotic/xonotic-data.pk3dir.git] / qcsrc / server / accuracy.qc
index de6b52752b95b358503e9fdd1a846377bd4f6bc6..aca64a431a55d2b474bb6322f4284a522b51a98d 100644 (file)
@@ -20,22 +20,26 @@ float accuracy_send(entity to, float sf)
        WriteByte(MSG_ENTITY, ENT_CLIENT_ACCURACY);
 
        a = self.owner;
-       if(a.classname == "spectator")
+       if(IS_SPEC(a))
                a = a.enemy;
        a = a.accuracy;
 
        if(to != a.owner)
-               if not(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share)
+               if (!(self.owner.cvar_cl_accuracy_data_share && autocvar_sv_accuracy_data_share))
                        sf = 0;
        // note: zero sendflags can never be sent... so we can use that to say that we send no accuracy!
        WriteInt24_t(MSG_ENTITY, sf);
        if(sf == 0)
                return TRUE;
        // note: we know that client and server agree about SendFlags...
-       for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w, f *= 2)
+       for(w = 0, f = 1; w <= WEP_LAST - WEP_FIRST; ++w)
        {
                if(sf & f)
                        WriteByte(MSG_ENTITY, accuracy_byte(self.(accuracy_hit[w]), self.(accuracy_fired[w])));
+               if(f == 0x800000)
+                       f = 1;
+               else
+                       f *= 2;
        }
        return TRUE;
 }
@@ -62,32 +66,6 @@ void accuracy_resend(entity e)
 }
 
 // update accuracy stats
-void accuracy_set(entity e, float w, float fired, float hit)
-{
-       entity a;
-       float b;
-       a = e.accuracy;
-       if(!a)
-               return;
-       w -= WEP_FIRST;
-       b = accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w]));
-       a.(accuracy_hit[w]) = hit;
-       a.(accuracy_fired[w]) = fired;
-
-    if(hit)
-        a.(accuracy_cnt_hit[w]) = 1;
-    a.(accuracy_cnt_fired[w]) = 1;
-
-       if(b == accuracy_byte(hit, fired))
-               return;
-       w = pow(2, w);
-       a.SendFlags |= w;
-       FOR_EACH_CLIENT(a)
-               if(a.classname == "spectator")
-                       if(a.enemy == e)
-                               a.SendFlags |= w;
-}
-
 .float hit_time;
 .float fired_time;
 
@@ -95,6 +73,8 @@ void accuracy_add(entity e, float w, float fired, float hit)
 {
        entity a;
        float b;
+       if(IS_INDEPENDENT_PLAYER(e))
+               return;
        a = e.accuracy;
        if(!a || !(hit || fired))
                return;
@@ -119,27 +99,27 @@ void accuracy_add(entity e, float w, float fired, float hit)
 
        if(b == accuracy_byte(a.(accuracy_hit[w]), a.(accuracy_fired[w])))
                return;
-       w = pow(2, w);
+       w = pow(2, mod(w, 24));
        a.SendFlags |= w;
        FOR_EACH_CLIENT(a)
-               if(a.classname == "spectator")
+               if(IS_SPEC(a))
                        if(a.enemy == e)
                                a.SendFlags |= w;
 }
 
 float accuracy_isgooddamage(entity attacker, entity targ)
 {
-       if(!inWarmupStage)
-       if(targ.flags & FL_CLIENT)
+       if(!warmup_stage)
+       if(IS_CLIENT(targ))
        if(targ.deadflag == DEAD_NO)
-       if(IsDifferentTeam(attacker, targ))
+       if(DIFF_TEAM(attacker, targ))
                return TRUE;
        return FALSE;
 }
 
 float accuracy_canbegooddamage(entity attacker)
 {
-       if(!inWarmupStage)
+       if(!warmup_stage)
                return TRUE;
        return FALSE;
 }