better handle >100% accuracy
authorRudolf Polzer <divverent@alientrap.org>
Wed, 24 Nov 2010 19:01:30 +0000 (20:01 +0100)
committerRudolf Polzer <divverent@alientrap.org>
Wed, 24 Nov 2010 19:01:30 +0000 (20:01 +0100)
qcsrc/client/Main.qc
qcsrc/server/accuracy.qc

index 0bcb9c4..ef220ac 100644 (file)
@@ -917,6 +917,8 @@ void Ent_ReadAccuracy(void)
                        b = ReadByte();
                        if(b == 0)
                                weapon_accuracy[w] = -1;
+                       else if(b == 255)
+                               weapon_accuracy[w] = 1.0; // no better error handling yet, sorry
                        else
                                weapon_accuracy[w] = (b - 1.0) / 100.0;
                }
index 783c0ac..335683c 100644 (file)
@@ -7,8 +7,10 @@ FTEQCC_YOU_SUCK_THIS_IS_NOT_UNREFERENCED(accuracy_fired);
 float accuracy_byte(float n, float d)
 {
        print(sprintf("accuracy: %d / %d\n", n, d));
-       if(d == 0)
+       if(n <= 0)
                return 0;
+       if(n > d)
+               return 255;
        return 1 + rint(n * 100.0 / d);
 }