]> de.git.xonotic.org Git - xonotic/darkplaces.git/blobdiff - prvm_cmds.c
made darkplaces compile successfully with g++ to test for errors C doesn't care about...
[xonotic/darkplaces.git] / prvm_cmds.c
index c2d32dbef80d5b1efd13a90af4850bfba1d9eced..e3f639294101fddda2a90ca74c9b9694fdf306c8 100644 (file)
@@ -74,9 +74,9 @@ checkextension(extensionname)
 // kind of helper function
 static qboolean checkextension(const char *name)
 {
 // kind of helper function
 static qboolean checkextension(const char *name)
 {
-       size_t len;
+       int len;
        char *e, *start;
        char *e, *start;
-       len = strlen(name);
+       len = (int)strlen(name);
 
        for (e = prog->extensionstring;*e;e++)
        {
 
        for (e = prog->extensionstring;*e;e++)
        {
@@ -87,11 +87,8 @@ static qboolean checkextension(const char *name)
                start = e;
                while (*e && *e != ' ')
                        e++;
                start = e;
                while (*e && *e != ' ')
                        e++;
-               if (e - start == len)
-                       if (!strncasecmp(start, name, len))
-                       {
-                               return true;
-                       }
+               if ((e - start) == len && !strncasecmp(start, name, len))
+                       return true;
        }
        return false;
 }
        }
        return false;
 }
@@ -255,24 +252,20 @@ void VM_normalize (void)
 {
        float   *value1;
        vec3_t  newvalue;
 {
        float   *value1;
        vec3_t  newvalue;
-       float   new;
+       double  f;
 
        VM_SAFEPARMCOUNT(1,VM_normalize);
 
        value1 = PRVM_G_VECTOR(OFS_PARM0);
 
 
        VM_SAFEPARMCOUNT(1,VM_normalize);
 
        value1 = PRVM_G_VECTOR(OFS_PARM0);
 
-       new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
-       new = sqrt(new);
-
-       if (new == 0)
-               newvalue[0] = newvalue[1] = newvalue[2] = 0;
-       else
+       f = VectorLength2(value1);
+       if (f)
        {
        {
-               new = 1/new;
-               newvalue[0] = value1[0] * new;
-               newvalue[1] = value1[1] * new;
-               newvalue[2] = value1[2] * new;
+               f = 1.0 / sqrt(f);
+               VectorScale(value1, f, newvalue);
        }
        }
+       else
+               VectorClear(newvalue);
 
        VectorCopy (newvalue, PRVM_G_VECTOR(OFS_RETURN));
 }
 
        VectorCopy (newvalue, PRVM_G_VECTOR(OFS_RETURN));
 }
@@ -286,17 +279,8 @@ scalar vlen(vector)
 */
 void VM_vlen (void)
 {
 */
 void VM_vlen (void)
 {
-       float   *value1;
-       float   new;
-
        VM_SAFEPARMCOUNT(1,VM_vlen);
        VM_SAFEPARMCOUNT(1,VM_vlen);
-
-       value1 = PRVM_G_VECTOR(OFS_PARM0);
-
-       new = value1[0] * value1[0] + value1[1] * value1[1] + value1[2]*value1[2];
-       new = sqrt(new);
-
-       PRVM_G_FLOAT(OFS_RETURN) = new;
+       PRVM_G_FLOAT(OFS_RETURN) = VectorLength(PRVM_G_VECTOR(OFS_PARM0));
 }
 
 /*
 }
 
 /*
@@ -1680,7 +1664,7 @@ fputs(float fhandle, string s)
 //void(float fhandle, string s) fputs = #113; // writes a line of text to the end of the file
 void VM_fputs(void)
 {
 //void(float fhandle, string s) fputs = #113; // writes a line of text to the end of the file
 void VM_fputs(void)
 {
-       size_t stringlength;
+       int stringlength;
        char string[VM_STRINGTEMP_LENGTH];
        int filenum;
 
        char string[VM_STRINGTEMP_LENGTH];
        int filenum;
 
@@ -1698,7 +1682,7 @@ void VM_fputs(void)
                return;
        }
        VM_VarString(1, string, sizeof(string));
                return;
        }
        VM_VarString(1, string, sizeof(string));
-       if ((stringlength = strlen(string)))
+       if ((stringlength = (int)strlen(string)))
                FS_Write(VM_FILES[filenum], string, stringlength);
        if (developer.integer)
                Con_Printf("fputs: %s: %s\n", PRVM_NAME, string);
                FS_Write(VM_FILES[filenum], string, stringlength);
        if (developer.integer)
                Con_Printf("fputs: %s: %s\n", PRVM_NAME, string);
@@ -2107,7 +2091,7 @@ loadfromfile(string file)
 void VM_loadfromfile(void)
 {
        const char *filename;
 void VM_loadfromfile(void)
 {
        const char *filename;
-       qbyte *data;
+       char *data;
 
        VM_SAFEPARMCOUNT(1,VM_loadfromfile);
 
 
        VM_SAFEPARMCOUNT(1,VM_loadfromfile);
 
@@ -2124,7 +2108,7 @@ void VM_loadfromfile(void)
        }
 
        // not conform with VM_fopen
        }
 
        // not conform with VM_fopen
-       data = FS_LoadFile(filename, tempmempool, false);
+       data = (char *)FS_LoadFile(filename, tempmempool, false);
        if (data == NULL)
                PRVM_G_FLOAT(OFS_RETURN) = -1;
 
        if (data == NULL)
                PRVM_G_FLOAT(OFS_RETURN) = -1;
 
@@ -2698,7 +2682,7 @@ void VM_cin_setstate( void )
        name = PRVM_G_STRING( OFS_PARM0 );
        VM_CheckEmptyString( name );
 
        name = PRVM_G_STRING( OFS_PARM0 );
        VM_CheckEmptyString( name );
 
-       state = PRVM_G_FLOAT( OFS_PARM1 );
+       state = (clvideostate_t)PRVM_G_FLOAT( OFS_PARM1 );
 
        video = CL_GetVideo( name );
        if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT )
 
        video = CL_GetVideo( name );
        if( video && state > CLVIDEO_UNUSED && state < CLVIDEO_STATECOUNT )