Generalize WaitForSecond to WaitForEngine
authorH.G. Muller <h.g.muller@hccnet.nl>
Mon, 18 Apr 2011 13:56:47 +0000 (15:56 +0200)
committerH.G. Muller <h.g.muller@hccnet.nl>
Wed, 20 Apr 2011 20:35:15 +0000 (22:35 +0200)
backend.c
backend.h
winboard/winboard.c
xoptions.c

index 07897c8..bcdef50 100644 (file)
--- 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);
index 20639c7..0331f38 100644 (file)
--- 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;\r
 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 */
index 50d82dd..3938cf2 100644 (file)
@@ -5095,7 +5095,7 @@ WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
 \r
     case IDM_Engine2Options:\r
       savedHwnd = hwnd;\r
-      if(WaitForSecond(SettingsMenuIfReady)) break;\r
+      if(WaitForEngine(&second, SettingsMenuIfReady)) break;\r
       EngineOptionsPopup(hwnd, &second);\r
       break;\r
 \r
index cd83fe9..688e185 100644 (file)
@@ -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);
 }