aboutsummaryrefslogtreecommitdiffstats
path: root/FICS/movecheck.c
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-03-16 13:21:52 +0100
committerMarkus Uhlin <markus@nifty-networks.net>2024-03-16 13:21:52 +0100
commita704efd17dbf155ff98eca67cad23bcdccfdf4a7 (patch)
treeb818adce22ac62bae572d18919a687b1bde27d99 /FICS/movecheck.c
parent52052622133895ca1a579ec57f97dc653067166e (diff)
Moved code to update_enpassant_array()
Diffstat (limited to 'FICS/movecheck.c')
-rw-r--r--FICS/movecheck.c59
1 files changed, 34 insertions, 25 deletions
diff --git a/FICS/movecheck.c b/FICS/movecheck.c
index 99996eb..99254be 100644
--- a/FICS/movecheck.c
+++ b/FICS/movecheck.c
@@ -1251,6 +1251,39 @@ backup_move_timeseal_block(int g, move_t *m)
}
#endif // TIMESEAL
+PRIVATE void
+update_enpassant_array(int g, int mode, game_state_t *gs)
+{
+ move_t *m1;
+
+ if (!(garray[g].numHalfMoves > 0))
+ return;
+
+ m1 = ((mode == REL_GAME)
+ ? &garray[g].moveList[garray[g].numHalfMoves - 1]
+ : &garray[g].examMoveList[garray[g].numHalfMoves - 1]);
+
+ if (piecetype(gs->board[m1->toFile][m1->toRank]) == PAWN) {
+ if ((m1->toRank - m1->fromRank) == 2) {
+ if (m1->toFile < 7 &&
+ gs->board[m1->toFile + 1][3] == B_PAWN)
+ gs->ep_possible[1][m1->toFile + 1] = -1;
+ if (m1->toFile - 1 >= 0 &&
+ gs->board[m1->toFile - 1][3] == B_PAWN)
+ gs->ep_possible[1][m1->toFile - 1] = 1;
+ }
+
+ if ((m1->toRank - m1->fromRank) == -2) {
+ if (m1->toFile < 7 &&
+ gs->board[m1->toFile + 1][4] == W_PAWN)
+ gs->ep_possible[0][m1->toFile + 1] = -1;
+ if (m1->toFile - 1 >= 0 &&
+ gs->board[m1->toFile - 1][4] == W_PAWN)
+ gs->ep_possible[0][m1->toFile - 1] = 1;
+ }
+ }
+}
+
PUBLIC int
backup_move(int g, int mode)
{
@@ -1445,31 +1478,7 @@ backup_move(int g, int mode)
* Takeback of last move is done already. It's time to update
* enpassant array...
*/
- if (garray[g].numHalfMoves > 0) {
- m1 = ((mode == REL_GAME)
- ? &garray[g].moveList[garray[g].numHalfMoves - 1]
- : &garray[g].examMoveList[garray[g].numHalfMoves - 1]);
-
- if (piecetype(gs->board[m1->toFile][m1->toRank]) == PAWN) {
- if ((m1->toRank - m1->fromRank) == 2) {
- if (m1->toFile < 7 &&
- gs->board[m1->toFile + 1][3] == B_PAWN)
- gs->ep_possible[1][m1->toFile + 1] = -1;
- if (m1->toFile - 1 >= 0 &&
- gs->board[m1->toFile - 1][3] == B_PAWN)
- gs->ep_possible[1][m1->toFile - 1] = 1;
- }
-
- if ((m1->toRank - m1->fromRank) == -2) {
- if (m1->toFile < 7 &&
- gs->board[m1->toFile + 1][4] == W_PAWN)
- gs->ep_possible[0][m1->toFile + 1] = -1;
- if (m1->toFile - 1 >= 0 &&
- gs->board[m1->toFile - 1][4] == W_PAWN)
- gs->ep_possible[0][m1->toFile - 1] = 1;
- }
- }
- }
+ update_enpassant_array(g, mode, gs);
return MOVE_OK;
}