diff -r 41bbfd4d17a3 -r 824c9522ce66 src/chess/bishop.c --- a/src/chess/bishop.c Mon Mar 31 14:08:00 2014 +0200 +++ b/src/chess/bishop.c Mon Mar 31 15:03:25 2014 +0200 @@ -35,7 +35,7 @@ return abs(move->torow-move->fromrow) == abs(move->tofile-move->fromfile); } -_Bool bishop_isblocked(Board board, Move *move) { +_Bool bishop_isblocked(GameState *gamestate, Move *move) { int dy = move->torow > move->fromrow ? 1 : -1; int dx = move->tofile > move->fromfile ? 1 : -1; @@ -45,7 +45,7 @@ while (x != move->tofile-dx && y != move->torow-dy) { x += dx; y += dy; - if (board[y][x]) { + if (gamestate->board[y][x]) { return 1; } } @@ -53,12 +53,12 @@ return 0; } -static int bishop_getloc_fixedfile(Board board, Move *move) { +static int bishop_getloc_fixedfile(GameState *gamestate, Move *move) { uint8_t d = abs(move->fromfile - move->tofile); - if (board[move->torow - d][move->fromfile] == move->piece) { + if (gamestate->board[move->torow - d][move->fromfile] == move->piece) { move->fromrow = move->torow - d; } - if (board[move->torow + d][move->fromfile] == move->piece) { + if (gamestate->board[move->torow + d][move->fromfile] == move->piece) { if (move->fromrow == POS_UNSPECIFIED) { move->fromrow = move->torow + d; } else { @@ -69,12 +69,12 @@ INVALID_POSITION : VALID_MOVE_SYNTAX; } -static int bishop_getloc_fixedrow(Board board, Move *move) { +static int bishop_getloc_fixedrow(GameState *gamestate, Move *move) { uint8_t d = abs(move->fromrow - move->torow); - if (board[move->fromrow][move->tofile - d] == move->piece) { + if (gamestate->board[move->fromrow][move->tofile - d] == move->piece) { move->fromfile = move->tofile - d; } - if (board[move->fromrow][move->tofile + d] == move->piece) { + if (gamestate->board[move->fromrow][move->tofile + d] == move->piece) { if (move->fromfile == POS_UNSPECIFIED) { move->fromfile = move->tofile + d; } else { @@ -85,14 +85,14 @@ INVALID_POSITION : VALID_MOVE_SYNTAX; } -int bishop_getlocation(Board board, Move *move) { +int bishop_getlocation(GameState *gamestate, Move *move) { if (move->fromfile != POS_UNSPECIFIED) { - return bishop_getloc_fixedfile(board, move); + return bishop_getloc_fixedfile(gamestate, move); } if (move->fromrow != POS_UNSPECIFIED) { - return bishop_getloc_fixedrow(board, move); + return bishop_getloc_fixedrow(gamestate, move); } _Bool amb = 0; @@ -100,7 +100,7 @@ uint8_t row = move->torow + d; if (isidx(row)) { uint8_t file = move->tofile + d; - if (isidx(file) && board[row][file] == move->piece) { + if (isidx(file) && gamestate->board[row][file] == move->piece) { if (amb) { return AMBIGUOUS_MOVE; } @@ -109,7 +109,7 @@ move->fromfile = file; } file = move->tofile - d; - if (isidx(file) && board[row][file] == move->piece) { + if (isidx(file) && gamestate->board[row][file] == move->piece) { if (amb) { return AMBIGUOUS_MOVE; }