* report full / full pk3 path on file syntax errors
This commit is contained in:
Garux 2017-08-02 09:05:30 +03:00
parent 0d5ebb17b2
commit bf6dd1f2d1
6 changed files with 34 additions and 21 deletions

View File

@ -172,7 +172,7 @@ void UnGetToken( void ){
qboolean EndOfScript( qboolean crossline ){ qboolean EndOfScript( qboolean crossline ){
if ( !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" ) ) { if ( !strcmp( script->filename, "memory buffer" ) ) {
@ -231,7 +231,7 @@ skipspace:
} }
if ( *script->script_p++ == '\n' ) { if ( *script->script_p++ == '\n' ) {
if ( !crossline ) { if ( !crossline ) {
Error( "Line %i is incomplete\n",scriptline ); Error( "Line %i is incomplete\nFile location be: %s\n", scriptline, g_strLoadedFileLocation );
} }
script->line++; script->line++;
scriptline = script->line; scriptline = script->line;
@ -246,7 +246,7 @@ skipspace:
if ( *script->script_p == ';' || *script->script_p == '#' if ( *script->script_p == ';' || *script->script_p == '#'
|| ( script->script_p[0] == '/' && script->script_p[1] == '/' ) ) { || ( script->script_p[0] == '/' && script->script_p[1] == '/' ) ) {
if ( !crossline ) { 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' ) while ( *script->script_p++ != '\n' )
if ( script->script_p >= script->end_p ) { if ( script->script_p >= script->end_p ) {
@ -260,7 +260,7 @@ skipspace:
// /* */ comments // /* */ comments
if ( script->script_p[0] == '/' && script->script_p[1] == '*' ) { if ( script->script_p[0] == '/' && script->script_p[1] == '*' ) {
if ( !crossline ) { 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; script->script_p += 2;
while ( script->script_p[0] != '*' && script->script_p[1] != '/' ) while ( script->script_p[0] != '*' && script->script_p[1] != '/' )
@ -293,7 +293,7 @@ skipspace:
break; break;
} }
if ( token_p == &token[MAXTOKEN] ) { 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++; script->script_p++;
@ -306,7 +306,7 @@ skipspace:
break; break;
} }
if ( token_p == &token[MAXTOKEN] ) { 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 );
} }
} }
} }

View File

@ -55,6 +55,7 @@
typedef struct typedef struct
{ {
char* unzFilePath;
char* name; char* name;
unz_s zipinfo; unz_s zipinfo;
unzFile zipfile; unzFile zipfile;
@ -71,6 +72,7 @@ static int g_numDirs;
char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1]; char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1];
int g_numForbiddenDirs = 0; int g_numForbiddenDirs = 0;
static gboolean g_bUsePak = TRUE; static gboolean g_bUsePak = TRUE;
char g_strLoadedFileLocation[1024];
// ============================================================================= // =============================================================================
// Static functions // Static functions
@ -120,6 +122,8 @@ static void vfsInitPakFile( const char *filename ){
} }
unzGoToFirstFile( uf ); unzGoToFirstFile( uf );
char* unzFilePath = strdup( filename );
for ( i = 0; i < gi.number_entry; i++ ) for ( i = 0; i < gi.number_entry; i++ )
{ {
char filename_inzip[NAME_MAX]; char filename_inzip[NAME_MAX];
@ -140,6 +144,7 @@ static void vfsInitPakFile( const char *filename ){
file->name = strdup( filename_inzip ); file->name = strdup( filename_inzip );
file->size = file_info.uncompressed_size; file->size = file_info.uncompressed_size;
file->zipfile = uf; file->zipfile = uf;
file->unzFilePath = unzFilePath;
memcpy( &file->zipinfo, uf, sizeof( unz_s ) ); memcpy( &file->zipinfo, uf, sizeof( unz_s ) );
if ( ( i + 1 ) < gi.number_entry ) { if ( ( i + 1 ) < gi.number_entry ) {
@ -322,6 +327,7 @@ void vfsShutdown(){
while ( g_pakFiles ) while ( g_pakFiles )
{ {
VFS_PAKFILE* file = (VFS_PAKFILE*)g_pakFiles->data; VFS_PAKFILE* file = (VFS_PAKFILE*)g_pakFiles->data;
free( file->unzFilePath );
free( file->name ); free( file->name );
free( file ); free( file );
g_pakFiles = g_slist_remove( g_pakFiles, 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 // filename is a full path
if ( index == -1 ) { if ( index == -1 ) {
strcpy( g_strLoadedFileLocation, filename );
long len; long len;
FILE *f; FILE *f;
@ -408,6 +415,8 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
strcat( tmp, filename ); strcat( tmp, filename );
if ( access( tmp, R_OK ) == 0 ) { if ( access( tmp, R_OK ) == 0 ) {
if ( count == index ) { if ( count == index ) {
strcpy( g_strLoadedFileLocation, tmp );
long len; long len;
FILE *f; FILE *f;
@ -451,6 +460,10 @@ int vfsLoadFile( const char *filename, void **bufferptr, int index ){
} }
if ( count == index ) { if ( count == index ) {
strcpy( g_strLoadedFileLocation, file->unzFilePath );
strcat( g_strLoadedFileLocation, " :: " );
strcat( g_strLoadedFileLocation, filename );
memcpy( file->zipfile, &file->zipinfo, sizeof( unz_s ) ); memcpy( file->zipfile, &file->zipinfo, sizeof( unz_s ) );
if ( unzOpenCurrentFile( file->zipfile ) != UNZ_OK ) { if ( unzOpenCurrentFile( file->zipfile ) != UNZ_OK ) {

View 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 char g_strForbiddenDirs[VFS_MAXDIRS][PATH_MAX + 1];
extern int g_numForbiddenDirs; extern int g_numForbiddenDirs;
extern char g_strLoadedFileLocation[1024];
#endif // _VFS_H_ #endif // _VFS_H_

View File

@ -395,8 +395,7 @@ void PartialLoadBSPFile( const char *filename ){
PartialLoadIBSPFile( filename ); PartialLoadIBSPFile( filename );
/* PartialSwapBSPFile() */ /* PartialSwapBSPFile() */
int i, j; int i;
shaderInfo_t *si;
/* shaders (don't swap the name) */ /* shaders (don't swap the name) */
for ( i = 0; i < numBSPShaders ; i++ ) for ( i = 0; i < numBSPShaders ; i++ )

View File

@ -2059,8 +2059,8 @@ skipEXfile:
break; break;
} }
if ( strcmp( token, "{" ) ) { if ( strcmp( token, "{" ) ) {
Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s", Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s",
temp, scriptline, token ); temp, scriptline, token, g_strLoadedFileLocation );
} }
while ( 1 ) while ( 1 )
@ -2113,8 +2113,8 @@ skipEXfile:
break; break;
} }
if ( strcmp( token, "{" ) ) { if ( strcmp( token, "{" ) ) {
Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s", Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s",
temp, scriptline, token ); temp, scriptline, token, g_strLoadedFileLocation );
} }
qboolean hasmap = qfalse; qboolean hasmap = qfalse;
@ -3061,8 +3061,8 @@ skipEXrefile:
break; break;
} }
if ( strcmp( token, "{" ) ) { if ( strcmp( token, "{" ) ) {
Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s", Error( "ParseShaderFile: %s, line %d: { not found!\nFound instead: %s\nFile location be: %s",
temp, scriptline, token ); temp, scriptline, token, g_strLoadedFileLocation );
} }
strcat( shaderText, "\n{" ); strcat( shaderText, "\n{" );
qboolean hasmap = qfalse; qboolean hasmap = qfalse;

View File

@ -947,17 +947,17 @@ void Parse1DMatrixAppend( char *buffer, int x, vec_t *m ){
if ( !GetTokenAppend( buffer, qtrue ) || strcmp( 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 );
} }
for ( i = 0; i < x; i++ ) for ( i = 0; i < x; i++ )
{ {
if ( !GetTokenAppend( buffer, qfalse ) ) { 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 ); m[ i ] = atof( token );
} }
if ( !GetTokenAppend( buffer, qtrue ) || strcmp( 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 ( strcmp( token, "{" ) ) {
if ( si != NULL ) { if ( si != NULL ) {
Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s", Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nLast known shader: %s\nFile location be: %s\n",
filename, scriptline, token, si->shader ); filename, scriptline, token, si->shader, g_strLoadedFileLocation );
} }
else{ else{
Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s", Error( "ParseShaderFile(): %s, line %d: { not found!\nFound instead: %s\nFile location be: %s\n",
filename, scriptline, token ); filename, scriptline, token, g_strLoadedFileLocation );
} }
} }