SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) { // Hopefully two threads won't call this simultaneously right at the start! if ( !g_bSpewCSInitted ) { InitializeCriticalSection( &g_SpewCS ); g_bSpewCSInitted = true; } WORD old; SpewRetval_t retVal; EnterCriticalSection( &g_SpewCS ); { if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG )) { old = SetConsoleTextColor( 1, 1, 1, 0 ); retVal = SPEW_CONTINUE; } else if( type == SPEW_WARNING ) { old = SetConsoleTextColor( 1, 1, 0, 1 ); retVal = SPEW_CONTINUE; } else if( type == SPEW_ASSERT ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_DEBUGGER; #ifdef MPI // VMPI workers don't want to bring up dialogs and suchlike. if ( g_bUseMPI && !g_bMPIMaster ) { VMPI_HandleCrash( pMsg, true ); exit( 0 ); } #endif } else if( type == SPEW_ERROR ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_ABORT; // doesn't matter.. we exit below so we can return an errorlevel (which dbg.dll doesn't do). } else { old = SetConsoleTextColor( 1, 1, 1, 1 ); retVal = SPEW_CONTINUE; } if ( !g_bSuppressPrintfOutput || type == SPEW_ERROR ) printf( "%s", pMsg ); OutputDebugString( pMsg ); if ( type == SPEW_ERROR ) { printf( "\n" ); OutputDebugString( "\n" ); } if( g_pLogFile ) { CmdLib_FPrintf( g_pLogFile, "%s", pMsg ); g_pFileSystem->Flush( g_pLogFile ); } // Dispatch to other spew hooks. FOR_EACH_LL( g_ExtraSpewHooks, i ) g_ExtraSpewHooks[i]( pMsg ); RestoreConsoleTextColor( old ); } LeaveCriticalSection( &g_SpewCS ); if ( type == SPEW_ERROR ) { CmdLib_Exit( 1 ); } return retVal; }
//----------------------------------------- // // Run PortalFlow across all available processing nodes // void RunMPIPortalFlow() { Msg( "%-20s ", "MPIPortalFlow:" ); if ( g_bMPIMaster ) StartPacifier(""); // Workers wait until we get the MC socket address. g_PortalMCThreadUniqueID = StatsDB_GetUniqueJobID(); if ( g_bMPIMaster ) { CCycleCount cnt; cnt.Sample(); CUniformRandomStream randomStream; randomStream.SetSeed( cnt.GetMicroseconds() ); g_PortalMCAddr.port = randomStream.RandomInt( 22000, 25000 ); // Pulled out of something else. g_PortalMCAddr.ip[0] = (unsigned char)RandomInt( 225, 238 ); g_PortalMCAddr.ip[1] = (unsigned char)RandomInt( 0, 255 ); g_PortalMCAddr.ip[2] = (unsigned char)RandomInt( 0, 255 ); g_PortalMCAddr.ip[3] = (unsigned char)RandomInt( 3, 255 ); g_pPortalMCSocket = CreateIPSocket(); int i=0; for ( i; i < 5; i++ ) { if ( g_pPortalMCSocket->BindToAny( randomStream.RandomInt( 20000, 30000 ) ) ) break; } if ( i == 5 ) { Error( "RunMPIPortalFlow: can't open a socket to multicast on." ); } char cPacketID[2] = { VMPI_VVIS_PACKET_ID, VMPI_SUBPACKETID_MC_ADDR }; VMPI_Send2Chunks( cPacketID, sizeof( cPacketID ), &g_PortalMCAddr, sizeof( g_PortalMCAddr ), VMPI_PERSISTENT ); } else { VMPI_SetCurrentStage( "wait for MC address" ); while ( !g_bGotMCAddr ) { VMPI_DispatchNextMessage(); } // Open our multicast receive socket. g_pPortalMCSocket = CreateMulticastListenSocket( g_PortalMCAddr ); if ( !g_pPortalMCSocket ) { char err[512]; IP_GetLastErrorString( err, sizeof( err ) ); Error( "RunMPIPortalFlow: CreateMulticastListenSocket failed. (%s).", err ); } // Make a thread to listen for the data on the multicast socket. DWORD dwDummy = 0; g_MCThreadExitEvent.Init( false, false ); // Make sure we kill the MC thread if the app exits ungracefully. CmdLib_AtCleanup( MCThreadCleanupFn ); g_hMCThread = CreateThread( NULL, 0, PortalMCThreadFn, NULL, 0, &dwDummy ); if ( !g_hMCThread ) { Error( "RunMPIPortalFlow: CreateThread failed for multicast receive thread." ); } } VMPI_SetCurrentStage( "RunMPIBasePortalFlow" ); g_pDistributeWorkCallbacks = &g_VisDistributeWorkCallbacks; g_CPUTime.Init(); double elapsed = DistributeWork( g_numportals * 2, // # work units VMPI_DISTRIBUTEWORK_PACKETID, // packet ID ProcessPortalFlow, // Worker function to process work units ReceivePortalFlow // Master function to receive work results ); g_pDistributeWorkCallbacks = NULL; CheckExitedEarly(); // Stop the multicast stuff. VMPI_DeletePortalMCSocket(); if( !g_bMPIMaster ) { if ( g_iVMPIVerboseLevel >= 1 ) { Msg( "Received %d (out of %d) portals from multicast.\n", g_nMulticastPortalsReceived, g_numportals * 2 ); Msg( "%.1f%% CPU utilization during PortalFlow\n", (g_CPUTime.GetSeconds() * 100.0f / elapsed) / numthreads ); } Msg( "VVIS worker finished. Over and out.\n" ); VMPI_SetCurrentStage( "worker done" ); CmdLib_Exit( 0 ); } if ( g_bMPIMaster ) { EndPacifier( false ); Msg( " (%d)\n", (int)elapsed ); } }
SpewRetval_t CmdLib_SpewOutputFunc( SpewType_t type, char const *pMsg ) { // Hopefully two threads won't call this simultaneously right at the start! if ( !g_bSpewCSInitted ) { InitializeCriticalSection( &g_SpewCS ); g_bSpewCSInitted = true; } WORD old; SpewRetval_t retVal; EnterCriticalSection( &g_SpewCS ); { if (( type == SPEW_MESSAGE ) || (type == SPEW_LOG )) { Color c = GetSpewOutputColor(); if ( c.r() != 255 || c.g() != 255 || c.b() != 255 ) { // custom color old = SetConsoleTextColor( c.r(), c.g(), c.b(), c.a() ); } else { old = SetConsoleTextColor( 1, 1, 1, 0 ); } retVal = SPEW_CONTINUE; } else if( type == SPEW_WARNING ) { old = SetConsoleTextColor( 1, 1, 0, 1 ); retVal = SPEW_CONTINUE; } else if( type == SPEW_ASSERT ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_DEBUGGER; #ifdef MPI // VMPI workers don't want to bring up dialogs and suchlike. // They need to have a special function installed to handle // the exceptions and write the minidumps. // Install the function after VMPI_Init with a call: // SetupToolsMinidumpHandler( VMPI_ExceptionFilter ); if ( g_bUseMPI && !g_bMPIMaster && !Plat_IsInDebugSession() ) { // Generating an exception and letting the // installed handler handle it ::RaiseException ( 0, // dwExceptionCode EXCEPTION_NONCONTINUABLE, // dwExceptionFlags 0, // nNumberOfArguments, NULL // const ULONG_PTR* lpArguments ); // Never get here (non-continuable exception) VMPI_HandleCrash( pMsg, NULL, true ); exit( 0 ); } #endif } else if( type == SPEW_ERROR ) { old = SetConsoleTextColor( 1, 0, 0, 1 ); retVal = SPEW_ABORT; // doesn't matter.. we exit below so we can return an errorlevel (which dbg.dll doesn't do). } else { old = SetConsoleTextColor( 1, 1, 1, 1 ); retVal = SPEW_CONTINUE; } if ( !g_bSuppressPrintfOutput || type == SPEW_ERROR ) printf( "%s", pMsg ); OutputDebugString( pMsg ); if ( type == SPEW_ERROR ) { printf( "\n" ); OutputDebugString( "\n" ); } if( g_pLogFile ) { CmdLib_FPrintf( g_pLogFile, "%s", pMsg ); g_pFileSystem->Flush( g_pLogFile ); } // Dispatch to other spew hooks. FOR_EACH_LL( g_ExtraSpewHooks, i ) g_ExtraSpewHooks[i]( pMsg ); RestoreConsoleTextColor( old ); } LeaveCriticalSection( &g_SpewCS ); if ( type == SPEW_ERROR ) { CmdLib_Exit( 1 ); } return retVal; }
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; }
int RunVVis( int argc, char **argv ) { char portalfile[1024]; char source[1024]; double start, end; Msg( "Valve Software - vvis.exe (%s)\n", __DATE__ ); verbose = false; Q_StripExtension( argv[ argc - 1 ], source, sizeof( source ) ); CmdLib_InitFileSystem( argv[ argc - 1 ] ); Q_FileBase( source, source, sizeof( source ) ); LoadCmdLineFromFile( argc, argv, source, "vvis" ); int i = ParseCommandLine( argc, argv ); // This part is just for VMPI. VMPI's file system needs the basedir in front of all filenames, // so we prepend qdir here. strcpy( source, ExpandPath( source ) ); if (i != argc - 1) { PrintUsage( argc, argv ); DeleteCmdLine( argc, argv ); CmdLib_Exit( 1 ); } start = Plat_FloatTime(); if (!g_bUseMPI) { // Setup the logfile. char logFile[512]; _snprintf( logFile, sizeof(logFile), "%s.log", source ); SetSpewFunctionLogFile( logFile ); } // Run in the background? if( g_bLowPriority ) { SetLowPriority(); } ThreadSetDefault (); char targetPath[1024]; GetPlatformMapPath( source, targetPath, 0, 1024 ); Msg ("reading %s\n", targetPath); LoadBSPFile (targetPath); if (numnodes == 0 || numfaces == 0) Error ("Empty map"); ParseEntities (); // Check the VMF for a vis radius if (!g_bUseRadius) { float flRadius = DetermineVisRadius( ); if (flRadius > 0.0f) { g_bUseRadius = true; g_VisRadius = flRadius * flRadius; } } if ( g_bUseRadius ) { MarkLeavesAsRadial(); } if ( inbase[0] == 0 ) { strcpy( portalfile, source ); } else { sprintf ( portalfile, "%s%s", inbase, argv[i] ); Q_StripExtension( portalfile, portalfile, sizeof( portalfile ) ); } strcat (portalfile, ".prt"); Msg ("reading %s\n", portalfile); LoadPortals (portalfile); CalcVis (); CalcPAS (); // We need a mapping from cluster to leaves, since the PVS // deals with clusters for both CalcVisibleFogVolumes and BuildClusterTable(); CalcVisibleFogVolumes(); CalcDistanceFromLeavesToWater(); visdatasize = vismap_p - dvisdata; Msg ("visdatasize:%i compressed from %i\n", visdatasize, originalvismapsize*2); Msg ("writing %s\n", targetPath); WriteBSPFile (targetPath); end = Plat_FloatTime(); char str[512]; GetHourMinuteSecondsString( (int)( end - start ), str, sizeof( str ) ); Msg( "%s elapsed\n", str ); DeleteCmdLine( argc, argv ); CmdLib_Cleanup(); return 0; }