From 77ad1e5157ad3cf48244f2377f90272d3bb4a1c1 Mon Sep 17 00:00:00 2001 From: H.G.Muller Date: Mon, 2 Jun 2014 19:49:41 +0200 Subject: [PATCH] Fix setting up of positions without King Without King, royal[] would not be set, and retain the value it had in the standard setup (as it was not cleared either). This would usually point outside the piece list, but occasionally it designated an on-board piece as royal, which then could make HaChu think it was checkmated in the initial position of a tsume problem. It also caused problems in positions with only CP. --- hachu.c | 4 ++++ 1 files changed, 4 insertions(+), 0 deletions(-) diff --git a/hachu.c b/hachu.c index a8828c5..9b98aa7 100644 --- a/hachu.c +++ b/hachu.c @@ -820,6 +820,7 @@ SetUp(char *array, int var) char c, *q, name[3], prince = 0; PieceDesc *p1, *p2; last[WHITE] = 1; last[BLACK] = 0; + royal[WHITE] = royal[BLACK] = 0; for(i=0; ; i++) { //printf("next rank: %s\n", array); for(j = BW*i; ; j++) { @@ -860,6 +861,9 @@ SetUp(char *array, int var) } } eos: + // add dummy Kings if not yet added (needed to set royal[] to valid value!) + if(!royal[WHITE]) p[AddPiece(WHITE, LookUp("K", V_CHU))].pos = ABSENT; + if(!royal[BLACK]) p[AddPiece(BLACK, LookUp("K", V_CHU))].pos = ABSENT; // add dummy Crown Princes if not yet added if(!(prince & WHITE+1)) p[AddPiece(WHITE, LookUp("CP", V_CHU))].pos = ABSENT; if(!(prince & BLACK+1)) p[AddPiece(BLACK, LookUp("CP", V_CHU))].pos = ABSENT; -- 1.7.0.4