aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-03-30 13:15:23 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-03-30 13:15:23 +0100
commitd3893b06c673a3e9d0e6e6841001cd36dbb834b8 (patch)
treef424275fcd5e0f2a8608825c30940aa4c646e056
parentf97f76d9e526f9cf6b85d77ff64a4c89df864772 (diff)
Reformatted CheckRepetition() and made it private
-rw-r--r--FICS/gameproc.c61
1 files changed, 34 insertions, 27 deletions
diff --git a/FICS/gameproc.c b/FICS/gameproc.c
index 38c7849..b386090 100644
--- a/FICS/gameproc.c
+++ b/FICS/gameproc.c
@@ -753,34 +753,41 @@ GetFENpos(int g, int half_move)
return ((char *)garray[g].moveList[half_move].FENpos);
}
-int CheckRepetition (int p, int g)
+PRIVATE int
+CheckRepetition(int p, int g)
{
- int move_num;
- int flag1 = 1, flag2 = 1;
- char *pos1 = GetFENpos (g, garray[g].numHalfMoves - 1);
- char *pos2 = GetFENpos (g, garray[g].numHalfMoves);
- char *pos;
-
- if (garray[g].numHalfMoves < 8) /* can't have three repeats any quicker. */
- return 0;
-
- for (move_num = garray[g].game_state.lastIrreversable;
- move_num < garray[g].numHalfMoves - 1; move_num++) {
- pos = GetFENpos (g, move_num);
- if (strlen(pos1) == strlen(pos) && !strcmp(pos1, pos))
- flag1++;
- if (strlen(pos2) == strlen(pos) && !strcmp(pos2, pos))
- flag2++;
- }
- if (flag1 >= 3 || flag2 >= 3) {
- if (player_find_pendfrom(p, parray[p].opponent, PEND_DRAW) >= 0) {
- player_remove_request(parray[p].opponent, p, PEND_DRAW);
- player_decline_offers(p, -1, -1);
- }
- game_ended(g, (garray[g].white == p) ? BLACK : WHITE, END_REPETITION);
- return 1;
- }
- else return 0;
+ char *pos1 = GetFENpos(g, garray[g].numHalfMoves - 1);
+ char *pos2 = GetFENpos(g, garray[g].numHalfMoves);
+ char *pos;
+ int flag1 = 1, flag2 = 1;
+ int move_num;
+
+ if (garray[g].numHalfMoves < 8) // Can't have three repeats any quicker.
+ return 0;
+
+ for (move_num = garray[g].game_state.lastIrreversable;
+ move_num < garray[g].numHalfMoves - 1;
+ move_num++) {
+ pos = GetFENpos(g, move_num);
+
+ if (strlen(pos1) == strlen(pos) && !strcmp(pos1, pos))
+ flag1++;
+ if (strlen(pos2) == strlen(pos) && !strcmp(pos2, pos))
+ flag2++;
+ }
+
+ if (flag1 >= 3 || flag2 >= 3) {
+ if (player_find_pendfrom(p, parray[p].opponent, PEND_DRAW)
+ >= 0) {
+ player_remove_request(parray[p].opponent, p, PEND_DRAW);
+ player_decline_offers(p, -1, -1);
+ }
+
+ game_ended(g, (garray[g].white == p ? BLACK : WHITE),
+ END_REPETITION);
+ return 1;
+ } else
+ return 0;
}
PUBLIC int