more anticheats

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@5457 e016b1c5-ed68-44aa-a2f7-31cac88cffde
This commit is contained in:
Rafael Barreto
2010-07-25 22:11:38 +00:00
parent 1ac442a213
commit 5988066abd
2 changed files with 9 additions and 20 deletions
+7 -18
View File
@@ -4,24 +4,12 @@
// http://www.mceniry.net/papers/Fast%20Inverse%20Square%20Root.pdf
// http://en.wikipedia.org/wiki/Fast_inverse_square_root
inline float fInvSqrt (float x)
{
union
{
int d;
float f;
} u;
u.f = x;
u.d = 0x5f3759df - (u.d >> 1);
// return u.f; // ultra-fast, about 3.5% of error
return 0.5f * u.f * ( 3.00175f - x * u.f * u.f ); // about 0.1% of error
}
inline float fSqrt (float x)
{
return x * fInvSqrt(x);
}
#define UFINVSQRT union { int d; float f; } u; u.f = x; u.d = 0x5f3759df - (u.d >> 1)
inline float ufInvSqrt (float x) { UFINVSQRT; return u.f; } // about 3.5% of error
inline float fInvSqrt (float x) { UFINVSQRT; return 0.5f * u.f * ( 3.00175f - x * u.f * u.f ); } // about 0.1% of error
inline float fSqrt (float x) { return x * fInvSqrt(x); }
inline float ufSqrt (float x) { return x * ufInvSqrt(x); }
#undef UFINVSQRT
struct vec
{
@@ -60,6 +48,7 @@ struct vec
vec &normalize() { div(magnitude()); return *this; }
float fmag() const { return fSqrt(squaredlen()); }
float ufmag() const { return ufSqrt(squaredlen()); }
float dist(const vec &e) const { vec t; return dist(e, t); }
float dist(const vec &e, vec &t) const { t = *this; t.sub(e); return t.magnitude(); }
+2 -2
View File
@@ -262,7 +262,7 @@ struct client // server side version of "dynent" type
int input, inputmillis;
int ffire, wn, f, g, t, y, p;
int yb, pb, oy, op, lda, ldda, fam;
int nt[10], np, lp, ls, ld, nd, nlt, lem;
int nt[10], np, lp, ls, ld, nd, nlt, lem, led;
vec cp[10], dp[10], d0, lv, lt, le;
float dda, tr, sda;
@@ -297,7 +297,7 @@ struct client // server side version of "dynent" type
ffire = 0;
f = g = y = p = t = 0;
yb = pb = oy = op = lda = ldda = fam = 0;
np = lp = ls = ld = nd = nlt = lem = 0;
np = lp = ls = ld = nd = nlt = lem = led = 0;
d0 = lv = lt = le = vec(0,0,0);
loopi(10) { cp[i] = dp[i] = vec(0,0,0); nt[i] = 0; }
dda = tr = sda = 0;