1.1 --- a/src/chess/knight.c Mon Mar 31 14:08:00 2014 +0200 1.2 +++ b/src/chess/knight.c Mon Mar 31 15:03:25 2014 +0200 1.3 @@ -38,12 +38,12 @@ 1.4 return (dx == 2 && dy == 1) || (dx == 1 && dy == 2); 1.5 } 1.6 1.7 -static int knight_getloc_fixedrow(Board board, Move *move) { 1.8 +static int knight_getloc_fixedrow(GameState *gamestate, Move *move) { 1.9 int d = 3 - abs(move->fromrow - move->torow); 1.10 1.11 if (d == 1 || d == 2) { 1.12 if (move->tofile < 6 && 1.13 - board[move->fromrow][move->tofile + d] == move->piece) { 1.14 + gamestate->board[move->fromrow][move->tofile + d] == move->piece) { 1.15 if (move->fromfile == POS_UNSPECIFIED) { 1.16 move->fromfile = move->tofile + d; 1.17 return VALID_MOVE_SYNTAX; 1.18 @@ -52,7 +52,7 @@ 1.19 } 1.20 } 1.21 if (move->tofile > 1 && 1.22 - board[move->fromrow][move->tofile - d] == move->piece) { 1.23 + gamestate->board[move->fromrow][move->tofile - d] == move->piece) { 1.24 if (move->fromfile == POS_UNSPECIFIED) { 1.25 move->fromfile = move->tofile - d; 1.26 return VALID_MOVE_SYNTAX; 1.27 @@ -65,12 +65,12 @@ 1.28 return INVALID_POSITION; 1.29 } 1.30 1.31 -static int knight_getloc_fixedfile(Board board, Move *move) { 1.32 +static int knight_getloc_fixedfile(GameState *gamestate, Move *move) { 1.33 int d = 3 - abs(move->fromfile - move->tofile); 1.34 1.35 if (d == 1 || d == 2) { 1.36 if (move->torow < 6 && 1.37 - board[move->torow + d][move->fromfile] == move->piece) { 1.38 + gamestate->board[move->torow + d][move->fromfile] == move->piece) { 1.39 if (move->fromrow == POS_UNSPECIFIED) { 1.40 move->fromrow = move->torow + d; 1.41 return VALID_MOVE_SYNTAX; 1.42 @@ -79,7 +79,7 @@ 1.43 } 1.44 } 1.45 if (move->torow > 1 && 1.46 - board[move->torow - d][move->fromfile] == move->piece) { 1.47 + gamestate->board[move->torow - d][move->fromfile] == move->piece) { 1.48 if (move->fromrow == POS_UNSPECIFIED) { 1.49 move->fromrow = move->torow - d; 1.50 return VALID_MOVE_SYNTAX; 1.51 @@ -92,14 +92,14 @@ 1.52 return INVALID_POSITION; 1.53 } 1.54 1.55 -int knight_getlocation(Board board, Move *move) { 1.56 +int knight_getlocation(GameState *gamestate, Move *move) { 1.57 1.58 if (move->fromfile != POS_UNSPECIFIED) { 1.59 - return knight_getloc_fixedfile(board, move); 1.60 + return knight_getloc_fixedfile(gamestate, move); 1.61 } 1.62 1.63 if (move->fromrow != POS_UNSPECIFIED) { 1.64 - return knight_getloc_fixedrow(board, move); 1.65 + return knight_getloc_fixedrow(gamestate, move); 1.66 } 1.67 1.68 for (int x = -2 ; x <= 2 ; x++) { 1.69 @@ -113,7 +113,8 @@ 1.70 uint8_t cx = move->tofile + x; 1.71 uint8_t cy = move->torow + y; 1.72 1.73 - if (isidx(cx) && isidx(cy) && board[cy][cx] == move->piece) { 1.74 + if (isidx(cx) && isidx(cy) 1.75 + && gamestate->board[cy][cx] == move->piece) { 1.76 if (move->fromfile == POS_UNSPECIFIED 1.77 && move->fromrow == POS_UNSPECIFIED) { 1.78 move->fromfile = cx;