From 6b5834a77b0a0589265710e9a13aef0c45c14bc2 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Tue, 2 Feb 2016 09:27:34 +0100 Subject: [PATCH] Allow pieces with dressed-letter ID as promotion choice Testing for the occurrence of a piece in the promotion set specified through the 'choice' command now takes dressing of the piece IDs into account. --- backend.c | 13 ++++++++++++- 1 files changed, 12 insertions(+), 1 deletions(-) diff --git a/backend.c b/backend.c index 38b4e54..37648d9 100644 --- a/backend.c +++ b/backend.c @@ -5381,6 +5381,17 @@ int dragging; static ClickType lastClickType; int +PieceInString (char *s, ChessSquare piece) +{ + char *p, ID = ToUpper(PieceToChar(piece)), suffix = PieceSuffix(piece); + while((p = strchr(s, ID))) { + if(!suffix || p[1] == suffix) return TRUE; + s = p; + } + return FALSE; +} + +int Partner (ChessSquare *p) { // change piece into promotion partner if one shogi-promotes to the other ChessSquare partner = promoPartner[*p]; @@ -5409,7 +5420,7 @@ Sweep (int step) if(!step) step = -1; } while(PieceToChar(promoSweep) == '.' || PieceToChar(promoSweep) == '~' || !toggleFlag && PieceToChar(promoSweep) == '+' || // skip promoted versions of other - promoRestrict[0] ? !strchr(promoRestrict, ToUpper(PieceToChar(promoSweep))) : // if choice set available, use it + promoRestrict[0] ? !PieceInString(promoRestrict, promoSweep) : // if choice set available, use it promoSweep == pawn || appData.testLegality && (promoSweep == king || gameInfo.variant != VariantChuChess && (promoSweep == WhiteLion || promoSweep == BlackLion))); -- 1.7.0.4