Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Client/core/CClientVariables.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -357,7 +357,7 @@ void CClientVariables::LoadDefaults()
DEFAULT("discord_rpc_share_data", false); // Consistent Rich Presence data sharing
DEFAULT("discord_rpc_share_data_firsttime", false); // Display the user data sharing consent dialog box - for the first time
DEFAULT("browser_enable_gpu", true); // Enable GPU in CEF? (allows stuff like WebGL to function)
DEFAULT("process_cpu_affinity", false); // Set CPU 0 affinity to improve game performance and fix the known issue in single-threaded games
DEFAULT("process_cpu_affinity", true); // Set CPU 0 affinity to improve game performance and fix the known issue in single-threaded games

if (!Exists("locale"))
{
Expand Down
24 changes: 10 additions & 14 deletions Client/core/CCore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1770,7 +1770,7 @@ void CCore::OnPostColorFilterRender()
void CCore::ApplyCoreInitSettings()
{
#if (_WIN32_WINNT >= _WIN32_WINNT_LONGHORN)
const auto aware = CVARS_GET_VALUE<bool>("process_dpi_aware");
bool aware = CVARS_GET_VALUE<bool>("process_dpi_aware");

// The minimum supported client for the function below is Windows Vista (Longhorn).
// For more information, refer to the Microsoft Learn article:
Expand All @@ -1779,39 +1779,35 @@ void CCore::ApplyCoreInitSettings()
SetProcessDPIAware();
#endif

const auto revision = GetApplicationSettingInt("reset-settings-revision");
int revision = GetApplicationSettingInt("reset-settings-revision");

// Users with the default skin will be switched to the 2023 version by replacing "Default" with "Default 2023".
// The "Default 2023" GUI skin was introduced in commit 2d9e03324b07e355031ecb3263477477f1a91399.
if (revision < 21486)
{
const auto skin = CVARS_GET_VALUE<std::string>("current_skin");
auto skin = CVARS_GET_VALUE<std::string>("current_skin");

if (skin == "Default")
CVARS_SET("current_skin", "Default 2023");

SetApplicationSettingInt("reset-settings-revision", 21486);
}

const auto process = GetCurrentProcess();
const int priorities[] = {NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS};
const auto priority = CVARS_GET_VALUE<int>("process_priority") % 3;
HANDLE process = GetCurrentProcess();
const int priorities[] = {NORMAL_PRIORITY_CLASS, ABOVE_NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS};
int priority = CVARS_GET_VALUE<int>("process_priority") % 3;

SetPriorityClass(process, priorities[priority]);

const auto affinity = CVARS_GET_VALUE<bool>("process_cpu_affinity");

bool affinity = CVARS_GET_VALUE<bool>("process_cpu_affinity");
if (!affinity)
return;

DWORD_PTR mask;
DWORD_PTR sys;
const auto result = GetProcessAffinityMask(process, &mask, &sys);

if (!result)
return;

SetProcessAffinityMask(process, mask & ~1);
BOOL result = GetProcessAffinityMask(process, &mask, &sys);
if (result)
SetProcessAffinityMask(process, mask & ~1);
}

//
Expand Down
20 changes: 7 additions & 13 deletions Client/core/CSettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3245,13 +3245,11 @@ void CSettings::LoadData()
DWORD_PTR mask;
DWORD_PTR sys;

const auto process = GetCurrentProcess();
const auto result = GetProcessAffinityMask(process, &mask, &sys);
HANDLE process = GetCurrentProcess();
BOOL result = GetProcessAffinityMask(process, &mask, &sys);

if (bVar && result)
{
SetProcessAffinityMask(process, mask & ~1);
}
else
{
SYSTEM_INFO info;
Expand Down Expand Up @@ -3657,19 +3655,17 @@ void CSettings::SaveData()
CScreenShot::SetPhotoSavingInsideDocuments(photoSaving);

// Process CPU Affinity
const auto affinity = m_pProcessAffinityCheckbox->GetSelected();
bool affinity = m_pProcessAffinityCheckbox->GetSelected();
CVARS_SET("process_cpu_affinity", affinity);

DWORD_PTR mask;
DWORD_PTR sys;

const auto process = GetCurrentProcess();
const auto result = GetProcessAffinityMask(process, &mask, &sys);
HANDLE process = GetCurrentProcess();
BOOL result = GetProcessAffinityMask(process, &mask, &sys);

if (affinity && result)
{
SetProcessAffinityMask(process, mask & ~1);
}
else
{
SYSTEM_INFO info;
Expand Down Expand Up @@ -4785,9 +4781,7 @@ bool CSettings::OnAffinityClick(CGUIElement* pElement)
shownWarning = true;

std::string message = std::string(
_("Enabling this setting may improve game performance, but on some processors, it may worsen it.\n"
"We have observed issues with AMD Ryzen processors featuring 3D V-Cache.\n"
"The exact list of affected processors is unknown.\n"
_("This option should only be changed if you experience performance issues.\n"
"\nAre you sure you want to enable this option?"));

CQuestionBox* pQuestionBox = CCore::GetSingleton().GetLocalGUI()->GetMainMenu()->GetQuestionWindow();
Expand Down Expand Up @@ -4967,7 +4961,7 @@ bool CSettings::OnShowAdvancedSettingDescription(CGUIElement* pElement)
else if (pCheckBox && pCheckBox == m_pWin8MouseCheckBox)
strText = std::string(_("Mouse fix:")) + " " + std::string(_("Mouse movement fix - May need PC restart"));
else if (pCheckBox && pCheckBox == m_pProcessAffinityCheckbox)
strText = std::string(_("CPU affinity:")) + " " + std::string(_("Experimental feature - It may improve performance or worsen it."));
strText = std::string(_("CPU affinity:")) + " " + std::string(_("Experimental feature - Change only if you experience performance issues"));

if (strText != "")
m_pAdvancedSettingDescriptionLabel->SetText(strText.c_str());
Expand Down
Loading