diff --git a/sp/src/utils/common/threads.cpp b/sp/src/utils/common/threads.cpp index 28f0894c..af34cf01 100644 --- a/sp/src/utils/common/threads.cpp +++ b/sp/src/utils/common/threads.cpp @@ -112,7 +112,11 @@ WIN32 =================================================================== */ +#ifdef MAPBASE +int numthreads = -(MAX_TOOL_THREADS + 1); +#else int numthreads = -1; +#endif CRITICAL_SECTION crit; static int enter; @@ -133,19 +137,37 @@ void SetLowPriority() SetPriorityClass( GetCurrentProcess(), IDLE_PRIORITY_CLASS ); } - +//Threads can be negative; if so, they will be subtracted from the total thread count. void ThreadSetDefault (void) { SYSTEM_INFO info; +#ifdef MAPBASE + if (numthreads == -(MAX_TOOL_THREADS + 1)) // not set manually +#else if (numthreads == -1) // not set manually +#endif { GetSystemInfo (&info); numthreads = info.dwNumberOfProcessors; - if (numthreads < 1 || numthreads > 32) +#ifdef MAPBASE + if (numthreads > 32) +#else + if (numthreads < 1 ||numthreads > 32) +#endif numthreads = 1; } +#ifdef MAPBASE + if (numthreads <= 0) + { + GetSystemInfo(&info); + numthreads = info.dwNumberOfProcessors + numthreads; + if (numthreads <= 0) + Error("\nIncrease the number of threads! Threads: %i, they cannot be negative or 0.\n", numthreads); + } +#endif + Msg ("%i threads\n", numthreads); } diff --git a/sp/src/utils/vbsp/vbsp.cpp b/sp/src/utils/vbsp/vbsp.cpp index 54d9e681..efcbd386 100644 --- a/sp/src/utils/vbsp/vbsp.cpp +++ b/sp/src/utils/vbsp/vbsp.cpp @@ -1313,8 +1313,9 @@ int RunVBSP( int argc, char **argv ) 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" + " -threads # : Control the number of threads vbsp uses (defaults to the #\n" + " or processors on your machine).\n" + " Threads can be negative; if so, they will be subtracted from the total thread count.\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" diff --git a/sp/src/utils/vrad/vrad.cpp b/sp/src/utils/vrad/vrad.cpp index 79cc467d..774af247 100644 --- a/sp/src/utils/vrad/vrad.cpp +++ b/sp/src/utils/vrad/vrad.cpp @@ -2431,11 +2431,13 @@ int ParseCommandLine( int argc, char **argv, bool *onlydetail ) if ( ++i < argc ) { numthreads = atoi (argv[i]); +#ifndef MAPBASE //Mapbase allows threads to be negative, go to ThreadSetDefault(void) in threads.cpp for a explanation. if ( numthreads <= 0 ) { Warning("Error: expected positive value after '-threads'\n" ); return 1; } +#endif } else { @@ -2827,8 +2829,9 @@ void PrintUsage( int argc, char **argv ) " -dump : Write debugging .txt files.\n" " -dumpnormals : Write normals to debug files.\n" " -dumptrace : Write ray-tracing environment to debug files.\n" - " -threads : Control the number of threads vbsp uses (defaults to the #\n" + " -threads # : Control the number of threads vrad uses (defaults to the #\n" " or processors on your machine).\n" + " Threads can be negative; if so, they will be subtracted from the total thread count.\n" " -lights : Load a lights file in addition to lights.rad and the\n" " level lights file.\n" " -noextra : Disable supersampling.\n" diff --git a/sp/src/utils/vvis/vvis.cpp b/sp/src/utils/vvis/vvis.cpp index 0fb61388..05f52041 100644 --- a/sp/src/utils/vvis/vvis.cpp +++ b/sp/src/utils/vvis/vvis.cpp @@ -1027,8 +1027,9 @@ void PrintUsage( int argc, char **argv ) " -novconfig : Don't bring up graphical UI on vproject errors.\n" " -radius_override: Force a vis radius, regardless of whether an\n" " -mpi_pw : Use a password to choose a specific set of VMPI workers.\n" - " -threads : Control the number of threads vbsp uses (defaults to the #\n" + " -threads # : Control the number of threads vvis uses (defaults to the #\n" " or processors on your machine).\n" + " Threads can be negative; if so, they will be subtracted from the total thread count.\n" " -nosort : Don't sort portals (sorting is an optimization).\n" " -tmpin : Make portals come from \\tmp\\.\n" " -tmpout : Make portals come from \\tmp\\.\n"