From: H.G.Muller Date: Tue, 2 Feb 2016 08:27:34 +0000 (+0100) Subject: Allow pieces with dressed-letter ID as promotion choice X-Git-Url: http://winboard.nl/cgi-bin?a=commitdiff_plain;h=6b5834a77b0a0589265710e9a13aef0c45c14bc2;p=xboard.git 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. --- 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)));