diff -r 4dcfb4c58b6d -r d726e4b46c33 src/chess/king.c --- a/src/chess/king.c Thu Apr 17 12:16:14 2014 +0200 +++ b/src/chess/king.c Wed May 28 15:47:57 2014 +0200 @@ -69,9 +69,11 @@ _Bool king_isblocked(GameState *gamestate, Move *move) { uint8_t opponent_color = opponent_color(move->piece&COLOR_MASK); - _Bool blocked = is_covered(gamestate, move->torow, move->tofile, - opponent_color); + // being in check does not "block" the king, so don't test it here + _Bool blocked = 0; + + // just test, if castling move is blocked if (abs(move->tofile - move->fromfile) == 2) { if (move->tofile == fileidx('c')) { blocked |= gamestate->board[move->torow][fileidx('b')]; @@ -84,33 +86,3 @@ return blocked; } - -int king_getlocation(GameState *gamestate, Move *move) { - - uint8_t file, row; - - for (int f = -1 ; f <= 1 ; f++) { - for (int r = -1 ; r <= 1 ; r++) { - if (f == 0 && r == 0) { - continue; - } - file = move->tofile + f; - row = move->torow + r; - if (isidx(file) && isidx(row)) { - if (gamestate->board[row][file] == move->piece) { - if ((move->fromfile != POS_UNSPECIFIED - && move->fromfile != file) || - (move->fromrow != POS_UNSPECIFIED - && move->fromrow != row)) { - return INVALID_POSITION; - } - move->fromfile = file; - move->fromrow = row; - return VALID_MOVE_SYNTAX; - } - } - } - } - - return INVALID_POSITION; -}