summaryrefslogtreecommitdiff
path: root/src/qcommon
diff options
context:
space:
mode:
authorChristopher Schwarz <lakitu7@gmail.com>2009-10-21 18:13:17 +0000
committerTim Angus <tim@ngus.net>2013-01-03 00:16:59 +0000
commite83ed6ee76cb7884bfc12e8c96920f9de0f70809 (patch)
treec7937d2a8f4ece7d65d654a1705939de27bcce7d /src/qcommon
parent7ea9b68aff5fa0a7306e7c0f0fd138aa58a033fd (diff)
* (bug 4311) Print file locations of relevant items to simplify troubleshooting (Amanieu)
Diffstat (limited to 'src/qcommon')
-rw-r--r--src/qcommon/files.c69
-rw-r--r--src/qcommon/vm.c3
2 files changed, 72 insertions, 0 deletions
diff --git a/src/qcommon/files.c b/src/qcommon/files.c
index 75686111..721536c4 100644
--- a/src/qcommon/files.c
+++ b/src/qcommon/files.c
@@ -2406,6 +2406,74 @@ void FS_TouchFile_f( void ) {
}
}
+/*
+============
+FS_Which_f
+============
+*/
+void FS_Which_f( void ) {
+ searchpath_t *search;
+ char *netpath;
+ pack_t *pak;
+ fileInPack_t *pakFile;
+ directory_t *dir;
+ long hash;
+ FILE *temp;
+ char *filename;
+ char buf[ MAX_OSPATH ];
+
+ hash = 0;
+ filename = Cmd_Argv(1);
+
+ if ( !filename[0] ) {
+ Com_Printf( "Usage: which <file>\n" );
+ return;
+ }
+
+ // qpaths are not supposed to have a leading slash
+ if ( filename[0] == '/' || filename[0] == '\\' ) {
+ filename++;
+ }
+
+ // just wants to see if file is there
+ for ( search = fs_searchpaths ; search ; search = search->next ) {
+ if ( search->pack ) {
+ hash = FS_HashFileName(filename, search->pack->hashSize);
+ }
+ // is the element a pak file?
+ if ( search->pack && search->pack->hashTable[hash] ) {
+ // look through all the pak file elements
+ pak = search->pack;
+ pakFile = pak->hashTable[hash];
+ do {
+ // case and separator insensitive comparisons
+ if ( !FS_FilenameCompare( pakFile->name, filename ) ) {
+ // found it!
+ Com_Printf( "File \"%s\" found in \"%s\"\n", filename, pak->pakFilename );
+ return;
+ }
+ pakFile = pakFile->next;
+ } while(pakFile != NULL);
+ } else if ( search->dir ) {
+ dir = search->dir;
+
+ netpath = FS_BuildOSPath( dir->path, dir->gamedir, filename );
+ temp = fopen (netpath, "rb");
+ if ( !temp ) {
+ continue;
+ }
+ fclose(temp);
+ Com_sprintf( buf, sizeof( buf ), "%s/%s", dir->path, dir->gamedir );
+ FS_ReplaceSeparators( buf );
+ Com_Printf( "File \"%s\" found at \"%s\"\n", filename, buf );
+ return;
+ }
+ }
+ Com_Printf( "File not found: \"%s\"\n", filename );
+ return;
+}
+
+
//===========================================================================
@@ -2791,6 +2859,7 @@ static void FS_Startup( const char *gameName )
Cmd_AddCommand ("dir", FS_Dir_f );
Cmd_AddCommand ("fdir", FS_NewDir_f );
Cmd_AddCommand ("touchFile", FS_TouchFile_f );
+ Cmd_AddCommand ("which", FS_Which_f );
// https://zerowing.idsoftware.com/bugzilla/show_bug.cgi?id=506
// reorder the pure pk3 files according to server order
diff --git a/src/qcommon/vm.c b/src/qcommon/vm.c
index 713256a7..876d36d5 100644
--- a/src/qcommon/vm.c
+++ b/src/qcommon/vm.c
@@ -387,6 +387,9 @@ vmHeader_t *VM_LoadQVM( vm_t *vm, qboolean alloc ) {
return NULL;
}
+ // show where the qvm was loaded from
+ Cmd_ExecuteString( va( "which %s\n", filename ) );
+
if( LittleLong( header.h->vmMagic ) == VM_MAGIC_VER2 ) {
Com_Printf( "...which has vmMagic VM_MAGIC_VER2\n" );