]> git.xonotic.org Git - xonotic/netradiant.git/commitdiff
Q3map2:
authorGarux <garux@mail.ru>
Wed, 2 Aug 2017 06:05:30 +0000 (09:05 +0300)
committerGarux <garux@mail.ru>
Wed, 2 Aug 2017 06:05:30 +0000 (09:05 +0300)
* report full / full pk3 path on file syntax errors

tools/quake3/common/scriplib.c
tools/quake3/common/vfs.c
tools/quake3/common/vfs.h
tools/quake3/q3map2/bspfile_abstract.c
tools/quake3/q3map2/main.c
tools/quake3/q3map2/shaders.c

index c223bca297bd23f59898e6ff7e4605db1828ac38..1f0ac88deeea9784ff7051f815c2027a41422421 100644 (file)
@@ -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 );
                        }
                }
        }
index 2b1b61bc379a0781ab495dd89ddbcd5027e0dd43..2cafd3f03fb5320e8eb00f5519675471690c344c 100644 (file)
@@ -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 ) {
index 3527b3e1392cf0f03d232f7345d43c16ac1bbeaa..eb6abe75b24072389008e89b38fcfd6198132955 100644 (file)
@@ -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_
index 27ea7c158ffc4761424fe63d0e978bd566dcaf1c..e5e4055f3232e0ceddca56d21080f5b97150aee0 100644 (file)
@@ -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++ )
index 3120587fd9918ee6143307ab00690040c67870c4..6ee40957e96f9f6ecf25177f986c65c54f1b74e7 100644 (file)
@@ -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;
index c771d89b5702cff75db2fb035f809e8bb6d1b063..a4453374a24f5d8e255cbee49c4e71ec3498d22f 100644 (file)
@@ -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 );
                        }
                }