diff -r 41bbfd4d17a3 -r 824c9522ce66 src/chess/rook.c --- a/src/chess/rook.c Mon Mar 31 14:08:00 2014 +0200 +++ b/src/chess/rook.c Mon Mar 31 15:03:25 2014 +0200 @@ -34,14 +34,14 @@ return move->torow == move->fromrow || move->tofile == move->fromfile; } -_Bool rook_isblocked(Board board, Move *move) { +_Bool rook_isblocked(GameState *gamestate, Move *move) { if (move->torow == move->fromrow) { int d = move->tofile > move->fromfile ? 1 : -1; uint8_t f = move->fromfile; while (f != move->tofile-d) { f += d; - if (board[move->fromrow][f]) { + if (gamestate->board[move->fromrow][f]) { return 1; } } @@ -50,7 +50,7 @@ uint8_t r = move->fromrow; while (r != move->torow - d) { r += d; - if (board[r][move->fromfile]) { + if (gamestate->board[r][move->fromfile]) { return 1; } } @@ -59,10 +59,10 @@ return 0; } -static int rook_getloc_fixedrow(Board board, Move *move) { +static int rook_getloc_fixedrow(GameState *gamestate, Move *move) { uint8_t file = POS_UNSPECIFIED; for (uint8_t f = 0 ; f < 8 ; f++) { - if (board[move->fromrow][f] == move->piece) { + if (gamestate->board[move->fromrow][f] == move->piece) { if (file == POS_UNSPECIFIED) { file = f; } else { @@ -78,10 +78,10 @@ } } -static int rook_getloc_fixedfile(Board board, Move *move) { +static int rook_getloc_fixedfile(GameState *gamestate, Move *move) { uint8_t row = POS_UNSPECIFIED; for (uint8_t r = 0 ; r < 8 ; r++) { - if (board[r][move->fromfile] == move->piece) { + if (gamestate->board[r][move->fromfile] == move->piece) { if (row == POS_UNSPECIFIED) { row = r; } else { @@ -97,13 +97,13 @@ } } -int rook_getlocation(Board board, Move *move) { +int rook_getlocation(GameState *gamestate, Move *move) { if (move->fromfile != POS_UNSPECIFIED) { if (move->fromfile == move->tofile) { - return rook_getloc_fixedfile(board, move); + return rook_getloc_fixedfile(gamestate, move); } else { - if (board[move->torow][move->fromfile] == move->piece) { + if (gamestate->board[move->torow][move->fromfile] == move->piece) { move->fromrow = move->torow; return VALID_MOVE_SYNTAX; } else { @@ -114,9 +114,9 @@ if (move->fromrow != POS_UNSPECIFIED) { if (move->fromrow == move->torow) { - return rook_getloc_fixedrow(board, move); + return rook_getloc_fixedrow(gamestate, move); } else { - if (board[move->fromrow][move->tofile] == move->piece) { + if (gamestate->board[move->fromrow][move->tofile] == move->piece) { move->fromfile = move->tofile; return VALID_MOVE_SYNTAX; } else { @@ -128,10 +128,10 @@ Move chkrowmove = *move, chkfilemove = *move; chkrowmove.fromrow = move->torow; - int chkrow = rook_getloc_fixedrow(board, &chkrowmove); + int chkrow = rook_getloc_fixedrow(gamestate, &chkrowmove); chkfilemove.fromfile = move->tofile; - int chkfile = rook_getloc_fixedfile(board, &chkfilemove); + int chkfile = rook_getloc_fixedfile(gamestate, &chkfilemove); if ((chkrow == VALID_MOVE_SYNTAX && chkfile == VALID_MOVE_SYNTAX) || chkrow == AMBIGUOUS_MOVE || chkfile == AMBIGUOUS_MOVE) {