X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=1de9cb765e7b282f6bfe61cdda06f338581287c3;hb=ca3a88fcfe0d10b8d841251166afbf5cc1a02886;hp=01d447e17a65ec317e29e10088c28f8be4f9e506;hpb=df9627370a43a38a89ad2a7aeb6b18a044f56744;p=xboard.git diff --git a/backend.c b/backend.c index 01d447e..1de9cb7 100644 --- a/backend.c +++ b/backend.c @@ -11853,6 +11853,37 @@ DisplayTwoMachinesTitle() } void +SettingsMenuIfReady() +{ + if (second.lastPing != second.lastPong) { + DisplayMessage("", _("Waiting for second chess program")); + ScheduleDelayedEvent(SettingsMenuIfReady, 10); // [HGM] fast: lowered from 1000 + return; + } + ThawUI(); + DisplayMessage("", ""); + SettingsPopUp(&second); +} + +int +WaitForSecond(DelayedEventCallback retry) +{ + if (second.pr == NULL) { + StartChessProgram(&second); + if (second.protocolVersion == 1) { + retry(); + } else { + /* kludge: allow timeout for initial "feature" command */ + FreezeUI(); + DisplayMessage("", _("Starting second chess program")); + ScheduleDelayedEvent(retry, FEATURE_TIMEOUT); + } + return 1; + } + return 0; +} + +void TwoMachinesEvent P((void)) { int i; @@ -11894,18 +11925,7 @@ TwoMachinesEvent P((void)) TruncateGame(); // [HGM] vari: MachineWhite and MachineBlack do this... ResurrectChessProgram(); /* in case first program isn't running */ - if (second.pr == NULL) { - StartChessProgram(&second); - if (second.protocolVersion == 1) { - TwoMachinesEventIfReady(); - } else { - /* kludge: allow timeout for initial "feature" command */ - FreezeUI(); - DisplayMessage("", _("Starting second chess program")); - ScheduleDelayedEvent(TwoMachinesEventIfReady, FEATURE_TIMEOUT); - } - return; - } + if(WaitForSecond(TwoMachinesEventIfReady)) return; DisplayMessage("", ""); InitChessProgram(&second, FALSE); SendToProgram("force\n", &second); @@ -13844,6 +13864,7 @@ FeatureDone(cps, val) { DelayedEventCallback cb = GetDelayedEvent(); if ((cb == InitBackEnd3 && cps == &first) || + (cb == SettingsMenuIfReady && cps == &second) || (cb == TwoMachinesEventIfReady && cps == &second)) { CancelDelayedEvent(); ScheduleDelayedEvent(cb, val ? 1 : 3600000);