Fix variant switch on engine load
authorH.G.Muller <hgm@hgm-xboard.(none)>
Thu, 24 Mar 2016 15:15:47 +0000 (16:15 +0100)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Tue, 29 Mar 2016 14:51:34 +0000 (16:51 +0200)
When an engine was installed with an engine-defined variant, selecting
that engine through the Load Engine dialog did not properly switch to
the intended variant. Now doing this at the start of a game forces an
extra New Game event. This event now also remembers the name of any
unknown variant, in the hope the engine will define it.

backend.c

index 734cf40..216afc8 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -996,6 +996,7 @@ Load (ChessProgramState *cps, int i)
        SwapEngines(i);
        ReplaceEngine(cps, i);
        FloatToFront(&appData.recentEngineList, engineLine);
+       if(gameMode == BeginningOfGame) Reset(TRUE, TRUE);
        return;
     }
     p = engineName;
@@ -10789,6 +10790,7 @@ InitChessProgram (ChessProgramState *cps, int setup)
 
       b = SupportedVariant(cps->variants, gameInfo.variant, gameInfo.boardWidth,
                            gameInfo.boardHeight, gameInfo.holdingsSize, cps->protocolVersion, cps->tidy);
+
       if (b == NULL) {
        VariantClass v;
        char c, *q = cps->variants, *p = strchr(q, ',');
@@ -11971,7 +11973,10 @@ Reset (int redraw, int init)
     lastHint[0] = NULLCHAR;
     ClearGameInfo(&gameInfo);
     gameInfo.variant = StringToVariant(appData.variant);
-    if(gameInfo.variant == VariantNormal && strcmp(appData.variant, "normal")) gameInfo.variant = VariantUnknown;
+    if(gameInfo.variant == VariantNormal && strcmp(appData.variant, "normal")) {
+       gameInfo.variant = VariantUnknown;
+       strncpy(engineVariant, appData.variant, MSG_SIZ);
+    }
     ics_user_moved = ics_clock_paused = FALSE;
     ics_getting_history = H_FALSE;
     ics_gamenum = -1;