From bc8cc6e2132b9d93c62a97bcfe22548605a051f1 Mon Sep 17 00:00:00 2001 From: Garux Date: Mon, 20 Jan 2020 16:33:33 +0300 Subject: [PATCH] fix compilation in Linux (Q_stricmp was function before and was implicitly linked w/o direct inclusion) remove platform dependent branching in q3data --- tools/quake3/q3data/md3lib.c | 13 +++---------- tools/quake3/q3data/p3dlib.c | 21 +++++++++------------ tools/quake3/q3data/q3data.c | 9 +-------- 3 files changed, 13 insertions(+), 30 deletions(-) diff --git a/tools/quake3/q3data/md3lib.c b/tools/quake3/q3data/md3lib.c index f2f0eee5..bfa21c6b 100644 --- a/tools/quake3/q3data/md3lib.c +++ b/tools/quake3/q3data/md3lib.c @@ -20,15 +20,8 @@ */ #include -#ifdef WIN32 -#include -#endif #include "md3lib.h" -#if defined ( __linux__ ) || defined ( __APPLE__ ) -#define filelength Q_filelength -#endif - /* ** MD3_ComputeTagFromTri */ @@ -142,15 +135,15 @@ void MD3_Dump( const char *filename ){ FILE *fp; void *_buffer; void *buffer; - long fileSize; + int fileSize; int i; if ( ( fp = fopen( filename, "rb" ) ) == 0 ) { Error( "Unable to open '%s'\n", filename ); } - fileSize = filelength( fileno( fp ) ); - _buffer = malloc( filelength( fileno( fp ) ) ); + fileSize = Q_filelength( fp ); + _buffer = malloc( fileSize ); fread( _buffer, fileSize, 1, fp ); fclose( fp ); diff --git a/tools/quake3/q3data/p3dlib.c b/tools/quake3/q3data/p3dlib.c index 2da1ae9b..36449f43 100644 --- a/tools/quake3/q3data/p3dlib.c +++ b/tools/quake3/q3data/p3dlib.c @@ -21,18 +21,15 @@ #include "p3dlib.h" -#ifdef WIN32 -#include -#endif #include #include #include +#include "../common/cmdlib.h" + #define MAX_POLYSETS 64 #if defined ( __linux__ ) || defined ( __APPLE__ ) -#define _strcmpi Q_stricmp -#define filelength Q_filelength #define strlwr strlower #endif typedef struct @@ -67,7 +64,7 @@ int P3DLoad( const char *filename ){ memset( &p3d, 0, sizeof( p3d ) ); - p3d.len = filelength( fileno( fp ) ); + p3d.len = Q_filelength( fp ); p3d.curpos = p3d.buffer = malloc( p3d.len ); @@ -102,7 +99,7 @@ int CharIsTokenDelimiter( int ch ){ int P3DSkipToToken( const char *name ){ while ( P3DGetToken( 0 ) ) { - if ( !_strcmpi( s_token, name ) ) { + if ( !Q_stricmp( s_token, name ) ) { return 1; } } @@ -167,14 +164,14 @@ int P3DSkipToTokenInBlock( const char *name ){ while ( P3DGetToken( 0 ) ) { - if ( !_strcmpi( s_token, "}" ) ) { + if ( !Q_stricmp( s_token, "}" ) ) { iLevel--; } - else if ( !_strcmpi( s_token, "{" ) ) { + else if ( !Q_stricmp( s_token, "{" ) ) { iLevel++; } - if ( !_strcmpi( s_token, name ) ) { + if ( !Q_stricmp( s_token, name ) ) { return 1; } @@ -201,7 +198,7 @@ int P3DProcess(){ // skip to the first Obj declaration while ( P3DGetToken( 0 ) ) { - if ( !_strcmpi( s_token, "Obj" ) ) { + if ( !Q_stricmp( s_token, "Obj" ) ) { int j = 0, k = 0; if ( P3DSkipToToken( "Text" ) ) { @@ -310,7 +307,7 @@ void SkinFromP3D( const char *file ){ // corresponds to and append the shader to it for ( i = 0; i < g_data.model.numSurfaces; i++ ) { - if ( !_strcmpi( g_data.surfData[i].header.name, psetName ) ) { + if ( !Q_stricmp( g_data.surfData[i].header.name, psetName ) ) { char *p; if ( strstr( associatedShader, gamedir + 1 ) ) { diff --git a/tools/quake3/q3data/q3data.c b/tools/quake3/q3data/q3data.c index f517beb0..a757b9d4 100644 --- a/tools/quake3/q3data/q3data.c +++ b/tools/quake3/q3data/q3data.c @@ -19,9 +19,6 @@ Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#ifdef WIN32 -#include -#endif #include "q3data.h" #include "md3lib.h" @@ -40,10 +37,6 @@ char *moddir = NULL; // some old defined that was in cmdlib lost during merge char writedir[1024]; -#if defined ( __linux__ ) || defined ( __APPLE__ ) -#define strlwr strlower -#endif - /* ======================================================= @@ -170,7 +163,7 @@ void FindShaderFiles( char *filename ){ } linebuffer[i] = 0; - strlwr( linebuffer ); + strlower( linebuffer ); // see if the line specifies an opaque map or blendmap if ( strstr( linebuffer, "opaquemap" ) == linebuffer ||