summaryrefslogtreecommitdiff
path: root/src/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.c')
-rw-r--r--src/main.c10
1 files changed, 5 insertions, 5 deletions
diff --git a/src/main.c b/src/main.c
index c855a6e..3df8e2b 100644
--- a/src/main.c
+++ b/src/main.c
@@ -255,13 +255,13 @@ int validate_move(Move move, int color, int* board) {
// Handle castling
if ((piece & NO_COLOR) == KING) {
if (piece % 2 == WHITE && move.origin == 4) {
- if (move.destination == 2) {
+ if (move.destination == 2 && board[0] == (ROOK | WHITE)) {
if (list_moves_with_destination(NULL, board, color ^ 1, move.origin)) return -5;
for (int i = 1; i < 4; i++) {
if (board[i] != EMPTY || list_moves_with_destination(NULL, board, color ^ 1, i)) return -5;
}
return 0;
- } else if (move.destination == 6) {
+ } else if (move.destination == 6 && board[7] == (ROOK | WHITE)) {
if (list_moves_with_destination(NULL, board, color ^ 1, move.origin)) return -5;
for (int i = 5; i < 7; i++) {
if (board[i] != EMPTY || list_moves_with_destination(NULL, board, color ^ 1, i)) return -5;
@@ -269,13 +269,13 @@ int validate_move(Move move, int color, int* board) {
return 0;
}
} else if (piece % 2 == BLACK && move.origin == 116) {
- if (move.destination == 114) {
+ if (move.destination == 114 && board[112] == (ROOK | BLACK)) {
if (list_moves_with_destination(NULL, board, color ^ 1, move.origin)) return -5;
- for (int i = 114; i < 116; i++) {
+ for (int i = 113; i < 116; i++) {
if (board[i] != EMPTY || list_moves_with_destination(NULL, board, color ^ 1, i)) return -5;
}
return 0;
- } else if (move.destination == 118) {
+ } else if (move.destination == 118 && board[119] == (ROOK | BLACK)) {
if (list_moves_with_destination(NULL, board, color ^ 1, move.origin)) return -5;
for (int i = 117; i < 119; i++) {
if (board[i] != EMPTY || list_moves_with_destination(NULL, board, color ^ 1, i)) return -5;