Make unsupported variant on loading 1st engine non-fatal
authorH.G.Muller <hgm@hgm-xboard.(none)>
Fri, 26 Sep 2014 17:47:08 +0000 (19:47 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sun, 28 Sep 2014 20:14:28 +0000 (22:14 +0200)
Like in the startup code, when the loaded engine does not play the
currently selected variant, we now figure out what the engine does play,
and switch to that. The error message still pops up, but not non-fatal.

backend.c

index 9495083..24558d5 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -10486,7 +10486,19 @@ InitChessProgram (ChessProgramState *cps, int setup)
       b = SupportedVariant(cps->variants, gameInfo.variant, gameInfo.boardWidth,
                            gameInfo.boardHeight, gameInfo.holdingsSize, cps->protocolVersion, cps->tidy);
       if (b == NULL) {
-       DisplayFatalError(variantError, 0, 1);
+       VariantClass v;
+       char c, *q = cps->variants, *p = strchr(q, ',');
+       if(p) *p = NULLCHAR;
+       v = StringToVariant(q);
+       DisplayError(variantError, 0);
+       if(v != VariantUnknown && cps == &first) {
+           int w, h, s;
+           if(sscanf(q, "%dx%d+%d_%c", &w, &h, &s, &c) == 4) // get size overrides the engine needs with it (if any)
+               appData.NrFiles = w, appData.NrRanks = h, appData.holdingsSize = s, q = strchr(q, '_') + 1;
+           ASSIGN(appData.variant, q);
+           Reset(TRUE, FALSE);
+       }
+       if(p) *p = ',';
        return;
       }