Example #1
0
//-----------------------------------------------------------------------------
// 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;
}
//-----------------------------------------------------------------------------
// 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;
}
Example #3
0
static int luasrc_SpewActivate (lua_State *L) {
  SpewActivate(luaL_checkstring(L, 1), luaL_checkint(L, 2));
  return 0;
}
Example #4
0
int RunVBSP( int argc, char **argv )
{
	int		i;
	double		start, end;
	char		path[1024];

	CommandLine()->CreateCmdLine( argc, argv );
	MathLib_Init( 2.2f, 2.2f, 0.0f, OVERBRIGHT, false, false, false, false );
	InstallSpewFunction();
	SpewActivate( "developer", 1 );
	
	CmdLib_InitFileSystem( argv[ argc-1 ] );

	Q_StripExtension( ExpandArg( argv[ argc-1 ] ), source, sizeof( source ) );
	Q_FileBase( source, mapbase, sizeof( mapbase ) );
	strlwr( mapbase );

	LoadCmdLineFromFile( argc, argv, mapbase, "vbsp" );

	Msg( "Valve Software - vbsp.exe (%s)\n", __DATE__ );

	for (i=1 ; i<argc ; i++)
	{
		if (!stricmp(argv[i],"-threads"))
		{
			numthreads = atoi (argv[i+1]);
			i++;
		}
		else if (!Q_stricmp(argv[i],"-glview"))
		{
			glview = true;
		}
		else if ( !Q_stricmp(argv[i], "-v") || !Q_stricmp(argv[i], "-verbose") )
		{
			Msg("verbose = true\n");
			verbose = true;
		}
		else if (!Q_stricmp(argv[i], "-noweld"))
		{
			Msg ("noweld = true\n");
			noweld = true;
		}
		else if (!Q_stricmp(argv[i], "-nocsg"))
		{
			Msg ("nocsg = true\n");
			nocsg = true;
		}
		else if (!Q_stricmp(argv[i], "-noshare"))
		{
			Msg ("noshare = true\n");
			noshare = true;
		}
		else if (!Q_stricmp(argv[i], "-notjunc"))
		{
			Msg ("notjunc = true\n");
			notjunc = true;
		}
		else if (!Q_stricmp(argv[i], "-nowater"))
		{
			Msg ("nowater = true\n");
			nowater = true;
		}
		else if (!Q_stricmp(argv[i], "-noopt"))
		{
			Msg ("noopt = true\n");
			noopt = true;
		}
		else if (!Q_stricmp(argv[i], "-noprune"))
		{
			Msg ("noprune = true\n");
			noprune = true;
		}
		else if (!Q_stricmp(argv[i], "-nomerge"))
		{
			Msg ("nomerge = true\n");
			nomerge = true;
		}
		else if (!Q_stricmp(argv[i], "-nomergewater"))
		{
			Msg ("nomergewater = true\n");
			nomergewater = true;
		}
		else if (!Q_stricmp(argv[i], "-nosubdiv"))
		{
			Msg ("nosubdiv = true\n");
			nosubdiv = true;
		}
		else if (!Q_stricmp(argv[i], "-nodetail"))
		{
			Msg ("nodetail = true\n");
			nodetail = true;
		}
		else if (!Q_stricmp(argv[i], "-fulldetail"))
		{
			Msg ("fulldetail = true\n");
			fulldetail = true;
		}
		else if (!Q_stricmp(argv[i], "-onlyents"))
		{
			Msg ("onlyents = true\n");
			onlyents = true;
		}
		else if (!Q_stricmp(argv[i], "-onlyprops"))
		{
			Msg ("onlyprops = true\n");
			onlyprops = true;
		}
		else if (!Q_stricmp(argv[i], "-micro"))
		{
			microvolume = atof(argv[i+1]);
			Msg ("microvolume = %f\n", microvolume);
			i++;
		}
		else if (!Q_stricmp(argv[i], "-leaktest"))
		{
			Msg ("leaktest = true\n");
			leaktest = true;
		}
		else if (!Q_stricmp(argv[i], "-verboseentities"))
		{
			Msg ("verboseentities = true\n");
			verboseentities = true;
		}
		else if (!Q_stricmp(argv[i], "-snapaxial"))
		{
			Msg ("snap axial = true\n");
			g_snapAxialPlanes = true;
		}
#if 0
		else if (!Q_stricmp(argv[i], "-maxlightmapdim"))
		{
			g_maxLightmapDimension = atof(argv[i+1]);
			Msg ("g_maxLightmapDimension = %f\n", g_maxLightmapDimension);
			i++;
		}
#endif
		else if (!Q_stricmp(argv[i], "-block"))
		{
			block_xl = block_xh = atoi(argv[i+1]);
			block_yl = block_yh = atoi(argv[i+2]);
			Msg ("block: %i,%i\n", block_xl, block_yl);
			i+=2;
		}
		else if (!Q_stricmp(argv[i], "-blocks"))
		{
			block_xl = atoi(argv[i+1]);
			block_yl = atoi(argv[i+2]);
			block_xh = atoi(argv[i+3]);
			block_yh = atoi(argv[i+4]);
			Msg ("blocks: %i,%i to %i,%i\n", 
				block_xl, block_yl, block_xh, block_yh);
			i+=4;
		}
		else if ( !Q_stricmp( argv[i], "-dumpcollide" ) )
		{
			Msg("Dumping collision models to collideXXX.txt\n" );
			dumpcollide = true;
		}
		else if ( !Q_stricmp( argv[i], "-dumpstaticprop" ) )
		{
			Msg("Dumping static props to staticpropXXX.txt\n" );
			g_DumpStaticProps = true;
		}
		else if ( !Q_stricmp( argv[i], "-forceskyvis" ) )
		{
			Msg("Enabled vis in 3d skybox\n" );
			g_bSkyVis = true;
		}
		else if (!Q_stricmp (argv[i],"-tmpout"))
		{
			strcpy (outbase, "/tmp");
		}
#if 0
		else if( !Q_stricmp( argv[i], "-defaultluxelsize" ) )
		{
			g_defaultLuxelSize = atof( argv[i+1] );
			i++;
		}
#endif
		else if( !Q_stricmp( argv[i], "-luxelscale" ) )
		{
			g_luxelScale = atof( argv[i+1] );
			i++;
		}
		else if( !strcmp( argv[i], "-minluxelscale" ) )
		{
			g_minLuxelScale = atof( argv[i+1] );
			if (g_minLuxelScale < 1)
				g_minLuxelScale = 1;
			i++;
		}
		else if( !Q_stricmp( argv[i], "-dxlevel" ) )
		{
			g_nDXLevel = atoi( argv[i+1] );
			Msg( "DXLevel = %d\n", g_nDXLevel );
			i++;
		}
		else if( !Q_stricmp( argv[i], "-bumpall" ) )
		{
			g_BumpAll = true;
		}
		else if( !Q_stricmp( argv[i], "-low" ) )
		{
			g_bLowPriority = true;
		}
		else if( !Q_stricmp( argv[i], "-lightifmissing" ) )
		{
			g_bLightIfMissing = true;
		}
		else if ( !Q_stricmp( argv[i], CMDLINEOPTION_NOVCONFIG ) )
		{
		}
		else if ( !Q_stricmp( argv[i], "-allowdebug" ) || !Q_stricmp( argv[i], "-steam" ) )
		{
			// nothing to do here, but don't bail on this option
		}
		else if ( !Q_stricmp( argv[i], "-vproject" ) || !Q_stricmp( argv[i], "-game" ) )
		{
			++i;
		}
		else if ( !Q_stricmp( argv[i], "-keepstalezip" ) )
		{
			g_bKeepStaleZip = true;
		}
		else if ( !Q_stricmp( argv[i], "-xbox" ) )
		{
			// enable mandatory xbox extensions
			g_NodrawTriggers = true;
			g_DisableWaterLighting = true;
		}
		else if ( !Q_stricmp( argv[i], "-allowdetailcracks"))
		{
			g_bAllowDetailCracks = true;
		}
		else if ( !Q_stricmp( argv[i], "-novirtualmesh"))
		{
			g_bNoVirtualMesh = true;
		}
		else if ( !Q_stricmp( argv[i], "-replacematerials" ) )
		{
			g_ReplaceMaterials = true;
		}
		else if ( !Q_stricmp(argv[i], "-nodrawtriggers") )
		{
			g_NodrawTriggers = true;
		}
		else if ( !Q_stricmp( argv[i], "-FullMinidumps" ) )
		{
			EnableFullMinidumps( true );
		}
		else if (argv[i][0] == '-')
		{
			Warning("VBSP: Unknown option \"%s\"\n\n", argv[i]);
			i = 100000;	// force it to print the usage
			break;
		}
		else
			break;
	}

	if (i != argc - 1)
	{
		PrintCommandLine( argc, argv );

		Warning(	
			"usage  : vbsp [options...] mapfile\n"
			"example: vbsp -onlyents c:\\hl2\\hl2\\maps\\test\n"
			"\n"
			"Common options (use -v to see all options):\n"
			"\n"
			"  -v (or -verbose): Turn on verbose output (also shows more command\n"
			"                    line options).\n"
			"\n"
			"  -onlyents   : This option causes vbsp only import the entities from the .vmf\n"
			"                file. -onlyents won't reimport brush models.\n"
			"  -onlyprops  : Only update the static props and detail props.\n"
			"  -glview     : Writes .gl files in the current directory that can be viewed\n"
			"                with glview.exe. If you use -tmpout, it will write the files\n"
			"                into the \\tmp folder.\n"
			"  -nodetail   : Get rid of all detail geometry. The geometry left over is\n"
			"                what affects visibility.\n"
			"  -nowater    : Get rid of water brushes.\n"
			"  -low        : Run as an idle-priority process.\n"
			"\n"
			"  -vproject <directory> : Override the VPROJECT environment variable.\n"
			"  -game <directory>     : Same as -vproject.\n"
			"\n" );

		if ( verbose )
		{
			Warning(
				"Other options  :\n"
				"  -novconfig   : Don't bring up graphical UI on vproject errors.\n"
				"  -threads     : Control the number of threads vbsp uses (defaults to the # of\n"
				"                 processors on your machine).\n"
				"  -verboseentities: If -v is on, this disables verbose output for submodels.\n"
				"  -noweld      : Don't join face vertices together.\n"
				"  -nocsg       : Don't chop out intersecting brush areas.\n"
				"  -noshare     : Emit unique face edges instead of sharing them.\n"
				"  -notjunc     : Don't fixup t-junctions.\n"
				"  -noopt       : By default, vbsp removes the 'outer shell' of the map, which\n"
				"                 are all the faces you can't see because you can never get\n"
				"                 outside the map. -noopt disables this behaviour.\n"
				"  -noprune     : Don't prune neighboring solid nodes.\n"
				"  -nomerge     : Don't merge together chopped faces on nodes.\n"
				"  -nomergewater: Don't merge together chopped faces on water.\n"
				"  -nosubdiv    : Don't subdivide faces for lightmapping.\n"
				"  -micro <#>   : vbsp will warn when brushes are output with a volume less\n"
				"                 than this number (default: 1.0).\n"
				"  -fulldetail  : Mark all detail geometry as normal geometry (so all detail\n"
				"                 geometry will affect visibility).\n"
				"  -leaktest    : Stop processing the map if a leak is detected. Whether or not\n"
				"                 this flag is set, a leak file will be written out at\n"
				"                 <vmf filename>.lin, and it can be imported into Hammer.\n"
				"  -bumpall     : Force all surfaces to be bump mapped.\n"
				"  -snapaxial   : Snap axial planes to integer coordinates.\n"
				"  -block # #      : Control the grid size mins that vbsp chops the level on.\n"
				"  -blocks # # # # : Enter the mins and maxs for the grid size vbsp uses.\n"
				"  -dumpstaticprops: Dump static props to staticprop*.txt\n"
				"  -dumpcollide    : Write files with collision info.\n"
				"  -forceskyvis	   : Enable vis calculations in 3d skybox leaves\n"
				"  -luxelscale #   : Scale all lightmaps by this amount (default: 1.0).\n"
				"  -minluxelscale #: No luxel scale will be lower than this amount (default: 1.0).\n"
				"  -lightifmissing : Force lightmaps to be generated for all surfaces even if\n"
				"                    they don't need lightmaps.\n"
				"  -keepstalezip   : Keep the BSP's zip files intact but regenerate everything\n"
				"                    else.\n"
				"  -virtualdispphysics : Use virtual (not precomputed) displacement collision models\n"
				"  -xbox           : Enable mandatory xbox options\n"
				"  -x360		   : Generate Xbox360 version of vsp\n"
				"  -nox360		   : Disable generation Xbox360 version of vsp (default)\n"
				"  -replacematerials : Substitute materials according to materialsub.txt in content\\maps\n"
				"  -FullMinidumps  : Write large minidumps on crash.\n"
				);
			}

		DeleteCmdLine( argc, argv );
		CmdLib_Cleanup();
		CmdLib_Exit( 1 );
	}

	start = Plat_FloatTime();

	// Run in the background?
	if( g_bLowPriority )
	{
		SetLowPriority();
	}

	if( ( g_nDXLevel != 0 ) && ( g_nDXLevel < 80 ) )
	{
		g_BumpAll = false;
	}

	if( g_luxelScale == 1.0f )
	{
		if ( g_nDXLevel == 70 )
		{
			g_luxelScale = 4.0f;
		}
	}

	ThreadSetDefault ();
	numthreads = 1;		// multiple threads aren't helping...

	// Setup the logfile.
	char logFile[512];
	_snprintf( logFile, sizeof(logFile), "%s.log", source );
	SetSpewFunctionLogFile( logFile );

	LoadPhysicsDLL();
	LoadSurfaceProperties();

#if 0
	Msg( "qdir: %s  This is the the path of the initial source file \n", qdir );
	Msg( "gamedir: %s This is the base engine + mod-specific game dir (e.g. d:/tf2/mytfmod/) \n", gamedir );
	Msg( "basegamedir: %s This is the base engine + base game directory (e.g. e:/hl2/hl2/, or d:/tf2/tf2/ )\n", basegamedir );
#endif

	sprintf( materialPath, "%smaterials", gamedir );
	InitMaterialSystem( materialPath, CmdLib_GetFileSystemFactory() );
	Msg( "materialPath: %s\n", materialPath );
	
	// delete portal and line files
	sprintf (path, "%s.prt", source);
	remove (path);
	sprintf (path, "%s.lin", source);
	remove (path);

	strcpy (name, ExpandArg (argv[i]));	

	const char *pszExtension = V_GetFileExtension( name );
	if ( !pszExtension )
	{
		V_SetExtension( name, ".vmm", sizeof( name ) );
		if ( !FileExists( name ) )
		{
			V_SetExtension( name, ".vmf", sizeof( name ) );
		}
	}

	char platformBSPFileName[1024];
	GetPlatformMapPath( source, platformBSPFileName, g_nDXLevel, 1024 );
	
	// if we're combining materials, load the script file
	if ( g_ReplaceMaterials )
	{
		LoadMaterialReplacementKeys( gamedir, mapbase );
	}

	//
	// if onlyents, just grab the entites and resave
	//
	if (onlyents)
	{
		LoadBSPFile (platformBSPFileName);
		num_entities = 0;
		// Clear out the cubemap samples since they will be reparsed even with -onlyents
		g_nCubemapSamples = 0;

		// Mark as stale since the lighting could be screwed with new ents.
		AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false );

		LoadMapFile (name);
		SetModelNumbers ();
		SetLightStyles ();

		// NOTE: If we ever precompute lighting for static props in
		// vrad, EmitStaticProps should be removed here

		// Emit static props found in the .vmf file
		EmitStaticProps();

		// NOTE: Don't deal with detail props here, it blows away lighting

		// Recompute the skybox
		ComputeBoundsNoSkybox();

		// Make sure that we have a water lod control eneity if we have water in the map.
		EnsurePresenceOfWaterLODControlEntity();

		// Make sure the func_occluders have the appropriate data set
		FixupOnlyEntsOccluderEntities();

		// Doing this here because stuff abov may filter out entities
		UnparseEntities ();

		WriteBSPFile (platformBSPFileName);
	}
	else if (onlyprops)
	{
		// In the only props case, deal with static + detail props only
		LoadBSPFile (platformBSPFileName);

		LoadMapFile(name);
		SetModelNumbers();
		SetLightStyles();

		// Emit static props found in the .vmf file
		EmitStaticProps();

		// Place detail props found in .vmf and based on material properties
		LoadEmitDetailObjectDictionary( gamedir );
		EmitDetailObjects();

		WriteBSPFile (platformBSPFileName);
	}
	else
	{
		//
		// start from scratch
		//

		// Load just the file system from the bsp
		if( g_bKeepStaleZip && FileExists( platformBSPFileName ) )
		{
			LoadBSPFile_FileSystemOnly (platformBSPFileName);
			// Mark as stale since the lighting could be screwed with new ents.
			AddBufferToPak( GetPakFile(), "stale.txt", "stale", strlen( "stale" ) + 1, false );
		}

		LoadMapFile (name);
		WorldVertexTransitionFixup();
		if( ( g_nDXLevel == 0 ) || ( g_nDXLevel >= 70 ) )
		{
			Cubemap_FixupBrushSidesMaterials();
			Cubemap_AttachDefaultCubemapToSpecularSides();
			Cubemap_AddUnreferencedCubemaps();
		}
		SetModelNumbers ();
		SetLightStyles ();
		LoadEmitDetailObjectDictionary( gamedir );
		ProcessModels ();
	}

	end = Plat_FloatTime();
	
	char str[512];
	GetHourMinuteSecondsString( (int)( end - start ), str, sizeof( str ) );
	Msg( "%s elapsed\n", str );

	DeleteCmdLine( argc, argv );
	ReleasePakFileLumps();
	DeleteMaterialReplacementKeys();
	ShutdownMaterialSystem();
	CmdLib_Cleanup();
	return 0;
}
//-----------------------------------------------------------------------------
// Create all singleton systems
//-----------------------------------------------------------------------------
bool CSceneViewerApp::Create()
{
	if ( CommandLine()->FindParm( "-help" ) )
	{
		const bool newConsole( SetupWin32ConsoleIO() );

		Msg( "\n\n Sceneviewer - Loads and views Valve DMX Assets\n\n" );
		Msg( " Synopsis: sceneviewer [ vgui opts ] [ -help ] [ filename.[dmx|obj] ]\n" );
		Msg(
			"\n"
			" Where:\n"
			"\n"
			" Sceneviewer Options:\n"
			"\n"
			" -help . . . . . . Prints this information\n"
			" -nozoom . . . . . Stop sceneviewer zooming model viewer to occupy all client\n"
			"                   space when a dmx is specified on the command line\n"
			" -showasset  . . . Stop sceneviewer from hiding the asset builder when a dmx\n"
			"                   file is specified on the command line.\n"
			"  filename.dmx . . The name of a dmx file to load on start\n"
			"\n"
			" VGUI Options:\n"
			"\n"
			" -vproject <$> . . Override VPROJECT environment variable\n"
			" -game <$> . . . . Override VPROJECT environment variable\n"
			" -remote <$> . . . Add the remote share name\n"
			" -host <$> . . . . Set the host name\n"
			" -norfs  . . . . . Do not use remote filesystem\n"
			" -fullscreen . . . Run application fullscreen rather than in a window\n"
			" -width <#>  . . . Set the window width when running windowed\n"
			" -height <#> . . . Set the window height when running windowed\n"
			" -adapter <$>  . . Set the adapter??\n"
			" -ref  . . . . . . Set MATERIAL_INIT_REFERENCE_RASTERIZER on adapter??\n"
			" -resizing . . . . Allow the window to be resized\n"
			" -mat_vsync  . . . Wait for VSYNC\n"
			" -mat_antialias  . Turn on Anti-Aliasing\n"
			" -mat_aaquality  . Antialiasing quality (set to zero unless you know what you're doing)\n"
			"\n"
			);

		if ( newConsole )
		{
			Msg( "\n\nPress Any Key Continue..." );

			char tmpBuf[ 2 ];
			DWORD cRead;
			ReadConsole( GetStdHandle( STD_INPUT_HANDLE ), tmpBuf, 1, &cRead, NULL );
		}

		return false;
	}

	// FIXME: Enable vs30 shaders while NVidia driver bug exists
	CommandLine()->AppendParm( "-box", NULL );

	SpewOutputFunc( ModelBrowserSpewFunc );
	SpewActivate( "console", 1 );

	if ( !BaseClass::Create() )
		return false;

	AppSystemInfo_t appSystems[] = 
	{
		{ "vstdlib.dll",			PROCESS_UTILS_INTERFACE_VERSION },
		{ "studiorender.dll",		STUDIO_RENDER_INTERFACE_VERSION },
		{ "vphysics.dll",			VPHYSICS_INTERFACE_VERSION },
		{ "datacache.dll",			DATACACHE_INTERFACE_VERSION },
		{ "datacache.dll",			MDLCACHE_INTERFACE_VERSION },
		{ "p4lib.dll",				P4_INTERFACE_VERSION },
		{ "", "" }	// Required to terminate the list
	};

	AddSystem( g_pDataModel, VDATAMODEL_INTERFACE_VERSION );
	AddSystem( g_pDmElementFramework, VDMELEMENTFRAMEWORK_VERSION );
	AddSystem( g_pDmSerializers, DMSERIALIZERS_INTERFACE_VERSION );
	AddSystem( GetDefaultDmeMakefileUtils(), DMEMAKEFILE_UTILS_INTERFACE_VERSION );

	return AddSystems( appSystems );
}
//-----------------------------------------------------------------------------
// 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;
}