diff --git a/artifacts/ddraw.ini b/artifacts/ddraw.ini index ddac6516..03bce110 100644 --- a/artifacts/ddraw.ini +++ b/artifacts/ddraw.ini @@ -406,7 +406,7 @@ ViewXPos=-1 ViewYPos=-1 ;Set to 1 to force Fallout not to use multiple processor cores even if they are available -SingleCore=1 +SingleCore=0 ;Set to 1 to override the art_cache_size setting in fallout2.cfg OverrideArtCacheSize=0 diff --git a/sfall/Modules/MiscPatches.cpp b/sfall/Modules/MiscPatches.cpp index 5af374a4..b52ecbd7 100644 --- a/sfall/Modules/MiscPatches.cpp +++ b/sfall/Modules/MiscPatches.cpp @@ -928,13 +928,21 @@ void MiscPatches::init() { SafeWrite32(0x444323, (DWORD)&patchName); } - if (IniReader::GetConfigInt("Misc", "SingleCore", 1)) { + if (IniReader::GetConfigInt("Misc", "SingleCore", 0)) { SYSTEM_INFO sysInfo; GetSystemInfo(&sysInfo); if (sysInfo.dwNumberOfProcessors > 1) { - dlogr("Applying single core patch.", DL_INIT); HANDLE process = GetCurrentProcess(); - SetProcessAffinityMask(process, 2); // use only CPU 1 + DWORD_PTR procAffinity, sysAffinity; + if (GetProcessAffinityMask(process, &procAffinity, &sysAffinity)) { + DWORD_PTR newMask = procAffinity & ~static_cast(1); // exclude CPU 0 + if (newMask == 0) newMask = procAffinity; // fall back if no other cores + newMask &= -static_cast(newMask); // pick the first available core + if (newMask != 0 && newMask != procAffinity) { + dlogr("Applying single core patch.", DL_INIT); + SetProcessAffinityMask(process, newMask); + } + } } }