Code edits to SingleCore to make it run safer

Changed SingleCore to be disabled by default.
(its usage is questionable on newer systems.)
This commit is contained in:
NovaRain
2026-01-16 10:10:07 +08:00
parent b3c5fad981
commit 84d8d80d30
2 changed files with 12 additions and 4 deletions
+1 -1
View File
@@ -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
+11 -3
View File
@@ -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<DWORD_PTR>(1); // exclude CPU 0
if (newMask == 0) newMask = procAffinity; // fall back if no other cores
newMask &= -static_cast<LONG_PTR>(newMask); // pick the first available core
if (newMask != 0 && newMask != procAffinity) {
dlogr("Applying single core patch.", DL_INIT);
SetProcessAffinityMask(process, newMask);
}
}
}
}