aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/movecheck.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2023-12-14 22:24:35 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2023-12-14 22:24:35 +0100
commitbc2d7526523c0aaed9552890417ce405baf25262 (patch)
tree8a46a9571cef5afed76de54dbedcf61f1b977629 /FICS/movecheck.c
parent768f239fde031dc867b308d6f1692c1d8304169a (diff)
Added check
Diffstat (limited to 'FICS/movecheck.c')
-rw-r--r--FICS/movecheck.c24
1 files changed, 15 insertions, 9 deletions
diff --git a/FICS/movecheck.c b/FICS/movecheck.c
index 45bcd24..4d0ecd0 100644
--- a/FICS/movecheck.c
+++ b/FICS/movecheck.c
@@ -755,16 +755,16 @@ PUBLIC int in_check(game_state_t * gs)
return 0;
}
-PRIVATE
-int
+PRIVATE int
has_legal_move(game_state_t *gs)
{
- int f, r;
- int i;
- int kf, kr;
- int numpossible = 0;
- int possiblef[500];
- int possibler[500];
+ int f, r;
+ int i;
+ int kf, kr;
+ int kf_and_kr_set = 0;
+ int numpossible = 0;
+ int possiblef[500];
+ int possibler[500];
for (InitPieceLoop(gs->board, &f, &r, gs->onMove);
NextPieceLoop(gs->board, &f, &r, gs->onMove);) {
@@ -792,6 +792,7 @@ has_legal_move(game_state_t *gs)
case KING:
kf = f;
kr = r;
+ kf_and_kr_set = 1;
possible_king_moves(gs, f, r, possiblef, possibler,
&numpossible);
break;
@@ -805,8 +806,13 @@ has_legal_move(game_state_t *gs)
}
}
+ if (!kf_and_kr_set) {
+ fprintf(stderr, "FICS: %s: 'kf_and_kr_set' is 0\n", __func__);
+ return 0;
+ }
+
// IanO: if we got here, then kf and kr must be set
- if (gs->gameNum >=0 && garray[gs->gameNum].link >= 0) {
+ if (gs->gameNum >= 0 && garray[gs->gameNum].link >= 0) {
// bughouse: potential drops as check interpositions
gs->holding[gs->onMove == WHITE ? 0 : 1][QUEEN - 1]++;
for (f = kf - 1; f <= kf + 1; f++) {