From: H.G. Muller Date: Mon, 28 Jan 2013 16:23:47 +0000 (+0100) Subject: Preserve mode on engine loading (sometimes) X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=f63864b8d50cffa9c90590a876a938b4ac0423eb;p=xboard.git Preserve mode on engine loading (sometimes) That the mode always switched to EditGame after engine loading was particularly annoying at the start of a game (where leaving BeginningOfGame mode would disablethe Time Control dialog, and the engine would not automatically reply if you start playing) and AnalyzeMode. These two modes are now preserved, BeginningOfGame by refraining from calling EditGameEvent() and sending 'force' to the new engine, and AnalyzeMode be calling AnalyzeModeEvent() after the engine is loaded and repositioned. --- diff --git a/backend.c b/backend.c index dd5106f..1aea360 100644 --- a/backend.c +++ b/backend.c @@ -840,6 +840,8 @@ InitEngine (ChessProgramState *cps, int n) ChessProgramState *savCps; +GameMode oldMode; + void LoadEngine () { @@ -849,21 +851,23 @@ LoadEngine () if(gameInfo.variant != StringToVariant(appData.variant)) { // we changed variant when loading the engine; this forces us to reset Reset(TRUE, savCps != &first); - EditGameEvent(); // for consistency with other path, as Reset changes mode + oldMode = BeginningOfGame; // to prevent restoring old mode } InitChessProgram(savCps, FALSE); - SendToProgram("force\n", savCps); + if(gameMode == EditGame) SendToProgram("force\n", savCps); // in EditGame mode engine must be in force mode DisplayMessage("", ""); if (startedFromSetupPosition) SendBoard(savCps, backwardMostMove); for (i = backwardMostMove; i < currentMove; i++) SendMoveToProgram(i, savCps); ThawUI(); SetGNUMode(); + if(oldMode == AnalyzeMode) AnalyzeModeEvent(); } void ReplaceEngine (ChessProgramState *cps, int n) { - EditGameEvent(); + oldMode = gameMode; // remember mode, so it can be restored after loading sequence is complete + if(oldMode != BeginningOfGame) EditGameEvent(); UnloadEngine(cps); appData.noChessProgram = FALSE; appData.clockMode = TRUE;