From 75c82871211daf66c50935b39427e78922d20a5e Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 11 Jul 2010 10:54:59 +0200 Subject: [PATCH] Fix bug in sending cores command to engine The cores command was alwas sent to the engine(s) when the user changed it through the menu, even when the engine had sent feature smp=0 (which is default anyway). NewSettingEvent() was patched to send the new setting conditionally, based on the engine properties as recorded in ChessProgramStates first, second; In this particular case it now consults cps->maxCores. (Note the code for testing the second engine contains some dirty pointer arithmetic.) --- backend.c | 8 ++++---- backend.h | 2 +- winboard/woptions.c | 3 +-- xoptions.c | 2 +- 4 files changed, 7 insertions(+), 8 deletions(-) diff --git a/backend.c b/backend.c index 5d0c420..bb52007 100644 --- a/backend.c +++ b/backend.c @@ -13867,17 +13867,17 @@ PonderNextMoveEvent(newState) } void -NewSettingEvent(option, command, value) +NewSettingEvent(option, feature, command, value) char *command; - int option, value; + int option, value, *feature; { char buf[MSG_SIZ]; if (gameMode == EditPosition) EditPositionDone(TRUE); sprintf(buf, "%s%s %d\n", (option ? "option ": ""), command, value); - SendToProgram(buf, &first); + if(feature == NULL || *feature) SendToProgram(buf, &first); if (gameMode == TwoMachinesPlay) { - SendToProgram(buf, &second); + if(feature == NULL || feature[(int*)&second - (int*)&first]) SendToProgram(buf, &second); } } diff --git a/backend.h b/backend.h index a5caec7..38515df 100644 --- a/backend.h +++ b/backend.h @@ -203,7 +203,7 @@ void ExitAnalyzeMode P((void)); void AnalyzeModeEvent P((void)); void AnalyzeFileEvent P((void)); void InitPosition P((int redraw)); -void NewSettingEvent P((int option, char *command, int value)); +void NewSettingEvent P((int option, int *feature, char *command, int value)); void DoEcho P((void)); void DontEcho P((void)); void TidyProgramName P((char *prog, char *host, char *buf)); diff --git a/winboard/woptions.c b/winboard/woptions.c index f9f3ce4..7420fc0 100644 --- a/winboard/woptions.c +++ b/winboard/woptions.c @@ -131,7 +131,6 @@ void SelectComboValue(HANDLE hwndCombo, ComboData *cd, unsigned value); VOID SetLoadOptionEnables(HWND hDlg); VOID SetSaveOptionEnables(HWND hDlg); VOID SetTimeControlEnables(HWND hDlg); -void NewSettingEvent(int option, char *command, int value); /*---------------------------------------------------------------------------*\ * @@ -2939,7 +2938,7 @@ LRESULT CALLBACK UciOptionsDialog(HWND hDlg, UINT message, WPARAM wParam, LPARAM // [HGM] smp: get nr of cores: oldCores = appData.smpCores; appData.smpCores = GetDlgItemInt(hDlg, IDC_Cores, NULL, FALSE ); - if(appData.smpCores != oldCores) NewSettingEvent(FALSE, "cores", appData.smpCores); + if(appData.smpCores != oldCores) NewSettingEvent(FALSE, &(first.maxCores), "cores", appData.smpCores); // [HGM] book: read tick boxes for own book use appData.firstHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook1 ); appData.secondHasOwnBookUCI = (Boolean) IsDlgButtonChecked( hDlg, IDC_OwnBook2 ); diff --git a/xoptions.c b/xoptions.c index e60e845..526dfd9 100644 --- a/xoptions.c +++ b/xoptions.c @@ -1233,7 +1233,7 @@ void UciCallback(w, client_data, call_data) // Some changed setting need immediate sending always. PonderNextMoveEvent(ponder); if(oldCores != appData.smpCores) - NewSettingEvent(False, "cores", appData.smpCores); + NewSettingEvent(False, &(first.maxCores), "cores", appData.smpCores); } UciPopDown(); return; -- 1.7.0.4