aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
authorMarkus Uhlin <markus@nifty-networks.net>2024-05-05 16:33:24 +0200
committerMarkus Uhlin <markus@nifty-networks.net>2024-05-05 16:33:24 +0200
commita162b31328b95f2007c96028ef07c66731769a24 (patch)
treee8e2594ecdaf54816752650d324a18c796bcc685 /FICS
parentb51d04438de2f7226c4504b44dc34c8578923765 (diff)
Reformatted parse_move()
Diffstat (limited to 'FICS')
-rw-r--r--FICS/movecheck.c112
1 files changed, 57 insertions, 55 deletions
diff --git a/FICS/movecheck.c b/FICS/movecheck.c
index 026b33a..6bd8cd5 100644
--- a/FICS/movecheck.c
+++ b/FICS/movecheck.c
@@ -874,63 +874,65 @@ has_legal_move(game_state_t *gs)
}
/* This will end up being a very complicated function */
-PUBLIC int parse_move(char *mstr, game_state_t * gs, move_t * mt, int promote)
+PUBLIC int
+parse_move(char *mstr, game_state_t *gs, move_t *mt, int promote)
{
- int type = is_move(mstr);
- int result;
+ int result;
+ int type = is_move(mstr);
- mt->color = gs->onMove;
- switch (type) {
- case MS_NOTMOVE:
- return MOVE_ILLEGAL;
- break;
- case MS_COMP:
- mt->fromFile = mstr[0] - 'a';
- mt->fromRank = mstr[1] - '1';
- mt->toFile = mstr[2] - 'a';
- mt->toRank = mstr[3] - '1';
- break;
- case MS_COMPDASH:
- mt->fromFile = mstr[0] - 'a';
- mt->fromRank = mstr[1] - '1';
- mt->toFile = mstr[3] - 'a';
- mt->toRank = mstr[4] - '1';
- break;
- case MS_KCASTLE:
- mt->fromFile = 4;
- mt->toFile = 6;
- if (gs->onMove == WHITE) {
- mt->fromRank = 0;
- mt->toRank = 0;
- } else {
- mt->fromRank = 7;
- mt->toRank = 7;
- }
- break;
- case MS_QCASTLE:
- mt->fromFile = 4;
- mt->toFile = 2;
- if (gs->onMove == WHITE) {
- mt->fromRank = 0;
- mt->toRank = 0;
- } else {
- mt->fromRank = 7;
- mt->toRank = 7;
- }
- break;
- case MS_ALG:
- /* Fills in the mt structure */
- if ((result = alg_parse_move(mstr, gs, mt)) != MOVE_OK)
- return result;
- break;
- default:
- return MOVE_ILLEGAL;
- break;
- }
- if (!legal_move(gs, mt->fromFile, mt->fromRank, mt->toFile, mt->toRank)) {
- return MOVE_ILLEGAL;
- }
- return move_calculate(gs, mt, promote);
+ mt->color = gs->onMove;
+
+ switch (type) {
+ case MS_NOTMOVE:
+ return MOVE_ILLEGAL;
+ break;
+ case MS_COMP:
+ mt->fromFile = mstr[0] - 'a';
+ mt->fromRank = mstr[1] - '1';
+ mt->toFile = mstr[2] - 'a';
+ mt->toRank = mstr[3] - '1';
+ break;
+ case MS_COMPDASH:
+ mt->fromFile = mstr[0] - 'a';
+ mt->fromRank = mstr[1] - '1';
+ mt->toFile = mstr[3] - 'a';
+ mt->toRank = mstr[4] - '1';
+ break;
+ case MS_KCASTLE:
+ mt->fromFile = 4;
+ mt->toFile = 6;
+ if (gs->onMove == WHITE) {
+ mt->fromRank = 0;
+ mt->toRank = 0;
+ } else {
+ mt->fromRank = 7;
+ mt->toRank = 7;
+ }
+ break;
+ case MS_QCASTLE:
+ mt->fromFile = 4;
+ mt->toFile = 2;
+ if (gs->onMove == WHITE) {
+ mt->fromRank = 0;
+ mt->toRank = 0;
+ } else {
+ mt->fromRank = 7;
+ mt->toRank = 7;
+ }
+ break;
+ case MS_ALG:
+ // Fills in the mt structure
+ if ((result = alg_parse_move(mstr, gs, mt)) != MOVE_OK)
+ return result;
+ break;
+ default:
+ return MOVE_ILLEGAL;
+ break;
+ }
+
+ if (!legal_move(gs, mt->fromFile, mt->fromRank, mt->toFile, mt->toRank))
+ return MOVE_ILLEGAL;
+ return move_calculate(gs, mt, promote);
}
/*