aboutsummaryrefslogtreecommitdiff
path: root/src/moves.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/moves.cpp')
-rw-r--r--src/moves.cpp7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/moves.cpp b/src/moves.cpp
index 163bb8c..803538b 100644
--- a/src/moves.cpp
+++ b/src/moves.cpp
@@ -417,6 +417,13 @@ void GenerateCastlingMoves(int from, Game *g, std::vector<Move> &moves) {
bool oneToLeft = g->PieceBitboard & (1ULL << (from - 1));
bool twoToLeft = g->PieceBitboard & (1ULL << (from - 2));
bool threeToLeft = g->PieceBitboard & (1ULL << (from - 3));
+
+ Position kingPosition = FindKing(g, g->turn);
+
+ bool check = IsSquareAttacked(g, kingPosition, !g->turn);
+ if (check) {
+ return;
+ }
if (g->turn) {
// white
if (!oneToRight && !twoToRight && g->whiteCastleKing) {