]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
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 0bcb9c46d3e5c27620f944e2930d90f9572a5cda..ef220acefac5e4d960c8e7d7bc69faebedae5c72 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 783c0aceb68648eb3123dbff07c34cfd13c429af..335683c73a42be3fc4bd8b210b415da910548e53 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);
 }