/* ============================== main ============================== */ int main (int argc, char **argv) { int i; printf ("\nqlumpy "VERSION" by John Carmack, copyright (c) 1994 Id Software.\n"); printf ("Portions copyright (c) 1998 Valve LLC (%s)\n", __DATE__ ); if (argc == 1) Error ("qlumpy [-archive directory] [-8bit] [-proj <project>] scriptfile [scriptfile ...]"); lumpbuffer = malloc (MAXLUMP); do16bit = true; for( i=1; i<argc; i++ ) { if( *argv[ i ] == '-' ) { if( !strcmp( argv[ i ], "-archive" ) ) { archive = true; strcpy (archivedir, argv[2]); printf ("Archiving source to: %s\n", archivedir); } else if( !strcmp( argv[ i ], "-proj" ) ) { strcpy( qproject, argv[ i + 1 ] ); i++; } else if( !strcmp( argv[ i ], "-8bit" ) ) do16bit = false; } else break; } // rest of arguments are script files for ( ; i<argc ; i++) { char szTemp[1024]; char *pszPath = argv[i]; // Fully qualify the path names before using them if (!(pszPath[0] == '/' || pszPath[0] == '\\' || pszPath[1] == ':')) { // path is partial Q_getwd (szTemp); strcat (szTemp, pszPath); pszPath = szTemp; } SetQdirFromPath(pszPath); ProcessLumpyScript(pszPath); } return 0; }
char *ExpandArg (char *path) { static char full[1024]; if (path[0] != '/' && path[0] != '\\' && path[1] != ':') { Q_getwd (full); strcat (full, path); } else strcpy (full, path); return full; }
char *ExpandArg (const char *path) { static char full[1024]; if (path[0] != '/' && path[0] != '\\' && path[1] != ':') { Q_getwd (full, sizeof(full)); qerr_strlcat(__thisfunc__, __LINE__, full, path, sizeof(full)); } else { qerr_strlcpy(__thisfunc__, __LINE__, full, path, sizeof(full)); } return full; }
void SetQdirFromPath (const char *path) { char temp[1024]; const char *c, *mark; if (!(path[0] == '/' || path[0] == '\\' || path[1] == ':')) { // path is partial Q_getwd (temp, sizeof(temp)); qerr_strlcat(__thisfunc__, __LINE__, temp, path, sizeof(temp)); path = temp; } c = path; while (*c) ++c; while (c > path && *c != '/' && *c != '\\') --c; if (c == path) goto end; mark = c + 1; --c; // search for the basedir (as defined in BUILDDIR) in path while (c != path) { if (!q_strncasecmp (c, BUILDDIR, sizeof(BUILDDIR) - 1)) { strncpy (qdir, path, c + sizeof(BUILDDIR) - path); printf ("qdir: %s\n", qdir); // now search for a gamedir in path c += sizeof(BUILDDIR); while (c < mark) { if (*c == '/' || *c == '\\') { strncpy (gamedir, path, c + 1 - path); printf ("gamedir: %s\n", gamedir); return; } c++; } Error ("No gamedir in %s", path); } --c; } end: Error ("%s: no '%s' in %s", __thisfunc__, BUILDDIR, path); }
//----------------------------------------------------------------------------- // Mounds a particular steam cache //----------------------------------------------------------------------------- FSReturnCode_t FileSystem_MountContent( CFSMountContentInfo &mountContentInfo ) { // This part is Steam-only. if ( mountContentInfo.m_pFileSystem->IsSteam() ) { // Find out the "extra app id". This is for tools, which want to mount a base app's filesystem // like HL2, then mount the SDK content (tools materials and models, etc) in addition. int nExtraAppId = -1; if ( mountContentInfo.m_bToolsMode ) { FSReturnCode_t ret = GetSteamExtraAppId( mountContentInfo.m_pDirectoryName, &nExtraAppId ); if ( ret != FS_OK ) return ret; } // Set our working directory temporarily so Steam can remember it. // This is what Steam strips off absolute filenames like c:\program files\valve\steam\steamapps\username\sourcesdk // to get to the relative part of the path. char baseDir[MAX_PATH], oldWorkingDir[MAX_PATH]; if ( !FileSystem_GetBaseDir( baseDir, sizeof( baseDir ) ) ) return SetupFileSystemError( false, FS_INVALID_PARAMETERS, "FileSystem_GetBaseDir failed." ); Q_getwd( oldWorkingDir, sizeof( oldWorkingDir ) ); _chdir( baseDir ); // Filesystem_tools needs to add dependencies in here beforehand. FilesystemMountRetval_t retVal = mountContentInfo.m_pFileSystem->MountSteamContent( nExtraAppId ); _chdir( oldWorkingDir ); if ( retVal != FILESYSTEM_MOUNT_OK ) return SetupFileSystemError( true, FS_UNABLE_TO_INIT, "Unable to mount Steam content in the file system" ); } return FileSystem_SetBasePaths( mountContentInfo.m_pFileSystem ); }
FSReturnCode_t LocateGameInfoFile( const CFSSteamSetupInfo &fsInfo, char *pOutDir, int outDirLen ) { // Engine and Hammer don't want to search around for it. if ( fsInfo.m_bOnlyUseDirectoryName ) { if ( !fsInfo.m_pDirectoryName ) return SetupFileSystemError( false, FS_MISSING_GAMEINFO_FILE, "bOnlyUseDirectoryName=1 and pDirectoryName=NULL." ); bool bExists = DoesFileExistIn( fsInfo.m_pDirectoryName, GAMEINFO_FILENAME ); if ( IsX360() && !bExists ) { bExists = DoesFileExistIn( fsInfo.m_pDirectoryName, GAMEINFO_FILENAME_ALTERNATE ); } if ( !bExists ) { if ( IsX360() && CommandLine()->FindParm( "-basedir" ) ) { char basePath[MAX_PATH]; strcpy( basePath, CommandLine()->ParmValue( "-basedir", "" ) ); Q_AppendSlash( basePath, sizeof( basePath ) ); Q_strncat( basePath, fsInfo.m_pDirectoryName, sizeof( basePath ), COPY_ALL_CHARACTERS ); if ( DoesFileExistIn( basePath, GAMEINFO_FILENAME ) ) { Q_strncpy( pOutDir, basePath, outDirLen ); return FS_OK; } if ( IsX360() && DoesFileExistIn( basePath, GAMEINFO_FILENAME_ALTERNATE ) ) { Q_strncpy( pOutDir, basePath, outDirLen ); return FS_OK; } } return SetupFileSystemError( true, FS_MISSING_GAMEINFO_FILE, "Setup file '%s' doesn't exist in subdirectory '%s'.\nCheck your -game parameter or VCONFIG setting.", GAMEINFO_FILENAME, fsInfo.m_pDirectoryName ); } Q_strncpy( pOutDir, fsInfo.m_pDirectoryName, outDirLen ); return FS_OK; } // First, check for overrides on the command line or environment variables. const char *pProject = GetVProjectCmdLineValue(); if ( pProject ) { if ( DoesFileExistIn( pProject, GAMEINFO_FILENAME ) ) { Q_MakeAbsolutePath( pOutDir, outDirLen, pProject ); return FS_OK; } if ( IsX360() && DoesFileExistIn( pProject, GAMEINFO_FILENAME_ALTERNATE ) ) { Q_MakeAbsolutePath( pOutDir, outDirLen, pProject ); return FS_OK; } if ( IsX360() && CommandLine()->FindParm( "-basedir" ) ) { char basePath[MAX_PATH]; strcpy( basePath, CommandLine()->ParmValue( "-basedir", "" ) ); Q_AppendSlash( basePath, sizeof( basePath ) ); Q_strncat( basePath, pProject, sizeof( basePath ), COPY_ALL_CHARACTERS ); if ( DoesFileExistIn( basePath, GAMEINFO_FILENAME ) ) { Q_strncpy( pOutDir, basePath, outDirLen ); return FS_OK; } if ( DoesFileExistIn( basePath, GAMEINFO_FILENAME_ALTERNATE ) ) { Q_strncpy( pOutDir, basePath, outDirLen ); return FS_OK; } } if ( fsInfo.m_bNoGameInfo ) { // fsInfo.m_bNoGameInfo is set by the Steam dedicated server, before it knows which mod to use. // Steam dedicated server doesn't need a gameinfo.txt, because we'll ask which mod to use, even if // -game is supplied on the command line. Q_strncpy( pOutDir, "", outDirLen ); return FS_OK; } else { // They either specified vproject on the command line or it's in their registry. Either way, // we don't want to continue if they've specified it but it's not valid. goto ShowError; } } if ( fsInfo.m_bNoGameInfo ) { Q_strncpy( pOutDir, "", outDirLen ); return FS_OK; } // Ask the application if it can provide us with a game info directory { bool bBubbleDir = true; SuggestGameInfoDirFn_t pfnSuggestGameInfoDirFn = GetSuggestGameInfoDirFn(); if ( pfnSuggestGameInfoDirFn && ( * pfnSuggestGameInfoDirFn )( &fsInfo, pOutDir, outDirLen, &bBubbleDir ) && FS_OK == TryLocateGameInfoFile( pOutDir, outDirLen, bBubbleDir ) ) return FS_OK; } // Try to use the environment variable / registry if ( ( pProject = getenv( GAMEDIR_TOKEN ) ) != NULL && ( Q_MakeAbsolutePath( pOutDir, outDirLen, pProject ), 1 ) && FS_OK == TryLocateGameInfoFile( pOutDir, outDirLen, false ) ) return FS_OK; if ( IsPC() ) { Warning( "Warning: falling back to auto detection of vproject directory.\n" ); // Now look for it in the directory they passed in. if ( fsInfo.m_pDirectoryName ) Q_MakeAbsolutePath( pOutDir, outDirLen, fsInfo.m_pDirectoryName ); else Q_MakeAbsolutePath( pOutDir, outDirLen, "." ); if ( FS_OK == TryLocateGameInfoFile( pOutDir, outDirLen, true ) ) return FS_OK; // Use the CWD Q_getwd( pOutDir, outDirLen ); if ( FS_OK == TryLocateGameInfoFile( pOutDir, outDirLen, true ) ) return FS_OK; } ShowError: return SetupFileSystemError( true, FS_MISSING_GAMEINFO_FILE, "Unable to find %s. Solutions:\n\n" "1. Read http://www.valve-erc.com/srcsdk/faq.html#NoGameDir\n" "2. Run vconfig to specify which game you're working on.\n" "3. Add -game <path> on the command line where <path> is the directory that %s is in.\n", GAMEINFO_FILENAME, GAMEINFO_FILENAME ); }
//----------------------------------------------------------------------------- // Purpose: // Input : argc - // argv[] - // Output : int //----------------------------------------------------------------------------- int main( int argc, char* argv[] ) { SpewOutputFunc( SpewFunc ); SpewActivate( "demoinfo", 2 ); int i; for ( i=1 ; i<argc ; i++) { if ( argv[ i ][ 0 ] == '-' ) { switch( argv[ i ][ 1 ] ) { case 'l': uselogfile = true; break; case 'v': verbose = true; break; case 'g': ++i; break; default: printusage(); break; } } } if ( argc < 2 || ( i != argc ) ) { PrintHeader(); printusage(); } CheckLogFile(); PrintHeader(); vprint( 0, " Info for %s..\n", argv[ i - 1 ] ); char workingdir[ 256 ]; workingdir[0] = 0; Q_getwd( workingdir, sizeof( workingdir ) ); if ( !FileSystem_Init( NULL, 0, FS_INIT_FULL ) ) return 1; // Add this so relative filenames work. g_pFullFileSystem->AddSearchPath( workingdir, "game", PATH_ADD_TO_HEAD ); // Load the demo CSmoothingContext context; LoadSmoothingInfo( argv[ i - 1 ], context ); // Note to tool makers: // Do your work here!!! //Performsmoothing( context ); // Save out updated .dem file // UNCOMMENT THIS TO ENABLE OUTPUTTING NEW .DEM FILES!!! // SaveSmoothingInfo( argv[ i - 1 ], context ); FileSystem_Term(); return 0; }
void SetQdirFromPath (char *path) { char temp[1024]; char *c; int len; if (!(path[0] == '/' || path[0] == '\\' || path[1] == ':')) { // path is partial Q_getwd (temp); strcat (temp, path); path = temp; } // search for "quake2" in path #if 1 len = strlen(BASEDIRNAME); for (c=path+strlen(path)-1 ; c != path ; c--) { if (!Q_strncasecmp (c, BASEDIRNAME, len)) { strncpy (qdir, path, c-path); Sys_Printf ("qdir: %s\n", qdir); while (*c) { if (*c == '/' || *c == '\\') { strncpy (gamedir, path, c+1-path); Sys_Printf ("gamedir: %s\n", gamedir); return; } c++; } // assert(0); Error ("Gamedir at root in %s", path); return; } } // assert(0); Error ("SetQdirFromPath: no '%s' in %s", BASEDIRNAME, path); #else len = strlen(BASEDIRNAME); for (c=path+strlen(path)-1 ; c != path ; c--) if (!Q_strncasecmp (c, BASEDIRNAME, len)) { strncpy (qdir, path, c+len+1-path); qprintf ("qdir: %s\n", qdir); c += len+1; while (*c) { if (*c == '/' || *c == '\\') { strncpy (gamedir, path, c+1-path); qprintf ("gamedir: %s\n", gamedir); return; } c++; } Error ("No gamedir in %s", path); return; } Error ("SetQdirFromPath: no '%s' in %s", BASEDIRNAME, path); #endif }
//----------------------------------------------------------------------------- // Purpose: // Input : argc - // argv[] - // Output : int //----------------------------------------------------------------------------- int main( int argc, char* argv[] ) { SpewOutputFunc( SpewFunc ); SpewActivate( "unusedcontent", 2 ); CommandLine()->CreateCmdLine( argc, argv ); int i=1; for ( i ; i<argc ; i++) { if ( argv[ i ][ 0 ] == '-' ) { switch( argv[ i ][ 1 ] ) { case 'l': uselogfile = true; break; case 'v': verbose = true; break; case 'r': showreferencedfiles = true; break; case 'd': spewdeletions = true; break; case 'i': immediatedelete = true; break; case 'w': printwhitelist = true; break; case 'm': showmapfileusage = true; break; case 'g': // Just skip -game Assert( !Q_stricmp( argv[ i ], "-game" ) ); ++i; break; case 'f': // grab reslists folder { ++i; Q_strncpy( g_szReslistDir, argv[ i ], sizeof( g_szReslistDir ) ); Q_strlower( g_szReslistDir ); Q_FixSlashes( g_szReslistDir ); Q_AppendSlash( g_szReslistDir, sizeof( g_szReslistDir ) ); } break; default: printusage(); break; } } } if ( argc < 3 || ( i != argc ) ) { PrintHeader(); printusage(); return 0; } CheckLogFile(); PrintHeader(); vprint( 0, " Using reslist dir '%s'\n", g_szReslistDir ); vprint( 0, " Looking for extraneous content...\n" ); char resfile[ 256 ]; strcpy( resfile, argv[ i - 1 ] ); vprint( 0, " Comparing results of resfile (%s) with files under current directory...\n", resfile ); char workingdir[ 256 ]; workingdir[0] = 0; Q_getwd( workingdir, sizeof( workingdir ) ); // If they didn't specify -game on the command line, use VPROJECT. CmdLib_InitFileSystem( workingdir ); filesystem = (IFileSystem *)(CmdLib_GetFileSystemFactory()( FILESYSTEM_INTERFACE_VERSION, NULL )); if ( !filesystem ) { AssertMsg( 0, "Failed to create/get IFileSystem" ); return 1; } g_pFullFileSystem->RemoveAllSearchPaths(); g_pFullFileSystem->AddSearchPath(gamedir, "GAME"); Q_strlower( gamedir ); Q_FixSlashes( gamedir ); // //ProcessMaterialsDirectory( vmtdir ); // find out the mod dir name Q_strncpy( modname, gamedir, sizeof(modname) ); modname[ strlen(modname) - 1] = 0; if ( strrchr( modname, '\\' ) ) { Q_strncpy( modname, strrchr( modname, '\\' ) + 1, sizeof(modname) ); } else { Q_strncpy( modname, "", sizeof(modname) ); } vprint( 1, "Mod Name:%s\n", modname); BuildCheckdirList(); BuildWhiteList(); vprint( 0, "Building aggregate file list from resfile output\n" ); CUtlRBTree< ReferencedFile, int > referencedfiles( 0, 0, RefFileLessFunc ); CUtlVector< UnusedContent::CUtlSymbol > resfiles; BuildReferencedFileList( resfiles, referencedfiles, resfile ); vprint( 0, "found %i files\n\n", referencedfiles.Count() ); vprint( 0, "Building list of all game content files\n" ); CUtlVector< FileEntry > contentfiles; CUtlVector< FileEntry > otherfiles; BuildFileList( 0, contentfiles, &otherfiles, "", 0 ); vprint( 0, "found %i files in content tree\n\n", contentfiles.Count() ); Correlate( referencedfiles, contentfiles, modname ); // now output the files not referenced in the whitelist or general reslists filesystem->RemoveFile( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "GAME" ); int c = otherfiles.Count(); for ( i = 0; i < c; ++i ) { FileEntry & entry = otherfiles[ i ]; char const *name = g_Analysis.symbols.String( entry.sym ); logprint( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, name ); } // also include the files from deletions.bat, as we don't actually run that now c = contentfiles.Count(); for ( i = 0; i < c; ++i ) { FileEntry & entry = contentfiles[ i ]; if ( entry.referenced != REFERENCED_NO ) continue; char const *fn = g_Analysis.symbols.String( entry.sym ); logprint( CFmtStr( "%sunreferenced_files.lst", g_szReslistDir ), "\"%s\\%s\"\n", modname, fn ); } FileSystem_Term(); return 0; }
static void LoadMaterialList( FILE *fp, long thisChunkLen, _3DSMaterial_t *pMat ){ long chunkLen; unsigned short chunkID; long bytesRead = 0; _3DSMaterial_t mat; char curdir[1024]; char buffer[2048]; memset( &mat, 0, sizeof( mat ) ); if ( s_verbose ) { printf( " >>> MATERIAL LIST\n" ); } while ( ReadChunkAndLength( fp, &chunkID, &chunkLen ) ) { switch ( chunkID ) { case _3DS_CHUNK_MAT_NAME: fread( mat.name, chunkLen - 6, 1, fp ); if ( s_verbose ) { printf( " found mat name '%s'\n", mat.name ); } break; case _3DS_CHUNK_TEXMAP: LoadMapName( fp, mat.texture, chunkLen - 6 ); if ( s_verbose ) { printf( " found texture '%s'\n", mat.texture ); } break; case _3DS_CHUNK_SPECMAP: LoadMapName( fp, mat.specular, chunkLen - 6 ); if ( s_verbose ) { printf( " found specular map '%s'\n", mat.specular ); } break; case _3DS_CHUNK_OPACMAP: LoadMapName( fp, mat.opacity, chunkLen - 6 ); if ( s_verbose ) { printf( " found opacity map '%s'\n", mat.opacity ); } break; case _3DS_CHUNK_REFLMAP: LoadMapName( fp, mat.reflection, chunkLen - 6 ); if ( s_verbose ) { printf( " found reflection map '%s'\n", mat.reflection ); } break; case _3DS_CHUNK_BUMPMAP: LoadMapName( fp, mat.bump, chunkLen - 6 ); if ( s_verbose ) { printf( " found bump map '%s'\n", mat.bump ); } break; default: fread( s_buffer, chunkLen - 6, 1, fp ); break; } bytesRead += chunkLen; if ( bytesRead >= thisChunkLen ) { break; } } Q_getwd( curdir ); if ( mat.texture[0] ) { sprintf( buffer, "%s%s", curdir, mat.texture ); if ( strstr( buffer, gamedir + 1 ) ) { strcpy( mat.texture, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); } else{ strcpy( mat.texture, buffer ); } } if ( mat.specular[0] ) { sprintf( buffer, "%s%s", curdir, mat.specular ); if ( strstr( buffer, gamedir + 1 ) ) { strcpy( mat.specular, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); } else{ strcpy( mat.specular, buffer ); } } if ( mat.bump[0] ) { sprintf( buffer, "%s%s", curdir, mat.bump ); if ( strstr( buffer, gamedir + 1 ) ) { strcpy( mat.bump, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); } else{ strcpy( mat.bump, buffer ); } } if ( mat.reflection[0] ) { sprintf( buffer, "%s%s", curdir, mat.reflection ); if ( strstr( buffer, gamedir + 1 ) ) { strcpy( mat.reflection, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); } else{ strcpy( mat.reflection, buffer ); } } if ( mat.opacity[0] ) { sprintf( buffer, "%s%s", curdir, mat.opacity ); if ( strstr( buffer, gamedir + 1 ) ) { strcpy( mat.opacity, strstr( buffer, gamedir + 1 ) + strlen( gamedir ) - 1 ); } else{ strcpy( mat.opacity, buffer ); } } *pMat = mat; }
main (int argc, char *argv[]) { int i; CommandLine()->CreateCmdLine( argc, argv ); SpewOutputFunc( HLFacePoserSpewFunc ); MathLib_Init( 2.2f, 2.2f, 0.0f, 2.0f ); CoInitialize(NULL); // make sure, we start in the right directory char szName[256]; strcpy (szName, mx::getApplicationPath() ); mx::init (argc, argv); sound->Init(); FileSystem_Init( true ); filesystem = (IFileSystem *)(FileSystem_GetFactory()( FILESYSTEM_INTERFACE_VERSION, NULL )); if ( !filesystem ) { AssertMsg( 0, "Failed to create/get IFileSystem" ); return 1; } char workingdir[ 256 ]; workingdir[0] = 0; Q_getwd( workingdir ); // If they didn't specify -game on the command line, use VPROJECT. CmdLib_InitFileSystem( workingdir, true ); IFacePoserToolWindow::EnableToolRedraw( false ); new MDLViewer (); g_MDLViewer->setMenuBar (g_MDLViewer->getMenuBar ()); g_pStudioModel->Init(); bool modelloaded = false; for ( i = 1; i < CommandLine()->ParmCount(); i++ ) { if ( Q_stristr (CommandLine()->GetParm( i ), ".mdl") ) { modelloaded = true; g_MDLViewer->LoadModelFile( CommandLine()->GetParm( i ) ); break; } } models->LoadModelList(); if ( models->Count() == 0 ) { g_pFlexPanel->initFlexes( ); } // Load expressions from last time int files = workspacefiles->GetNumStoredFiles( IWorkspaceFiles::EXPRESSION ); for ( i = 0; i < files; i++ ) { expressions->LoadClass( workspacefiles->GetStoredFile( IWorkspaceFiles::EXPRESSION, i ) ); } IFacePoserToolWindow::EnableToolRedraw( true ); int retval = mx::run(); soundemitter->BaseShutdown(); if (g_pStudioModel) { g_pStudioModel->Shutdown(); g_pStudioModel = NULL; } if (g_pMaterialSystem) { g_pMaterialSystem->Shutdown(); g_pMaterialSystem = NULL; } FileSystem_Term(); CoUninitialize(); return retval; }
int main(int argc, char* argv[]) { SpewOutputFunc( SceneManagerSpewFunc ); // // make sure, we start in the right directory // char szName[256]; strcpy (szName, mx::getApplicationPath ()); if (argc > 1) { strcpy (cmdline, argv[1]); for (int i = 2; i < argc; i++) { strcat (cmdline, " "); strcat (cmdline, argv[i]); } } mx::init (argc, argv); FileSystem_Init( true ); filesystem = (IFileSystem *)(FileSystem_GetFactory()( FILESYSTEM_INTERFACE_VERSION, NULL )); if ( !filesystem ) { AssertMsg( 0, "Failed to create/get IFileSystem" ); return 1; } char workingdir[ 256 ]; workingdir[0] = 0; Q_getwd( workingdir ); char *vproject = getenv("VPROJECT"); if ( !vproject ) { mxMessageBox( NULL, "You must set VPROJECT to run scenemanager.exe", "SceneManager", MB_OK ); return -1; } // If they didn't specify -game on the command line, use VPROJECT. CmdLib_InitFileSystem( workingdir, true ); sound->Init(); CWorkspaceManager *sm = new CWorkspaceManager(); bool workspace_loaded = false; for ( int i = 1; i < argc; i++ ) { if ( !workspace_loaded && strstr (argv[i], ".vsw") ) { workspace_loaded = true; // Strip game directory and slash char workspace_name[ 512 ]; filesystem->FullPathToRelativePath( argv[ i ], workspace_name ); sm->AutoLoad( workspace_name ); } } if ( !workspace_loaded ) { sm->AutoLoad( NULL ); } int retval = mx::run (); sound->Shutdown(); soundemitter->BaseShutdown(); FileSystem_Term(); return retval; }
//----------------------------------------------------------------------------- // Purpose: // Input : argc - // argv[] - // Output : int //----------------------------------------------------------------------------- int main( int argc, char* argv[] ) { SpewOutputFunc( SpewFunc ); SpewActivate( "vcd_sound_check", 2 ); int i=1; for ( i ; i<argc ; i++) { if ( argv[ i ][ 0 ] == '-' ) { switch( argv[ i ][ 1 ] ) { case 'l': uselogfile = true; break; case 'v': verbose = true; break; case 'm': spewmoveto = true; break; case 'o': vcdonly = true; break; default: printusage(); break; } } } if ( argc < 3 || ( i != argc ) ) { PrintHeader(); printusage(); } CheckLogFile(); PrintHeader(); vprint( 0, " Looking for .wav files not referenced in .vcd files...\n" ); char sounddir[ 256 ]; char vcddir[ 256 ]; strcpy( sounddir, argv[ i - 2 ] ); strcpy( vcddir, argv[ i - 1 ] ); if ( !strstr( sounddir, "sound" ) ) { vprint( 0, "Sound dir %s looks invalid (format: u:/tf2/hl2/sound/vo)\n", sounddir ); return 0; } if ( !strstr( vcddir, "scenes" ) ) { vprint( 0, ".vcd dir %s looks invalid (format: u:/tf2/hl2/scenes)\n", vcddir ); return 0; } char workingdir[ 256 ]; workingdir[0] = 0; Q_getwd( workingdir, sizeof( workingdir ) ); // If they didn't specify -game on the command line, use VPROJECT. CmdLib_InitFileSystem( workingdir ); CSysModule *pSoundEmitterModule = g_pFullFileSystem->LoadModule( "soundemittersystem.dll" ); if ( !pSoundEmitterModule ) { vprint( 0, "Sys_LoadModule( soundemittersystem.dll ) failed!\n" ); return 0; } CreateInterfaceFn hSoundEmitterFactory = Sys_GetFactory( pSoundEmitterModule ); if ( !hSoundEmitterFactory ) { vprint( 0, "Sys_GetFactory on soundemittersystem.dll failed!\n" ); return 0; } soundemitter = ( ISoundEmitterSystemBase * )hSoundEmitterFactory( SOUNDEMITTERSYSTEM_INTERFACE_VERSION, NULL ); if ( !soundemitter ) { vprint( 0, "Couldn't get interface %s from soundemittersystem.dll!\n", SOUNDEMITTERSYSTEM_INTERFACE_VERSION ); return 0; } filesystem = (IFileSystem *)(CmdLib_GetFileSystemFactory()( FILESYSTEM_INTERFACE_VERSION, NULL )); if ( !filesystem ) { AssertMsg( 0, "Failed to create/get IFileSystem" ); return 1; } Q_FixSlashes( gamedir ); Q_strlower( gamedir ); vprint( 0, "game dir %s\nsounds dir %s\nvcd dir %s\n\n", gamedir, sounddir, vcddir ); Q_StripTrailingSlash( sounddir ); Q_StripTrailingSlash( vcddir ); filesystem->RemoveFile( "moveto.txt", "GAME" ); // //ProcessMaterialsDirectory( vmtdir ); vprint( 0, "Initializing sound emitter system\n" ); soundemitter->Connect( FileSystem_GetFactory() ); soundemitter->Init(); vprint( 0, "Loaded %i sounds\n", soundemitter->GetSoundCount() ); vprint( 0, "Building list of .vcd files\n" ); CUtlVector< CUtlSymbol > vcdfiles; BuildFileList( vcdfiles, vcddir, ".vcd" ); vprint( 0, "found %i .vcd files\n\n", vcdfiles.Count() ); vprint( 0, "Building list of known .wav files\n" ); CUtlVector< CUtlSymbol > wavfiles; BuildFileList( wavfiles, sounddir, ".wav" ); vprint( 0, "found %i .wav files\n\n", wavfiles.Count() ); CorrelateWavsAndVCDs( vcdfiles, wavfiles ); soundemitter->Shutdown(); soundemitter = 0; g_pFullFileSystem->UnloadModule( pSoundEmitterModule ); FileSystem_Term(); return 0; }