X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fserver%2Faccuracy.qc;h=9271e03d0ad20ef4b7e8e9a6536d68b723b40348;hb=8a000d27bdf428db93e0304c4fdee5a26b89e9e8;hp=a0a557c3ccb7df33f6daae7b3f11bcd753f963ed;hpb=abfe0d3a11f71e9302d7409712174604bb5a230e;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/server/accuracy.qc b/qcsrc/server/accuracy.qc index a0a557c3c..9271e03d0 100644 --- a/qcsrc/server/accuracy.qc +++ b/qcsrc/server/accuracy.qc @@ -2,10 +2,6 @@ .float accuracy_fired[WEP_MAXCOUNT]; .float accuracy_cnt_hit[WEP_MAXCOUNT]; .float accuracy_cnt_fired[WEP_MAXCOUNT]; -FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_hit); -FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_fired); -FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_cnt_hit); -FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_cnt_fired); float accuracy_byte(float n, float d) { @@ -36,10 +32,14 @@ float accuracy_send(entity to, float 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; } @@ -66,36 +66,15 @@ 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; 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; @@ -106,13 +85,21 @@ void accuracy_add(entity e, float w, float fired, float hit) if(fired) a.(accuracy_fired[w]) += fired; - if(hit) + if(hit && a.hit_time != time) // only run this once per frame + { a.(accuracy_cnt_hit[w]) += 1; - a.(accuracy_cnt_fired[w]) += 1; + a.hit_time = time; + } + + if(fired && a.fired_time != time) // only run this once per frame + { + a.(accuracy_cnt_fired[w]) += 1; + a.fired_time = time; + } 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")