]> de.git.xonotic.org Git - xonotic/netradiant.git/blobdiff - tools/quake3/q3data/md3lib.c
use %ld instead of %d for “long int” arguments
[xonotic/netradiant.git] / tools / quake3 / q3data / md3lib.c
index aa277126bb2c607e7a1f62a489044a55e38bf27c..66dfa52d8283682dcb46b8706aa1100ea25526e3 100644 (file)
@@ -1,23 +1,23 @@
 /*
-Copyright (C) 1999-2006 Id Software, Inc. and contributors.
-For a list of contributors, see the accompanying CONTRIBUTORS file.
+   Copyright (C) 1999-2006 Id Software, Inc. and contributors.
+   For a list of contributors, see the accompanying CONTRIBUTORS file.
 
-This file is part of GtkRadiant.
+   This file is part of GtkRadiant.
 
-GtkRadiant is free software; you can redistribute it and/or modify
-it under the terms of the GNU General Public License as published by
-the Free Software Foundation; either version 2 of the License, or
-(at your option) any later version.
+   GtkRadiant is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
 
-GtkRadiant is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
-GNU General Public License for more details.
+   GtkRadiant is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
 
-You should have received a copy of the GNU General Public License
-along with GtkRadiant; if not, write to the Free Software
-Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
-*/
+   You should have received a copy of the GNU General Public License
+   along with GtkRadiant; if not, write to the Free Software
+   Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
+ */
 
 #include <assert.h>
 #ifdef WIN32
@@ -25,21 +25,20 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
 #endif
 #include "md3lib.h"
 
-#if defined (__linux__) || defined (__APPLE__)
+#if defined ( __linux__ ) || defined ( __APPLE__ )
 #define filelength Q_filelength
 #endif
 
 /*
 ** MD3_ComputeTagFromTri
 */
-void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] )
-{
-       float   len[3];
-       vec3_t  axes[3], sides[3];
-       int             longestSide, shortestSide, hypotSide;
-       int             origin;
-       int             j;
-       float   d;
+void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] ){
+       float len[3];
+       vec3_t axes[3], sides[3];
+       int longestSide, shortestSide, hypotSide;
+       int origin;
+       int j;
+       float d;
 
        memset( axes, 0, sizeof( axes ) );
        memset( sides, 0, sizeof( sides ) );
@@ -49,24 +48,21 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] )
        //
        for ( j = 0; j < 3; j++ )
        {
-               sides[j][0] = pTri[(j+1)%3][0] - pTri[j][0];
-               sides[j][1] = pTri[(j+1)%3][1] - pTri[j][1];
-               sides[j][2] = pTri[(j+1)%3][2] - pTri[j][2];
+               sides[j][0] = pTri[( j + 1 ) % 3][0] - pTri[j][0];
+               sides[j][1] = pTri[( j + 1 ) % 3][1] - pTri[j][1];
+               sides[j][2] = pTri[( j + 1 ) % 3][2] - pTri[j][2];
 
                len[j] = ( float ) sqrt( DotProduct( sides[j], sides[j] ) );
        }
 
 #if 0
-       if ( len[0] > len[1] && len[0] > len[2] )
-       {
+       if ( len[0] > len[1] && len[0] > len[2] ) {
                longestSide = 0; shortestSide = 1; origin = 2;
        }
-       else if ( len[1] > len[0] && len[1] > len[2] )
-       {
+       else if ( len[1] > len[0] && len[1] > len[2] ) {
                longestSide = 1; shortestSide = 2; origin = 0;
        }
-       else if ( len[2] > len[0] && len[2] > len[1] )
-       {
+       else if ( len[2] > len[0] && len[2] > len[1] ) {
                longestSide = 2; shortestSide = 0; origin = 1;
        }
        else
@@ -77,10 +73,12 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] )
        if ( len[0] > len[1] && len[0] > len[2] ) {
                hypotSide = 0;
                origin = 2;
-       } else if ( len[1] > len[0] && len[1] > len[2] ) {
+       }
+       else if ( len[1] > len[0] && len[1] > len[2] ) {
                hypotSide = 1;
                origin = 0;
-       } else if ( len[2] > len[0] && len[2] > len[1] ) {
+       }
+       else if ( len[2] > len[0] && len[2] > len[1] ) {
                hypotSide = 2;
                origin = 1;
        }
@@ -88,18 +86,22 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] )
 
        if ( len[0] > len[1] && len[0] > len[2] ) {
                longestSide = 0;
-       } else if ( len[1] > len[0] && len[1] > len[2] ) {
+       }
+       else if ( len[1] > len[0] && len[1] > len[2] ) {
                longestSide = 1;
-       } else if ( len[2] > len[0] && len[2] > len[1] ) {
+       }
+       else if ( len[2] > len[0] && len[2] > len[1] ) {
                longestSide = 2;
        }
        len[longestSide] = -1;
 
        if ( len[0] > len[1] && len[0] > len[2] ) {
                shortestSide = 0;
-       } else if ( len[1] > len[0] && len[1] > len[2] ) {
+       }
+       else if ( len[1] > len[0] && len[1] > len[2] ) {
                shortestSide = 1;
-       } else if ( len[2] > len[0] && len[2] > len[1] ) {
+       }
+       else if ( len[2] > len[0] && len[2] > len[1] ) {
                shortestSide = 2;
        }
        len[shortestSide] = -1;
@@ -129,12 +131,11 @@ void MD3_ComputeTagFromTri( md3Tag_t *pTag, const float pTri[3][3] )
 }
 
 /*
-==============
-MD3_Dump
-==============
-*/
-void MD3_Dump( const char *filename )
-{
+   ==============
+   MD3_Dump
+   ==============
+ */
+void MD3_Dump( const char *filename ){
        md3Header_t header;
        md3Tag_t *pTag;
        md3Surface_t *pSurface;
@@ -144,8 +145,7 @@ void MD3_Dump( const char *filename )
        long fileSize;
        int i;
 
-       if ( ( fp = fopen( filename, "rb" ) ) == 0 )
-       {
+       if ( ( fp = fopen( filename, "rb" ) ) == 0 ) {
                Error( "Unable to open '%s'\n", filename );
        }
 
@@ -157,8 +157,7 @@ void MD3_Dump( const char *filename )
        buffer = ( char * ) _buffer;
        header = *( md3Header_t * ) _buffer;
 
-       if ( header.ident != MD3_IDENT )
-       {
+       if ( header.ident != MD3_IDENT ) {
                Error( "Incorrect ident for '%s'\n", filename );
        }
 
@@ -169,7 +168,7 @@ void MD3_Dump( const char *filename )
        printf( "  num tags:       %d\n", header.numTags );
        printf( "  num surfaces:   %d\n", header.numSurfaces );
        printf( "  num skins:      %d\n", header.numSkins );
-       printf( "  file size:      %d\n", fileSize );
+       printf( "  file size:      %ld\n", fileSize );
 
        printf( "--- TAGS ---\n" );
        pTag = ( md3Tag_t * ) ( ( ( char * ) buffer ) + header.ofsTags );
@@ -197,8 +196,7 @@ void MD3_Dump( const char *filename )
                printf( "    num tris: %d\n", pSurface->numTriangles );
                printf( "    num verts: %d\n", pSurface->numVerts );
 
-               if ( pSurface->numShaders > 0 )
-               {
+               if ( pSurface->numShaders > 0 ) {
                        printf( "    --- SHADERS ---\n" );
 
                        for ( j = 0; j < pSurface->numShaders; j++, pShader++ )
@@ -211,4 +209,3 @@ void MD3_Dump( const char *filename )
 
        free( _buffer );
 }
-