X-Git-Url: http://winboard.nl/cgi-bin?p=uci2wb.git;a=blobdiff_plain;f=UCI2WB.c;h=2ea25127dea078635bf82fc12a7677b3bfaad563;hp=b2c458396569bdece0b656c3b5164db09d328a05;hb=70a30c0a0c9a43de477a13a75e8f9d5c05762afc;hpb=3b37b287b6d8973dfd0385ad529e1d04963cb208 diff --git a/UCI2WB.c b/UCI2WB.c index b2c4583..2ea2512 100644 --- a/UCI2WB.c +++ b/UCI2WB.c @@ -269,7 +269,7 @@ Move4Engine(char *m) void GUI2Engine() { - char line[256], command[256], *p, *q; + char line[256], command[256], *p, *q, *r; while(1) { int i, x; @@ -336,10 +336,13 @@ GUI2Engine() } else if(!strcmp(command, "setboard")) { if(strstr(line+9, " b ")) stm = BLACK; - if(sc == 's' && (p = strchr(line+9, '['))) { char c; - *p++ = ' '; q = strchr(p, ']'); c = 'w' + 'b' - q[2]; strcpy(q+2, " 1\n"); while(*--q != ' ') q[2] = *q; *p = c; p[1] = ' '; - } - sprintf(iniPos, "%s%sfen %s", iniPos[0]=='p' ? "position " : "", sc=='s' ? "s" : "", line+9); + if(p = strchr(line+9, '[')) { char c; + *p++ = 0; q = strchr(p, ']'); *q = 0; r = q + 4; + if(sc == 's') q[2] = 'w' + 'b' - q[2], strcpy(r=q+3, " 1\n"); // Shogi: reverse color + else r = strchr(strchr(q+4, ' ') + 1, ' '); // skip to second space (after e.p. square) + *r = 0; sprintf(command, "%s%s %s %s", line+9, q+1, p, r+1); + } else strcpy(command, line+9); + sprintf(iniPos, "%s%sfen %s", iniPos[0]=='p' ? "position " : "", sc=='s' ? "s" : "", command); iniPos[strlen(iniPos)-1] = 0; } else if(!strcmp(command, "variant")) {