1.1 --- a/src/chess/rules.c Wed Aug 29 17:05:40 2018 +0200 1.2 +++ b/src/chess/rules.c Wed Aug 29 17:31:36 2018 +0200 1.3 @@ -576,6 +576,7 @@ 1.4 static int getlocation(GameState *gamestate, Move *move) { 1.5 1.6 uint8_t color = move->piece & COLOR_MASK; 1.7 + uint8_t piece = move->piece & PIECE_MASK; 1.8 _Bool incheck = gamestate->lastmove?gamestate->lastmove->move.check:0; 1.9 1.10 Move threats[16], *threat = NULL; 1.11 @@ -588,8 +589,8 @@ 1.12 1.13 /* find threats for the specified position */ 1.14 for (uint8_t i = 0 ; i < threatcount ; i++) { 1.15 - if ((threats[i].piece & (PIECE_MASK | COLOR_MASK)) 1.16 - == move->piece && 1.17 + if ((threats[i].piece & PIECE_MASK) == piece 1.18 + && (threats[i].piece & COLOR_MASK) == color && 1.19 (move->fromrow == POS_UNSPECIFIED || 1.20 move->fromrow == threats[i].fromrow) && 1.21 (move->fromfile == POS_UNSPECIFIED || 1.22 @@ -600,7 +601,8 @@ 1.23 } else { 1.24 /* found threat is no real threat */ 1.25 if (is_pinned(gamestate, &(threats[i]))) { 1.26 - reason = incheck?KING_IN_CHECK:PIECE_PINNED; 1.27 + reason = incheck?KING_IN_CHECK: 1.28 + (piece==KING?KING_MOVES_INTO_CHECK:PIECE_PINNED); 1.29 } else { 1.30 threat = &(threats[i]); 1.31 }