mirror of
https://github.com/sfall-team/sfall.git
synced 2026-07-27 16:52:34 -07:00
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:
+1
-1
@@ -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
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user