fix compilation in Linux (Q_stricmp was function before and was implicitly linked w/o direct inclusion)

remove platform dependent branching in q3data
This commit is contained in:
Garux 2020-01-20 16:33:33 +03:00
parent 7492d3d8c5
commit bc8cc6e213
3 changed files with 13 additions and 30 deletions

View File

@ -20,15 +20,8 @@
*/ */
#include <assert.h> #include <assert.h>
#ifdef WIN32
#include <io.h>
#endif
#include "md3lib.h" #include "md3lib.h"
#if defined ( __linux__ ) || defined ( __APPLE__ )
#define filelength Q_filelength
#endif
/* /*
** MD3_ComputeTagFromTri ** MD3_ComputeTagFromTri
*/ */
@ -142,15 +135,15 @@ void MD3_Dump( const char *filename ){
FILE *fp; FILE *fp;
void *_buffer; void *_buffer;
void *buffer; void *buffer;
long fileSize; int fileSize;
int i; int i;
if ( ( fp = fopen( filename, "rb" ) ) == 0 ) { if ( ( fp = fopen( filename, "rb" ) ) == 0 ) {
Error( "Unable to open '%s'\n", filename ); Error( "Unable to open '%s'\n", filename );
} }
fileSize = filelength( fileno( fp ) ); fileSize = Q_filelength( fp );
_buffer = malloc( filelength( fileno( fp ) ) ); _buffer = malloc( fileSize );
fread( _buffer, fileSize, 1, fp ); fread( _buffer, fileSize, 1, fp );
fclose( fp ); fclose( fp );

View File

@ -21,18 +21,15 @@
#include "p3dlib.h" #include "p3dlib.h"
#ifdef WIN32
#include <io.h>
#endif
#include <stdlib.h> #include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include "../common/cmdlib.h"
#define MAX_POLYSETS 64 #define MAX_POLYSETS 64
#if defined ( __linux__ ) || defined ( __APPLE__ ) #if defined ( __linux__ ) || defined ( __APPLE__ )
#define _strcmpi Q_stricmp
#define filelength Q_filelength
#define strlwr strlower #define strlwr strlower
#endif #endif
typedef struct typedef struct
@ -67,7 +64,7 @@ int P3DLoad( const char *filename ){
memset( &p3d, 0, sizeof( p3d ) ); memset( &p3d, 0, sizeof( p3d ) );
p3d.len = filelength( fileno( fp ) ); p3d.len = Q_filelength( fp );
p3d.curpos = p3d.buffer = malloc( p3d.len ); p3d.curpos = p3d.buffer = malloc( p3d.len );
@ -102,7 +99,7 @@ int CharIsTokenDelimiter( int ch ){
int P3DSkipToToken( const char *name ){ int P3DSkipToToken( const char *name ){
while ( P3DGetToken( 0 ) ) while ( P3DGetToken( 0 ) )
{ {
if ( !_strcmpi( s_token, name ) ) { if ( !Q_stricmp( s_token, name ) ) {
return 1; return 1;
} }
} }
@ -167,14 +164,14 @@ int P3DSkipToTokenInBlock( const char *name ){
while ( P3DGetToken( 0 ) ) while ( P3DGetToken( 0 ) )
{ {
if ( !_strcmpi( s_token, "}" ) ) { if ( !Q_stricmp( s_token, "}" ) ) {
iLevel--; iLevel--;
} }
else if ( !_strcmpi( s_token, "{" ) ) { else if ( !Q_stricmp( s_token, "{" ) ) {
iLevel++; iLevel++;
} }
if ( !_strcmpi( s_token, name ) ) { if ( !Q_stricmp( s_token, name ) ) {
return 1; return 1;
} }
@ -201,7 +198,7 @@ int P3DProcess(){
// skip to the first Obj declaration // skip to the first Obj declaration
while ( P3DGetToken( 0 ) ) while ( P3DGetToken( 0 ) )
{ {
if ( !_strcmpi( s_token, "Obj" ) ) { if ( !Q_stricmp( s_token, "Obj" ) ) {
int j = 0, k = 0; int j = 0, k = 0;
if ( P3DSkipToToken( "Text" ) ) { if ( P3DSkipToToken( "Text" ) ) {
@ -310,7 +307,7 @@ void SkinFromP3D( const char *file ){
// corresponds to and append the shader to it // corresponds to and append the shader to it
for ( i = 0; i < g_data.model.numSurfaces; i++ ) 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; char *p;
if ( strstr( associatedShader, gamedir + 1 ) ) { if ( strstr( associatedShader, gamedir + 1 ) ) {

View File

@ -19,9 +19,6 @@
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/ */
#ifdef WIN32
#include <io.h>
#endif
#include "q3data.h" #include "q3data.h"
#include "md3lib.h" #include "md3lib.h"
@ -40,10 +37,6 @@ char *moddir = NULL;
// some old defined that was in cmdlib lost during merge // some old defined that was in cmdlib lost during merge
char writedir[1024]; char writedir[1024];
#if defined ( __linux__ ) || defined ( __APPLE__ )
#define strlwr strlower
#endif
/* /*
======================================================= =======================================================
@ -170,7 +163,7 @@ void FindShaderFiles( char *filename ){
} }
linebuffer[i] = 0; linebuffer[i] = 0;
strlwr( linebuffer ); strlower( linebuffer );
// see if the line specifies an opaque map or blendmap // see if the line specifies an opaque map or blendmap
if ( strstr( linebuffer, "opaquemap" ) == linebuffer || if ( strstr( linebuffer, "opaquemap" ) == linebuffer ||