"-thread" allows negative values.

This commit is contained in:
Carlos suarez 2025-03-04 17:47:46 +01:00 committed by Blixibon
parent f3c9872262
commit 13557bffc9
4 changed files with 33 additions and 6 deletions

View File

@ -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);
}

View File

@ -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"

View File

@ -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 <file> : Load a lights file in addition to lights.rad and the\n"
" level lights file.\n"
" -noextra : Disable supersampling.\n"

View File

@ -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 <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\\<mapname>.\n"
" -tmpout : Make portals come from \\tmp\\<mapname>.\n"