@@ -405,6 +405,12 @@ void CSettings::CreateGUI()
405
405
m_pCheckBoxAllowDiscordRPC->GetPosition (vecTemp, false );
406
406
m_pCheckBoxAllowDiscordRPC->AutoSize (NULL , 20 .0f );
407
407
408
+ // Enable camera photos getting saved to documents folder
409
+ m_pPhotoSavingCheckbox = reinterpret_cast <CGUICheckBox*>(pManager->CreateCheckBox (pTabMultiplayer, _ (" Save photos taken by camera weapon to GTA San Andreas User Files folder" ), true ));
410
+ m_pPhotoSavingCheckbox->SetPosition (CVector2D (vecTemp.fX , vecTemp.fY + 20 .0f ));
411
+ m_pPhotoSavingCheckbox->GetPosition (vecTemp, false );
412
+ m_pPhotoSavingCheckbox->AutoSize (NULL , 20 .0f );
413
+
408
414
m_pCheckBoxCustomizedSAFiles = reinterpret_cast <CGUICheckBox*>(pManager->CreateCheckBox (pTabMultiplayer, _ (" Use customized GTA:SA files" ), true ));
409
415
m_pCheckBoxCustomizedSAFiles->SetPosition (CVector2D (vecTemp.fX , vecTemp.fY + 20 .0f ));
410
416
m_pCheckBoxCustomizedSAFiles->GetPosition (vecTemp, false );
@@ -1201,10 +1207,10 @@ void CSettings::CreateGUI()
1201
1207
m_pCachePathValue->AutoSize ();
1202
1208
vecTemp.fY += fLineHeight ;
1203
1209
1204
- // Enable camera photos getting saved to documents folder
1205
- m_pPhotoSavingCheckbox = reinterpret_cast <CGUICheckBox*>(pManager->CreateCheckBox (pTabAdvanced, _ (" Save photos taken by camera weapon to GTA San Andreas User Files folder " ), true ));
1206
- m_pPhotoSavingCheckbox ->SetPosition (CVector2D (vecTemp.fX , vecTemp.fY ));
1207
- m_pPhotoSavingCheckbox ->AutoSize (NULL , 20 .0f );
1210
+ // Process affinity
1211
+ m_pProcessAffinityCheckbox = reinterpret_cast <CGUICheckBox*>(pManager->CreateCheckBox (pTabAdvanced, _ (" Set CPU 0 affinity to improve game performance " ), true ));
1212
+ m_pProcessAffinityCheckbox ->SetPosition (CVector2D (vecTemp.fX , vecTemp.fY ));
1213
+ m_pProcessAffinityCheckbox ->AutoSize (nullptr , 20 .0f );
1208
1214
vecTemp.fY += fLineHeight ;
1209
1215
1210
1216
// Auto updater section label
@@ -1306,6 +1312,7 @@ void CSettings::CreateGUI()
1306
1312
m_pButtonBrowserWhitelistRemove->SetClickHandler (GUI_CALLBACK (&CSettings::OnBrowserWhitelistRemove, this ));
1307
1313
m_pEditBrowserWhitelistAdd->SetActivateHandler (GUI_CALLBACK (&CSettings::OnBrowserWhitelistDomainAddFocused, this ));
1308
1314
m_pEditBrowserWhitelistAdd->SetDeactivateHandler (GUI_CALLBACK (&CSettings::OnBrowserWhitelistDomainAddDefocused, this ));
1315
+ m_pProcessAffinityCheckbox->SetClickHandler (GUI_CALLBACK (&CSettings::OnAffinityClick, this ));
1309
1316
1310
1317
// Set up the events for advanced description
1311
1318
m_pPriorityLabel->SetMouseEnterHandler (GUI_CALLBACK (&CSettings::OnShowAdvancedSettingDescription, this ));
@@ -1374,6 +1381,9 @@ void CSettings::CreateGUI()
1374
1381
m_pUpdateAutoInstallCombo->SetMouseEnterHandler (GUI_CALLBACK (&CSettings::OnShowAdvancedSettingDescription, this ));
1375
1382
m_pUpdateAutoInstallCombo->SetMouseLeaveHandler (GUI_CALLBACK (&CSettings::OnHideAdvancedSettingDescription, this ));
1376
1383
1384
+ m_pProcessAffinityCheckbox->SetMouseEnterHandler (GUI_CALLBACK (&CSettings::OnShowAdvancedSettingDescription, this ));
1385
+ m_pProcessAffinityCheckbox->SetMouseLeaveHandler (GUI_CALLBACK (&CSettings::OnHideAdvancedSettingDescription, this ));
1386
+
1377
1387
// Load Chat presets
1378
1388
LoadChatPresets ();
1379
1389
@@ -3228,6 +3238,22 @@ void CSettings::LoadData()
3228
3238
CVARS_GET (" photosaving" , bVar);
3229
3239
m_pPhotoSavingCheckbox->SetSelected (bVar);
3230
3240
3241
+ // Process CPU Affinity
3242
+ CVARS_GET (" process_cpu_affinity" , bVar);
3243
+ m_pProcessAffinityCheckbox->SetSelected (bVar);
3244
+
3245
+ DWORD_PTR affinityMask = 0 ;
3246
+ if (bVar)
3247
+ affinityMask = 1 << 0 ; // CPU 0 only
3248
+ else
3249
+ {
3250
+ SYSTEM_INFO sysInfo;
3251
+ GetSystemInfo (&sysInfo);
3252
+
3253
+ affinityMask = (1 << sysInfo.dwNumberOfProcessors ) - 1 ; // All cores (default)
3254
+ }
3255
+ SetProcessAffinityMask (GetCurrentProcess (), affinityMask);
3256
+
3231
3257
// Update build type
3232
3258
CVARS_GET (" update_build_type" , iVar);
3233
3259
if (iVar == 0 || iVar == 1 )
@@ -3624,6 +3650,22 @@ void CSettings::SaveData()
3624
3650
CVARS_SET (" photosaving" , photoSaving);
3625
3651
CScreenShot::SetPhotoSavingInsideDocuments (photoSaving);
3626
3652
3653
+ // Process CPU Affinity
3654
+ bool cpuAffinity = m_pProcessAffinityCheckbox->GetSelected ();
3655
+ CVARS_SET (" process_cpu_affinity" , cpuAffinity);
3656
+
3657
+ DWORD_PTR affinityMask = 0 ;
3658
+ if (cpuAffinity)
3659
+ affinityMask = 1 << 0 ; // CPU 0 only
3660
+ else
3661
+ {
3662
+ SYSTEM_INFO sysInfo;
3663
+ GetSystemInfo (&sysInfo);
3664
+
3665
+ affinityMask = (1 << sysInfo.dwNumberOfProcessors ) - 1 ; // All cores (default)
3666
+ }
3667
+ SetProcessAffinityMask (GetCurrentProcess (), affinityMask);
3668
+
3627
3669
// Debug setting
3628
3670
if (CGUIListItem* pSelected = m_pDebugSettingCombo->GetSelectedItem ())
3629
3671
{
@@ -4711,6 +4753,44 @@ static void DPIAwareQuestionCallBack(void* userdata, unsigned int uiButton)
4711
4753
}
4712
4754
}
4713
4755
4756
+ static void CPUAffinityQuestionCallBack (void * userdata, unsigned int button)
4757
+ {
4758
+ CCore::GetSingleton ().GetLocalGUI ()->GetMainMenu ()->GetQuestionWindow ()->Reset ();
4759
+
4760
+ if (button == 0 )
4761
+ {
4762
+ auto const checkBox = reinterpret_cast <CGUICheckBox*>(userdata);
4763
+ checkBox->SetSelected (false );
4764
+ }
4765
+ }
4766
+
4767
+ bool CSettings::OnAffinityClick (CGUIElement* pElement)
4768
+ {
4769
+ static bool shownWarning = false ;
4770
+
4771
+ if (m_pProcessAffinityCheckbox->GetSelected () && !shownWarning)
4772
+ {
4773
+ shownWarning = true ;
4774
+
4775
+ std::string message = std::string (
4776
+ _ (" Enabling this setting may improve game performance, but on some processors, it may worsen it.\n "
4777
+ " We have observed issues with AMD Ryzen processors featuring 3D V-Cache.\n "
4778
+ " The exact list of affected processors is unknown.\n "
4779
+ " \n Are you sure you want to enable this option?" ));
4780
+
4781
+ CQuestionBox* pQuestionBox = CCore::GetSingleton ().GetLocalGUI ()->GetMainMenu ()->GetQuestionWindow ();
4782
+ pQuestionBox->Reset ();
4783
+ pQuestionBox->SetTitle (_ (" EXPERIMENTAL FEATURE" ));
4784
+ pQuestionBox->SetMessage (message);
4785
+ pQuestionBox->SetButton (0 , _ (" No" ));
4786
+ pQuestionBox->SetButton (1 , _ (" Yes" ));
4787
+ pQuestionBox->SetCallback (CPUAffinityQuestionCallBack, m_pProcessAffinityCheckbox);
4788
+ pQuestionBox->Show ();
4789
+ }
4790
+
4791
+ return true ;
4792
+ }
4793
+
4714
4794
bool CSettings::OnBrowserBlacklistAdd (CGUIElement* pElement)
4715
4795
{
4716
4796
SString strDomain = m_pEditBrowserBlacklistAdd->GetText ();
@@ -4874,6 +4954,8 @@ bool CSettings::OnShowAdvancedSettingDescription(CGUIElement* pElement)
4874
4954
strText = std::string (_ (" 16-bit color:" )) + " " + std::string (_ (" Enable 16 bit color modes - Requires MTA restart" ));
4875
4955
else if (pCheckBox && pCheckBox == m_pWin8MouseCheckBox)
4876
4956
strText = std::string (_ (" Mouse fix:" )) + " " + std::string (_ (" Mouse movement fix - May need PC restart" ));
4957
+ else if (pCheckBox && pCheckBox == m_pProcessAffinityCheckbox)
4958
+ strText = std::string (_ (" CPU affinity:" )) + " " + std::string (_ (" Experimental feature - It may improve performance or worsen it." ));
4877
4959
4878
4960
if (strText != " " )
4879
4961
m_pAdvancedSettingDescriptionLabel->SetText (strText.c_str ());
0 commit comments