From 225ee001625a06413e7ceee04d8723972231b9ea Mon Sep 17 00:00:00 2001 From: H.G. Muller Date: Sun, 8 Jan 2012 23:53:08 +0100 Subject: [PATCH] Fix takeback of S-Chess gatings The code for takeback of Spartan promotions had broken this, as it was applied to gatings too, reverting the moved piece to Pawn! --- lasker-2.2.3/src/movecheck.c | 13 ++++++------- 1 files changed, 6 insertions(+), 7 deletions(-) diff --git a/lasker-2.2.3/src/movecheck.c b/lasker-2.2.3/src/movecheck.c index 6d05050..d575915 100644 --- a/lasker-2.2.3/src/movecheck.c +++ b/lasker-2.2.3/src/movecheck.c @@ -2289,7 +2289,7 @@ int backup_move(int g, int mode) { struct game_state_t *gs; struct move_t *m, *m1; - int now, i; + int now, i, piece; if (game_globals.garray[g].link >= 0) /*IanO: not implemented for bughouse yet */ return MOVE_ILLEGAL; @@ -2330,12 +2330,11 @@ int backup_move(int g, int mode) gs->board[kingFromFile][rank] = KING | m->color; // King fromSquare goto cleanupMove; } + piece = gs->board[m->toFile][m->toRank]; if(gs->board[m->fromFile][m->fromRank] != NOPIECE) { // [HGM] from-square occupied; move must have been Seirawan-style gating gs->holding[gs->onMove==WHITE ? 1 : 0][piecetype(gs->board[m->fromFile][m->fromRank])-1]++; // put back in holdings (onMove not flipped yet!) - } - gs->board[m->fromFile][m->fromRank] = gs->board[m->toFile][m->toRank]; - if (m->piecePromotionTo != NOPIECE) { - int piece; + } else + if (m->piecePromotionTo != NOPIECE) { // it is a real promotion switch(piecetype(m->piecePromotionTo)) { // Spartan pieces came from Hoplite, Shogi is problematic case KING: case CAPTAIN: @@ -2347,9 +2346,9 @@ int backup_move(int g, int mode) case GOLD: // TODO: figure out what original was default: piece = PAWN; } - gs->board[m->fromFile][m->fromRank] = piece | - colorval(gs->board[m->fromFile][m->fromRank]); + piece |= colorval(gs->board[m->toFile][m->toRank]); } + gs->board[m->fromFile][m->fromRank] = piece; /****************** When takeback a _first_ move of rook, the ??rmoved variable must be cleared . To check, if the move is first, we should -- 1.7.0.4