Interpret UCI2WB's invalid pieceToCharTable
authorH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 6 Jul 2019 13:52:32 +0000 (15:52 +0200)
committerH.G.Muller <hgm@hgm-xboard.(none)>
Sat, 6 Jul 2019 13:52:32 +0000 (15:52 +0200)
UCI2WB sends an invalid pieceToCharTable "-" in its setup command for
engine-defined variants. This would keep the pieceToChar assignment
of the parent variant (in UCI2WB's case always 'fairy'). Now this is
replaced by the pieceToCharTable for variant normal, as the UCI engines
that use this feature only support variants with orthodox pieces.

backend.c

index 77baf51..b6088f6 100644 (file)
--- a/backend.c
+++ b/backend.c
@@ -9327,8 +9327,9 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h
       if(appData.icsActive || forwardMostMove != 0 || cps != &first) return;
       *buf = NULLCHAR;
       if(sscanf(message, "setup (%s", buf) == 1) {
-        s = 8 + strlen(buf), buf[s-9] = NULLCHAR, SetCharTableEsc(pieceToChar, buf, SUFFIXES);
-        ASSIGN(appData.pieceToCharTable, buf);
+        char *ptc = strlen(buf) < 3 ? "PNBRQKpnbrqk" : buf;
+        s = 8 + strlen(buf), buf[s-9] = NULLCHAR, SetCharTableEsc(pieceToChar, ptc, SUFFIXES);
+        ASSIGN(appData.pieceToCharTable, ptc);
       }
       dummy = sscanf(message+s, "%dx%d+%d_%s", &w, &h, &hand, varName);
       if(dummy >= 3) {