From: H.G. Muller Date: Sat, 19 Jan 2013 16:34:04 +0000 (+0100) Subject: Fix crash after using setboard (and undo?) X-Git-Tag: 0.18~66 X-Git-Url: http://winboard.nl/cgi-bin?p=hachu.git;a=commitdiff_plain;h=4f353c90e7676e1c17760bb00dd7517dde67cbfa Fix crash after using setboard (and undo?) The crash was due to an attempt to set up a Lance in Chess. An error message has been added to detect unknown pieces in setup. Also the ambiguity of N in FEN between Chess and Chu has been resolved in Convert. The board is now cleared before calling Setup, by calling Init. --- diff --git a/hachu.c b/hachu.c index ad2904e..7a6dccc 100644 --- a/hachu.c +++ b/hachu.c @@ -691,6 +691,7 @@ SetUp(char *array, int var) if(name[1]) name[1] += 'A' - 'a'; } else color = WHITE; p1 = LookUp(name, var); + if(!p1) printf("tellusererror Unknown piece '%s' in setup\n", name), exit(-1); if(pflag && p1->promoted) p1 = LookUp(p1->promoted, var); // use promoted piece instead n = AddPiece(color, p1); p[n].pos = j; @@ -1822,8 +1823,6 @@ pmoves(int start, int end) #define OFF 0 #define ON 1 -#define DEFAULT_FEN "" - typedef Move MOVE; int moveNr; // part of game state; incremented by MakeMove @@ -1891,7 +1890,8 @@ Convert (char *fen) if(isalpha(*fen)) { char *table = fenNames; n = *fen > 'Z' ? 'a' - 'A' : 0; - if(table[2* (*fen - 'A' - n)] == '.') *p++ = *fen; else { + if(currentVariant == V_CHESS && *fen - 'A' - n == 'N' // In Chess N is Knight, not Lion + || table[2* (*fen - 'A' - n)] == '.') *p++ = *fen; else { *p++ = ':'; *p++ = table[2* (*fen - 'A' - n)] + n; *p++ = table[2* (*fen - 'A' - n)+1] + n; @@ -2101,7 +2101,7 @@ PonderUntilInput (int stm) int TakeBack(int n) { // reset the game and then replay it to the desired point int last, stm; - stm = Setup2(NULL); + Init(currentVariant); stm = Setup2(NULL); printf("# setup done");fflush(stdout); last = moveNr - n; if(last < 0) last = 0; for(moveNr=0; moveNr