From bf6dd1f2d186c799adf11f1e744a1ff57aa8d335 Mon Sep 17 00:00:00 2001 From: Garux Date: Wed, 2 Aug 2017 09:05:30 +0300 Subject: [PATCH] Q3map2: * report full / full pk3 path on file syntax errors --- tools/quake3/common/scriplib.c | 12 ++++++------ tools/quake3/common/vfs.c | 13 +++++++++++++ tools/quake3/common/vfs.h | 1 + tools/quake3/q3map2/bspfile_abstract.c | 3 +-- tools/quake3/q3map2/main.c | 12 ++++++------ tools/quake3/q3map2/shaders.c | 14 +++++++------- 6 files changed, 34 insertions(+), 21 deletions(-) diff --git a/tools/quake3/common/scriplib.c b/tools/quake3/common/scriplib.c index c223bca2..1f0ac88d 100644 --- a/tools/quake3/common/scriplib.c +++ b/tools/quake3/common/scriplib.c @@ -172,7 +172,7 @@ void UnGetToken( void ){ qboolean EndOfScript( qboolean crossline ){ if ( !crossline ) { - Error( "Line %i is incomplete\n",scriptline ); + Error( "Line %i is incomplete\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } if ( !strcmp( script->filename, "memory buffer" ) ) { @@ -231,7 +231,7 @@ skipspace: } if ( *script->script_p++ == '\n' ) { if ( !crossline ) { - Error( "Line %i is incomplete\n",scriptline ); + Error( "Line %i is incomplete\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } script->line++; scriptline = script->line; @@ -246,7 +246,7 @@ skipspace: if ( *script->script_p == ';' || *script->script_p == '#' || ( script->script_p[0] == '/' && script->script_p[1] == '/' ) ) { if ( !crossline ) { - Error( "Line %i is incomplete\n",scriptline ); + Error( "Line %i is incomplete\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } while ( *script->script_p++ != '\n' ) if ( script->script_p >= script->end_p ) { @@ -260,7 +260,7 @@ skipspace: // /* */ comments if ( script->script_p[0] == '/' && script->script_p[1] == '*' ) { if ( !crossline ) { - Error( "Line %i is incomplete\n",scriptline ); + Error( "Line %i is incomplete\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } script->script_p += 2; while ( script->script_p[0] != '*' && script->script_p[1] != '/' ) @@ -293,7 +293,7 @@ skipspace: break; } if ( token_p == &token[MAXTOKEN] ) { - Error( "Token too large on line %i\n",scriptline ); + Error( "Token too large on line %i\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } } script->script_p++; @@ -306,7 +306,7 @@ skipspace: break; } if ( token_p == &token[MAXTOKEN] ) { - Error( "Token too large on line %i\n",scriptline ); + Error( "Token too large on line %i\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } } } diff --git a/tools/quake3/common/vfs.c b/tools/quake3/common/vfs.c index 2b1b61bc..2cafd3f0 100644 --- a/tools/quake3/common/vfs.c +++ b/tools/quake3/common/vfs.c @@ -55,6 +55,7 @@ typedef struct { + char* unzFilePath; char* name; unz_s zipinfo; unzFile zipfile; @@ -71,6 +72,7 @@ static int g_numDirs; char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1]; int g_numForbiddenDirs = 0; static gboolean g_bUsePak = TRUE; +char g_strLoadedFileLocation[1024]; // ============================================================================= // Static functions @@ -120,6 +122,8 @@ static void vfsInitPakFile( const char *filename ){ } unzGoToFirstFile( uf ); + char* unzFilePath = strdup( filename ); + for ( i = 0; i < gi.number_entry; i++ ) { char filename_inzip[NAME_MAX]; @@ -140,6 +144,7 @@ static void vfsInitPakFile( const char *filename ){ file->name = strdup( filename_inzip ); file->size = file_info.uncompressed_size; file->zipfile = uf; + file->unzFilePath = unzFilePath; memcpy( &file->zipinfo, uf, sizeof( unz_s ) ); if ( ( i + 1 ) < gi.number_entry ) { @@ -322,6 +327,7 @@ void vfsShutdown(){ while ( g_pakFiles ) { VFS_PAKFILE* file = (VFS_PAKFILE*)g_pakFiles->data; + free( file->unzFilePath ); free( file->name ); free( file ); g_pakFiles = g_slist_remove( g_pakFiles, file ); @@ -367,6 +373,7 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ // filename is a full path if ( index == -1 ) { + strcpy( g_strLoadedFileLocation, filename ); long len; FILE *f; @@ -408,6 +415,8 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ strcat( tmp, filename ); if ( access( tmp, R_OK ) == 0 ) { if ( count == index ) { + strcpy( g_strLoadedFileLocation, tmp ); + long len; FILE *f; @@ -451,6 +460,10 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){ } if ( count == index ) { + strcpy( g_strLoadedFileLocation, file->unzFilePath ); + strcat( g_strLoadedFileLocation, " :: " ); + strcat( g_strLoadedFileLocation, filename ); + memcpy( file->zipfile, &file->zipinfo, sizeof( unz_s ) ); if ( unzOpenCurrentFile( file->zipfile ) != UNZ_OK ) { diff --git a/tools/quake3/common/vfs.h b/tools/quake3/common/vfs.h index 3527b3e1..eb6abe75 100644 --- a/tools/quake3/common/vfs.h +++ b/tools/quake3/common/vfs.h @@ -61,5 +61,6 @@ qboolean vfsPackFile_Absolute_Path( const char *filepath, const char *filename, extern char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1]; extern int g_numForbiddenDirs; +extern char g_strLoadedFileLocation[1024]; #endif // _VFS_H_ diff --git a/tools/quake3/q3map2/bspfile_abstract.c b/tools/quake3/q3map2/bspfile_abstract.c index 27ea7c15..e5e4055f 100644 --- a/tools/quake3/q3map2/bspfile_abstract.c +++ b/tools/quake3/q3map2/bspfile_abstract.c @@ -395,8 +395,7 @@ void PartialLoadBSPFile( const char *filename ){ PartialLoadIBSPFile( filename ); /* PartialSwapBSPFile() */ - int i, j; - shaderInfo_t *si; + int i; /* shaders (don't swap the name) */ for ( i = 0; i < numBSPShaders ; i++ ) diff --git a/tools/quake3/q3map2/main.c b/tools/quake3/q3map2/main.c index 3120587f..6ee40957 100644 --- a/tools/quake3/q3map2/main.c +++ b/tools/quake3/q3map2/main.c @@ -2059,8 +2059,8 @@ skipEXfile: break; } if ( strcmp( token, "{" ) ) { - Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s", - temp, scriptline, token ); + Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s", + temp, scriptline, token, g_strLoadedFileLocation ); } while ( 1 ) @@ -2113,8 +2113,8 @@ skipEXfile: break; } if ( strcmp( token, "{" ) ) { - Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s", - temp, scriptline, token ); + Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s", + temp, scriptline, token, g_strLoadedFileLocation ); } qboolean hasmap = qfalse; @@ -3061,8 +3061,8 @@ skipEXrefile: break; } if ( strcmp( token, "{" ) ) { - Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s", - temp, scriptline, token ); + Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s", + temp, scriptline, token, g_strLoadedFileLocation ); } strcat( shaderText, "\n{" ); qboolean hasmap = qfalse; diff --git a/tools/quake3/q3map2/shaders.c b/tools/quake3/q3map2/shaders.c index c771d89b..a4453374 100644 --- a/tools/quake3/q3map2/shaders.c +++ b/tools/quake3/q3map2/shaders.c @@ -947,17 +947,17 @@ void Parse1DMatrixAppend( char *buffer, int x, vec_t *m ){ if ( !GetTokenAppend( buffer, qtrue ) || strcmp( token, "(" ) ) { - Error( "Parse1DMatrixAppend(): line %d: ( not found!", scriptline ); + Error( "Parse1DMatrixAppend(): line %d: ( not found!\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } for ( i = 0; i < x; i++ ) { if ( !GetTokenAppend( buffer, qfalse ) ) { - Error( "Parse1DMatrixAppend(): line %d: Number not found!", scriptline ); + Error( "Parse1DMatrixAppend(): line %d: Number not found!\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } m[ i ] = atof( token ); } if ( !GetTokenAppend( buffer, qtrue ) || strcmp( token, ")" ) ) { - Error( "Parse1DMatrixAppend(): line %d: ) not found!", scriptline ); + Error( "Parse1DMatrixAppend(): line %d: ) not found!\nFile location be: %s\n", scriptline, g_strLoadedFileLocation ); } } @@ -1019,12 +1019,12 @@ static void ParseShaderFile( const char *filename ){ } if ( strcmp( token, "{" ) ) { if ( si != NULL ) { - Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s", - filename, scriptline, token, si->shader ); + Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s\nFile location be: %s\n", + filename, scriptline, token, si->shader, g_strLoadedFileLocation ); } else{ - Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s", - filename, scriptline, token ); + Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nFile location be: %s\n", + filename, scriptline, token, g_strLoadedFileLocation ); } } -- 2.39.2