From 7b721be1faca2a8524f56ab9e414d0bb97215765 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 2 Mar 2015 19:59:18 +0100 Subject: [PATCH] Improve reading of pieceToCharTable The piece-to-char string can now contain ' and ! suffixes on pieces, which are taken together with the preceding piece ID. An encountered : will cause the assigning to skip to the chu-promoted series of pieces, however these are numbered. --- backend.c | 28 ++++++++++++++++++++++------ 1 files changed, 22 insertions(+), 6 deletions(-) diff --git a/backend.c b/backend.c index 6cd2224..a75a87a 100644 --- a/backend.c +++ b/backend.c @@ -5947,23 +5947,39 @@ SetUpShuffle (Board board, int number) } int +ptclen (const char *s) +{ + int n = 0; + while(*s) n += (*s != '\'' && *s != '"' && *s != '`' && *s != '!'), s++; + return n; +} + +int SetCharTable (char *table, const char * map) /* [HGM] moved here from winboard.c because of its general usefulness */ /* Basically a safe strcpy that uses the last character as King */ { int result = FALSE; int NrPieces; - if( map != NULL && (NrPieces=strlen(map)) <= (int) EmptySquare + if( map != NULL && (NrPieces=ptclen(map)) <= (int) EmptySquare && NrPieces >= 12 && !(NrPieces&1)) { - int i; /* [HGM] Accept even length from 12 to 34 */ + int i, j = 0; /* [HGM] Accept even length from 12 to 88 */ for( i=0; i<(int) EmptySquare; i++ ) table[i] = '.'; for( i=0; i