]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
fix "warping" bug MrBougo found in the protocol (namely, values near +4096 causing...
authordivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Dec 2007 18:02:44 +0000 (18:02 +0000)
committerdivverent <divverent@d7cf8633-e32d-0410-b094-e92efae38249>
Tue, 25 Dec 2007 18:02:44 +0000 (18:02 +0000)
git-svn-id: svn://svn.icculus.org/twilight/trunk/darkplaces@7866 d7cf8633-e32d-0410-b094-e92efae38249

protocol.c

index 1be46fbbf79aa0bc91c0caf5fd3098f22f58ab11..8413c65823a95c7bfc88601e667b334e7ef32030 100644 (file)
@@ -1805,8 +1805,17 @@ void EntityState5_WriteUpdate(int number, const entity_state_t *s, int changedbi
        else
        {
                bits = changedbits;
-               if ((bits & E5_ORIGIN) && ((s->flags & RENDER_EXTERIORMODEL) || s->origin[0] < -4096 || s->origin[0] >= 4096 || s->origin[1] < -4096 || s->origin[1] >= 4096 || s->origin[2] < -4096 || s->origin[2] >= 4096))
+               if ((bits & E5_ORIGIN) && ((s->flags & RENDER_EXTERIORMODEL) || s->origin[0] <= -4096.0625 || s->origin[0] >= 4095.9375 || s->origin[1] <= -4096.0625 || s->origin[1] >= 4095.9375 || s->origin[2] <= -4096.0625 || s->origin[2] >= 4095.9375))
                        bits |= E5_ORIGIN32;
+                       // possible values:
+                       //   negative origin:
+                       //     (int)(f * 8 - 0.5) >= -32768
+                       //          (f * 8 - 0.5) >  -32769
+                       //           f            >  -4096.0625
+                       //   positive origin:
+                       //     (int)(f * 8 + 0.5) <=  32767
+                       //          (f * 8 + 0.5) <   32768
+                       //           f * 8 + 0.5) <   4095.9375
                if ((bits & E5_ANGLES) && !(s->flags & RENDER_LOWPRECISION))
                        bits |= E5_ANGLES16;
                if ((bits & E5_MODEL) && s->modelindex >= 256)