- mlist = generate_direct_checks<PAWN>(pos, mlist, us, dc, ksq);
- mlist = generate_direct_checks<KNIGHT>(pos, mlist, us, dc, ksq);
- mlist = generate_direct_checks<BISHOP>(pos, mlist, us, dc, ksq);
- mlist = generate_direct_checks<ROOK>(pos, mlist, us, dc, ksq);
- return generate_direct_checks<QUEEN>(pos, mlist, us, dc, ksq);
+ mlist = generate_direct_checks<PAWN>(pos, mlist, us, ci);
+ mlist = generate_direct_checks<KNIGHT>(pos, mlist, us, ci);
+ mlist = generate_direct_checks<BISHOP>(pos, mlist, us, ci);
+ mlist = generate_direct_checks<ROOK>(pos, mlist, us, ci);
+ mlist = generate_direct_checks<QUEEN>(pos, mlist, us, ci);
+
+ if (pos.can_castle(us))
+ {
+ mlist = generate_castle_moves<KING_SIDE, true>(pos, mlist, us);
+ mlist = generate_castle_moves<QUEEN_SIDE, true>(pos, mlist, us);
+ }
+
+ return mlist;