From 308004ff067f7f11ba7e4932009df47c71e7adc8 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Sat, 4 Oct 2014 21:56:14 +0200 Subject: [PATCH] Always accept piece commands for Falcon and Cobra The wild-card pieces Falcon and Cobra do not have any moves assigned to them, and XBoard would accept any move for them even when legality checking is on. So for these pieces it is always better to trust the engine's piece definition. --- backend.c | 6 ++++-- moves.c | 2 +- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/backend.c b/backend.c index d23ddfb..8b18888 100644 --- a/backend.c +++ b/backend.c @@ -8898,13 +8898,15 @@ FakeBookMove: // [HGM] book: we jump here to simulate machine moves after book h if(sscanf(message, "piece %s %s", buf2, buf1) == 2) { ChessSquare piece = WhitePawn; char *p=buf2; + if(*p == '+') piece = CHUPROMOTED WhitePawn, p++; + piece += CharToPiece(*p) - WhitePawn; if(cps != &first || appData.testLegality && *engineVariant == NULLCHAR + /* always accept definition of */ && piece != WhiteFalcon && piece != BlackFalcon + /* wild-card pieces. */ && piece != WhiteCobra && piece != BlackCobra /* For variants we don't have */ && gameInfo.variant != VariantBerolina /* correct rules for, we cannot */ && gameInfo.variant != VariantCylinder /* enforce legality on our own! */ && gameInfo.variant != VariantUnknown && gameInfo.variant != VariantFairy ) return; - if(*p == '+') piece = CHUPROMOTED WhitePawn, p++; - piece += CharToPiece(*p) - WhitePawn; if(piece < EmptySquare) { pieceDefs = TRUE; ASSIGN(pieceDesc[piece], buf1); diff --git a/moves.c b/moves.c index 5af3c47..e1b0145 100644 --- a/moves.c +++ b/moves.c @@ -1663,7 +1663,7 @@ LegalityTest (Board board, int flags, int rf, int ff, int rt, int ft, int promoC /* [HGM] Cobra and Falcon are wildcard pieces; consider all their moves legal */ /* (perhaps we should disallow moves that obviously leave us in check?) */ if((piece == WhiteFalcon || piece == BlackFalcon || - piece == WhiteCobra || piece == BlackCobra) && gameInfo.variant != VariantChu) + piece == WhiteCobra || piece == BlackCobra) && gameInfo.variant != VariantChu && !pieceDesc[piece]) return CheckTest(board, flags, rf, ff, rt, ft, FALSE) ? IllegalMove : NormalMove; cl.rf = rf; -- 1.7.0.4