From 2ced57bc0aa92b0c17da68415f841d8457adcf47 Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Mon, 1 Nov 2010 19:26:19 +0100 Subject: [PATCH] Make test for valid promotion piece color-dependent This is needed to make it work in variants where white and black have different armies; quite likely white will promote to pieces that do not exist in the black army, so we really have to make sure we test if the white (upper-case) piece exists in this case. --- moves.c | 5 +++-- 1 files changed, 3 insertions(+), 2 deletions(-) diff --git a/moves.c b/moves.c index d667113..830e0bb 100644 --- a/moves.c +++ b/moves.c @@ -1085,7 +1085,8 @@ if(appData.debugMode)fprintf(debugFP,"SHOGI promoChar = %c\n", promoChar ? promo if (promoChar != NULLCHAR) { if(promoChar == '=') cl.kind = IllegalMove; else // [HGM] shogi: no deferred promotion outside Shogi if (cl.kind == WhitePromotion || cl.kind == BlackPromotion) { - if(CharToPiece(promoChar) == EmptySquare) cl.kind = ImpossibleMove; // non-existing piece + if(CharToPiece(flags & F_WHITE_ON_MOVE ? ToUpper(promoChar) : ToLower(promoChar)) == EmptySquare) + cl.kind = ImpossibleMove; // non-existing piece } else { cl.kind = IllegalMove; } @@ -1291,7 +1292,7 @@ void Disambiguate(board, flags, closure) } else if (c != NULLCHAR) closure->kind = IllegalMove; closure->promoChar = ToLower(c); // this can be NULLCHAR! Note we keep original promoChar even if illegal. - if(c != '+' && c != '=' && c != NULLCHAR && CharToPiece(c) == EmptySquare) + if(c != '+' && c != '=' && c != NULLCHAR && CharToPiece(flags & F_WHITE_ON_MOVE ? ToUpper(c) : ToLower(c)) == EmptySquare) closure->kind = ImpossibleMove; // but we cannot handle non-existing piece types! if (closure->count > 1) { closure->kind = AmbiguousMove; -- 1.7.0.4