From 0d028927885f24bda4d1c64f9cac2cda17703e19 Mon Sep 17 00:00:00 2001
From: H.G. Muller <h.g.muller@hccnet.nl>
Date: Fri, 27 Dec 2013 20:06:21 +0100
Subject: [PATCH] Fix promotion in Ai-Wok

When in a variant with fixed promotion, such as Makruk, the promotion
piece did not participate, this led to disappearence of the piece, and
an =. suffix in SAN. This is relevant for the Makruk variant Ai-Wok,
which replaces the Met by a much more powerful Ai-Wok, which could not
be represented by another XBoard piece type due to this problem.
Now we search through the pieceToCharTable until a valid piece is found,
which works when the Ai-Wok is represented by a SMIRF Archbishop symbol.
---
 backend.c |    6 +++++-
 1 files changed, 5 insertions(+), 1 deletions(-)

diff --git a/backend.c b/backend.c
index 8f796e7..b7c3246 100644
--- a/backend.c
+++ b/backend.c
@@ -6553,7 +6553,11 @@ HasPromotionChoice (int fromX, int fromY, int toX, int toY, char *promoChoice, i
     // we either have a choice what to promote to, or (in Shogi) whether to promote
     if(gameInfo.variant == VariantShatranj || gameInfo.variant == VariantCourier ||
        gameInfo.variant == VariantMakruk || gameInfo.variant == VariantASEAN) {
-	*promoChoice = PieceToChar(BlackFerz);  // no choice
+	ChessSquare p=BlackFerz;  // no choice
+	while(p < EmptySquare) {  //but make sure we use piece that exists
+	    *promoChoice = PieceToChar(p++);
+	    if(*promoChoice != '.') break;
+	}
 	return FALSE;
     }
     // no sense asking what we must promote to if it is going to explode...
-- 
1.7.0.4