X-Git-Url: http://winboard.nl/cgi-bin?a=blobdiff_plain;f=backend.c;h=37648d908001a4706c043bd03772cea0e342f9c0;hb=6b5834a77b0a0589265710e9a13aef0c45c14bc2;hp=38b4e54da2ac879cb8947da1aecbe93c4116f574;hpb=9337560fbda4278a04213d85947445218fd01621;p=xboard.git 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)));