diff options
author | Markus Uhlin <markus@nifty-networks.net> | 2024-04-20 15:37:56 +0200 |
---|---|---|
committer | Markus Uhlin <markus@nifty-networks.net> | 2024-04-20 15:37:56 +0200 |
commit | 08f4a8d9e2f99cc8241df5eaa36562972d6162b5 (patch) | |
tree | e5290e994243010acd873b103b4afc4cf9c07c92 /FICS/obsproc.c | |
parent | 73a4b058b3f433ff66de53ab641bd8d9de6fc462 (diff) |
Reformatted com_backward()
Diffstat (limited to 'FICS/obsproc.c')
-rw-r--r-- | FICS/obsproc.c | 113 |
1 files changed, 63 insertions, 50 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c index 42576a2..ad72ee2 100644 --- a/FICS/obsproc.c +++ b/FICS/obsproc.c @@ -1252,60 +1252,73 @@ PUBLIC int com_forward(int p, param_list param) return COM_OK; } -PUBLIC int com_backward(int p, param_list param) +PUBLIC int +com_backward(int p, param_list param) { - int nHalfMoves = 1; - int g, i; - int p1; - unsigned now; + int g, i; + int nHalfMoves = 1; + int p1; + unsigned int now; - if (!((parray[p].game >=0) &&(garray[parray[p].game].status == GAME_EXAMINE))) { - pprintf(p, "You are not examining any games.\n"); - return COM_OK; - } - g = parray[p].game; - if (param[0].type == TYPE_INT) { - nHalfMoves = param[0].val.integer; - } - if (garray[g].numHalfMoves != 0) { - for (p1 = 0; p1 < p_num; p1++) { - if (parray[p1].status != PLAYER_PROMPT) - continue; - if (player_is_observe(p1, g) || parray[p1].game == g) { - pprintf(p1, "%s backs up %d move%s.\n", - parray[p].name, nHalfMoves, (nHalfMoves == 1) ? "" : "s"); - } - } - } - for (i = 0; i < nHalfMoves; i++) { - if (backup_move(g, REL_EXAMINE) != MOVE_OK) { - for (p1 = 0; p1 < p_num; p1++) { - if (parray[p1].status != PLAYER_PROMPT) - continue; - if (player_is_observe(p1, g) || parray[p1].game == g) { - pprintf(p1, "Beginning of game.\n"); + if (!(parray[p].game >= 0 && garray[parray[p].game].status == + GAME_EXAMINE)) { + pprintf(p, "You are not examining any games.\n"); + return COM_OK; } - } - break; - } - } - if (garray[g].numHalfMoves < garray[g].revertHalfMove) { - garray[g].revertHalfMove = garray[g].numHalfMoves; - } - /* roll back time */ - if (garray[g].game_state.onMove == WHITE) { - garray[g].wTime += (garray[g].lastDecTime - garray[g].lastMoveTime); - } else { - garray[g].bTime += (garray[g].lastDecTime - garray[g].lastMoveTime); - } - now = tenth_secs(); - if (garray[g].numHalfMoves == 0) - garray[g].timeOfStart = now; - garray[g].lastMoveTime = now; - garray[g].lastDecTime = now; - send_boards(g); - return COM_OK; + g = parray[p].game; + + if (param[0].type == TYPE_INT) + nHalfMoves = param[0].val.integer; + + if (garray[g].numHalfMoves != 0) { + for (p1 = 0; p1 < p_num; p1++) { + if (parray[p1].status != PLAYER_PROMPT) + continue; + if (player_is_observe(p1, g) || parray[p1].game == g) { + pprintf(p1, "%s backs up %d move%s.\n", + parray[p].name, + nHalfMoves, + (nHalfMoves == 1 ? "" : "s")); + } + } + } + + for (i = 0; i < nHalfMoves; i++) { + if (backup_move(g, REL_EXAMINE) != MOVE_OK) { + for (p1 = 0; p1 < p_num; p1++) { + if (parray[p1].status != PLAYER_PROMPT) + continue; + if (player_is_observe(p1, g) || + parray[p1].game == g) + pprintf(p1, "Beginning of game.\n"); + } + + break; + } + } + + if (garray[g].numHalfMoves < garray[g].revertHalfMove) + garray[g].revertHalfMove = garray[g].numHalfMoves; + + // roll back time + if (garray[g].game_state.onMove == WHITE) { + garray[g].wTime += (garray[g].lastDecTime - + garray[g].lastMoveTime); + } else { + garray[g].bTime += (garray[g].lastDecTime - + garray[g].lastMoveTime); + } + + now = tenth_secs(); + + if (garray[g].numHalfMoves == 0) + garray[g].timeOfStart = now; + garray[g].lastMoveTime = now; + garray[g].lastDecTime = now; + + send_boards(g); + return COM_OK; } PUBLIC int |