aboutsummaryrefslogtreecommitdiffstats
path: root/FICS
diff options
context:
space:
mode:
Diffstat (limited to 'FICS')
-rw-r--r--FICS/obsproc.c97
1 files changed, 55 insertions, 42 deletions
diff --git a/FICS/obsproc.c b/FICS/obsproc.c
index a9cf6d4..42576a2 100644
--- a/FICS/obsproc.c
+++ b/FICS/obsproc.c
@@ -1308,50 +1308,63 @@ PUBLIC int com_backward(int p, param_list param)
return COM_OK;
}
-PUBLIC int com_revert(int p, param_list param)
+PUBLIC int
+com_revert(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;
+ }
- 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;
- nHalfMoves = garray[g].numHalfMoves - garray[g].revertHalfMove;
- if (nHalfMoves == 0) {
- pprintf(p, "Already at mainline.\n");
- return COM_OK;
- }
- if (nHalfMoves < 0) { /* eek - should NEVER happen! */
- fprintf(stderr, "OUCH! in com_revert: nHalfMoves < 0\n");
- return COM_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, "%s reverts to mainline.\n", parray[p].name);
- }
- }
- for (i = 0; i < nHalfMoves; i++) {
- backup_move(g, REL_EXAMINE);/* should never return error */
- }
- /* 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;
+ nHalfMoves = garray[g].numHalfMoves - garray[g].revertHalfMove;
+
+ if (nHalfMoves == 0) {
+ pprintf(p, "Already at mainline.\n");
+ return COM_OK;
+ }
+
+ if (nHalfMoves < 0) { // eek - should NEVER happen!
+ fprintf(stderr, "OUCH! in %s: nHalfMoves < 0\n", __func__);
+ return COM_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, "%s reverts to mainline.\n",
+ parray[p].name);
+ }
+ }
+
+ for (i = 0; i < nHalfMoves; i++)
+ backup_move(g, REL_EXAMINE);
+
+ // 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