X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=57c06b9c171cefbaa098a1d710f612718a830f56;hb=57c7fed9ebd0ac59ba8e6ba5ec9463acd0182998;hp=ef6f83973432137b53fe029bf2f76180ea147fac;hpb=e3955dbbd7fbfb0fd22d5a75971075556a102e66;p=xboard.git diff --git a/backend.c b/backend.c index ef6f839..57c06b9 100644 --- a/backend.c +++ b/backend.c @@ -4209,6 +4209,12 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int parse, currentMove); if (sscanf(parse, " game %d", &gamenum) == 1) { if(gamenum == ics_gamenum) { // [HGM] bughouse: old code if part of foreground game + new_piece[0] = NULLCHAR; + sscanf(parse, "game %d white [%s black [%s <- %s", + &gamenum, white_holding, black_holding, + new_piece); + white_holding[strlen(white_holding)-1] = NULLCHAR; + black_holding[strlen(black_holding)-1] = NULLCHAR; if (gameInfo.variant == VariantNormal) { /* [HGM] We seem to switch variant during a game! * Presumably no holdings were displayed, so we have @@ -4219,7 +4225,10 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int switch(gameInfo.boardWidth) { // base guess on board width case 9: newVariant = VariantShogi; break; case 10: newVariant = VariantGreat; break; - default: newVariant = VariantCrazyhouse; break; + default: newVariant = VariantCrazyhouse; + if(strchr(white_holding, 'E') || strchr(black_holding, 'E') || + strchr(white_holding, 'H') || strchr(black_holding, 'H') ) + newVariant = VariantSChess; } VariantSwitch(boards[currentMove], newVariant); /* temp guess */ /* Get a move list just to see the header, which @@ -4230,12 +4239,6 @@ read_from_ics (InputSourceRef isr, VOIDSTAR closure, char *data, int count, int SendToICS(str); } } - new_piece[0] = NULLCHAR; - sscanf(parse, "game %d white [%s black [%s <- %s", - &gamenum, white_holding, black_holding, - new_piece); - white_holding[strlen(white_holding)-1] = NULLCHAR; - black_holding[strlen(black_holding)-1] = NULLCHAR; /* [HGM] copy holdings to board holdings area */ CopyHoldings(boards[forwardMostMove], white_holding, WhitePawn); CopyHoldings(boards[forwardMostMove], black_holding, BlackPawn); @@ -18467,6 +18470,12 @@ PositionToFEN (int move, char *overrideCastling, int moveCounts) } } + i = boards[move][CHECK_COUNT]; + if(i) { + sprintf(p, "%d+%d ", i&255, i>>8); + while(*p) p++; + } + if(moveCounts) { int i = 0, j=move; @@ -18827,10 +18836,19 @@ ParseFEN (Board board, int *blackPlaysFirst, char *fen, Boolean autoSize) } } + while(*p == ' ') p++; + + board[CHECK_COUNT] = 0; // [HGM] 3check: check-count field + if(sscanf(p, "%d+%d", &i, &j) == 2) { + board[CHECK_COUNT] = i + 256*j; + while(*p && *p != ' ') p++; + } - if(sscanf(p, "%d", &i) == 1) { + c = sscanf(p, "%d%*d +%d+%d", &i, &j, &k); + if(c > 0) { FENrulePlies = i; /* 50-move ply counter */ /* (The move number is still ignored) */ + if(c == 3 && !board[CHECK_COUNT]) board[CHECK_COUNT] = (3 - j) + 256*(3 - k); // SCIDB-style check count } return TRUE;