From: H.G. Muller Date: Mon, 18 Apr 2011 13:56:47 +0000 (+0200) Subject: Generalize WaitForSecond to WaitForEngine X-Git-Url: http://winboard.nl/cgi-bin?p=xboard.git;a=commitdiff_plain;h=e5b86edd32897db1b482df4bbacd67ccf091ae75 Generalize WaitForSecond to WaitForEngine --- diff --git a/backend.c b/backend.c index 07897c8..bcdef50 100644 --- a/backend.c +++ b/backend.c @@ -12077,16 +12077,18 @@ SettingsMenuIfReady() } int -WaitForSecond(DelayedEventCallback retry) +WaitForEngine(ChessProgramState *cps, DelayedEventCallback retry) { - if (second.pr == NULL) { - StartChessProgram(&second); - if (second.protocolVersion == 1) { + char buf[MSG_SIZ]; + if (cps->pr == NULL) { + StartChessProgram(cps); + if (cps->protocolVersion == 1) { retry(); } else { /* kludge: allow timeout for initial "feature" command */ FreezeUI(); - DisplayMessage("", _("Starting second chess program")); + snprintf(buf, MSG_SIZ, _("Starting %s chess program"), cps->which); + DisplayMessage("", buf); ScheduleDelayedEvent(retry, FEATURE_TIMEOUT); } return 1; @@ -12137,7 +12139,7 @@ TwoMachinesEvent P((void)) TruncateGame(); // [HGM] vari: MachineWhite and MachineBlack do this... ResurrectChessProgram(); /* in case first program isn't running */ - if(WaitForSecond(TwoMachinesEventIfReady)) return; + if(WaitForEngine(&second, TwoMachinesEventIfReady)) return; if(first.lastPing != first.lastPong) { // [HGM] wait till we are sure first engine has set up position DisplayMessage("", _("Waiting for first chess program")); ScheduleDelayedEvent(TwoMachinesEvent, 10); diff --git a/backend.h b/backend.h index 20639c7..0331f38 100644 --- a/backend.h +++ b/backend.h @@ -210,7 +210,6 @@ void TypeInEvent P((char first)); void TypeInDoneEvent P((char *move)); void InitPosition P((int redraw)); void NewSettingEvent P((int option, int *feature, char *command, int value)); -int WaitForSecond P((DelayedEventCallback x)); void SettingsMenuIfReady P((void)); void DoEcho P((void)); void DontEcho P((void)); @@ -407,5 +406,6 @@ extern ChessProgramStats programStats; extern int opponentKibitzes; // used by wengineo.c extern int errorExitStatus; void SettingsPopUp P((ChessProgramState *cps)); // [HGM] really in front-end, but CPS not known in frontend.h +int WaitForEngine P((ChessProgramState *cps, DelayedEventCallback x)); #endif /* _BACKEND */ diff --git a/winboard/winboard.c b/winboard/winboard.c index 50d82dd..3938cf2 100644 --- a/winboard/winboard.c +++ b/winboard/winboard.c @@ -5095,7 +5095,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) case IDM_Engine2Options: savedHwnd = hwnd; - if(WaitForSecond(SettingsMenuIfReady)) break; + if(WaitForEngine(&second, SettingsMenuIfReady)) break; EngineOptionsPopup(hwnd, &second); break; diff --git a/xoptions.c b/xoptions.c index cd83fe9..688e185 100644 --- a/xoptions.c +++ b/xoptions.c @@ -2002,7 +2002,7 @@ void SecondSettingsProc(w, event, prms, nprms) String *prms; Cardinal *nprms; { - if(WaitForSecond(SettingsMenuIfReady)) return; + if(WaitForEngine(&second, SettingsMenuIfReady)) return; SettingsPopUp(&second); }