]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Kill dotproduct() function as it's built-in in QC; move cross() to warpzonelib so...
authorRudolf Polzer <divVerent@xonotic.org>
Tue, 24 Mar 2015 14:36:12 +0000 (15:36 +0100)
committerRudolf Polzer <divVerent@xonotic.org>
Tue, 24 Mar 2015 14:36:12 +0000 (15:36 +0100)
qcsrc/common/util.qc
qcsrc/common/util.qh
qcsrc/common/weapons/w_shockwave.qc
qcsrc/server/command/cmd.qc
qcsrc/server/mutators/gamemode_ctf.qc
qcsrc/warpzonelib/mathlib.qc
qcsrc/warpzonelib/mathlib.qh
qcsrc/warpzonelib/server.qc

index 99fecda0bbfc2855600c02a3ec2629845511f730..49d707f077be45adc59a7867322022ed9be41d96 100644 (file)
@@ -500,19 +500,6 @@ string ScoreString(int pFlags, float pValue)
        return valstr;
 }
 
-float dotproduct(vector a, vector b)
-{
-       return a.x * b.x + a.y * b.y + a.z * b.z;
-}
-
-vector cross(vector a, vector b)
-{
-       return
-               '1 0 0' * (a.y * b.z - a.z * b.y)
-       +       '0 1 0' * (a.z * b.x - a.x * b.z)
-       +       '0 0 1' * (a.x * b.y - a.y * b.x);
-}
-
 // compressed vector format:
 // like MD3, just even shorter
 //   4 bit pitch (16 angles), 0 is -90, 8 is 0, 16 would be 90
index 4de610f26fcc2113587a64019db6b55fb71ae647..b2cdf8dcaf2232be15fb675e2140d4018d686b64 100644 (file)
@@ -109,9 +109,6 @@ const float TIME_FACTOR = 100;
 
 string ScoreString(float vflags, float value);
 
-float dotproduct(vector a, vector b);
-vector cross(vector a, vector b);
-
 void compressShortVector_init();
 vector decompressShortVector(float data);
 float compressShortVector(vector vec);
index 24b8634b91dd1a6b6eb04defa40d2f8f8cecd466..3f40c5397fcfb8d34b96f4db4e0132c8b07bc5d1 100644 (file)
@@ -553,13 +553,11 @@ void W_Shockwave_Attack(void)
                        center = CENTER_OR_VIEWOFS(head);
 
                        // find the closest point on the enemy to the center of the attack
-                       float ang; // angle between shotdir and h
                        float h; // hypotenuse, which is the distance between attacker to head
                        float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
 
                        h = vlen(center - self.origin);
-                       ang = acos(dotproduct(normalize(center - self.origin), w_shotdir));
-                       a = h * cos(ang);
+                       a = h * (normalize(center - self.origin) * w_shotdir);
                        // WEAPONTODO: replace with simpler method
 
                        vector nearest_on_line = (w_shotorg + a * w_shotdir);
index 4a8b59eba651d8b8b1c3099858854ce7cbfca127..14e0f201c0f7bb029d4f4363a8ba50e7b7ea39c3 100644 (file)
@@ -825,6 +825,15 @@ void ClientCommand_macro_write_aliases(float fh)
 
 void SV_ParseClientCommand(string command)
 {
+       // If invalid UTF-8, don't even parse it
+       string command2 = "";
+       float len = strlen(command);
+       float i;
+       for (i = 0; i < len; ++i)
+               command2 = strcat(command2, chr2str(str2chr(command, i)));
+       if (command != command2)
+               return;
+
        // if we're banned, don't even parse the command
        if(Ban_MaybeEnforceBanOnce(self))
                return;
index 2e6eb4ff732533e927fc4359459ea5fec9f940f6..5ea2924cc4a40184fc80f9197ac49cebdb0dfab0 100644 (file)
@@ -89,13 +89,11 @@ float ctf_CheckPassDirection(vector head_center, vector passer_center, vector pa
                makevectors(passer_angle);
 
                // find the closest point on the enemy to the center of the attack
-               float ang; // angle between shotdir and h
                float h; // hypotenuse, which is the distance between attacker to head
                float a; // adjacent side, which is the distance between attacker and the point on w_shotdir that is closest to head.origin
 
                h = vlen(head_center - passer_center);
-               ang = acos(dotproduct(normalize(head_center - passer_center), v_forward));
-               a = h * cos(ang);
+               a = h * (normalize(head_center - passer_center) * v_forward);
 
                vector nearest_on_line = (passer_center + a * v_forward);
                float distance_from_line = vlen(nearest_to_passer - nearest_on_line);
index d86af8a00ec786760c15a9440b525a7160d4a0ab..c9cde9072c34210fb2f387f137569dfa35f71d9e 100644 (file)
@@ -290,3 +290,11 @@ int isunordered(float x, float y)
 {
        return !(x < y || x == y || x > y);
 }
+
+vector cross(vector a, vector b)
+{
+       return
+               '1 0 0' * (a.y * b.z - a.z * b.y)
+       +       '0 1 0' * (a.z * b.x - a.x * b.z)
+       +       '0 0 1' * (a.x * b.y - a.y * b.x);
+}
index a37ba63de6c63b87ed3dad63d12ea1ad4637fe52..ddd494de5b8422e5560cb68301d5fada7b43d73d 100644 (file)
@@ -112,4 +112,8 @@ const float M_2_PI     = 0.63661977236758134308;  /* 2/pi */
 const float M_2_SQRTPI = 1.12837916709551257390;  /* 2/sqrt(pi) */
 const float M_SQRT2    = 1.41421356237309504880;  /* sqrt(2) */
 const float M_SQRT1_2  = 0.70710678118654752440;  /* 1/sqrt(2) */
+
+// Non-<math.h> stuff follows here.
+vector cross(vector a, vector b);
+
 #endif
index 5d529c12e215ab78c66f85c48d7c79a8f3800147..d5a3f4e9271eae56cc4ba79dcb25c2788a705d91 100644 (file)
@@ -563,9 +563,7 @@ void WarpZone_InitStep_UpdateTransform()
                        c = getsurfacepoint(self, i_s, tri.z);
                        p = b - a;
                        q = c - a;
-                       n =     '1 0 0' * (q.y * p.z - q.z * p.y)
-                       +       '0 1 0' * (q.z * p.x - q.x * p.z)
-                       +       '0 0 1' * (q.x * p.y - q.y * p.x);
+                       n = cross(q, p);
                        area = area + vlen(n);
                        norm = norm + n;
                        point = point + vlen(n) * (a + b + c);