]> git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - common.c
Rename COM_CheckParm to Sys_CheckParm and move it to sys_shared.c
[xonotic/darkplaces.git] / common.c
index 9513239f9ddfd7e6055c767e67b1c0a2a9aa2bd9..7271384055629971b660ffbca44ca1ea8f25bf3f 100644 (file)
--- a/common.c
+++ b/common.c
@@ -860,28 +860,31 @@ skipwhite:
        return true;
 }
 
-
 /*
-================
-COM_CheckParm
+===============
+Com_CalcRoll
 
-Returns the position (1 to argc-1) in the program's argument list
-where the given parameter apears, or 0 if not present
-================
+Used by view and sv_user
+===============
 */
-int COM_CheckParm (const char *parm)
+float Com_CalcRoll (const vec3_t angles, const vec3_t velocity, const vec_t angleval, const vec_t velocityval)
 {
-       int i;
+       vec3_t  right;
+       float   sign;
+       float   side;
 
-       for (i=1 ; i<sys.argc ; i++)
-       {
-               if (!sys.argv[i])
-                       continue;               // NEXTSTEP sometimes clears appkit vars.
-               if (!strcmp (parm,sys.argv[i]))
-                       return i;
-       }
+       AngleVectors (angles, NULL, right, NULL);
+       side = DotProduct (velocity, right);
+       sign = side < 0 ? -1 : 1;
+       side = fabs(side);
+
+       if (side < velocityval)
+               side = side * angleval / velocityval;
+       else
+               side = angleval;
+
+       return side*sign;
 
-       return 0;
 }
 
 //===========================================================================