[Commit] rrserver dispatch.5c,1.28,1.29 games.5c,1.25,1.26
Keith Packard
commit at keithp.com
Thu Jun 26 05:20:14 PDT 2003
Committed by: keithp
Update of /local/src/CVS/rrserver
In directory home.keithp.com:/tmp/cvs-serv8410
Modified Files:
dispatch.5c games.5c
Log Message:
Catch and handle io_error on client. Move to SHOW when last bidding client exits. Move to DONE when SHOW starts completed
Index: dispatch.5c
===================================================================
RCS file: /local/src/CVS/rrserver/dispatch.5c,v
retrieving revision 1.28
retrieving revision 1.29
diff -u -d -r1.28 -r1.29
--- dispatch.5c 26 Jun 2003 09:18:28 -0000 1.28
+++ dispatch.5c 26 Jun 2003 11:20:11 -0000 1.29
@@ -635,7 +635,14 @@
raise rr_error (Error.COMMAND);
} catch rr_error (Error e) {
respond ("ERROR %E\n", e);
+ } catch File::io_error (string msg,
+ File::error_type error,
+ file f) {
+ File::fprintf (stderr, "%v: %s\n",
+ c.user, msg);
+ return;
} catch closed () {
+ File::fprintf (stderr, "%v: closed\n", c.user);
return;
}
}
Index: games.5c
===================================================================
RCS file: /local/src/CVS/rrserver/games.5c,v
retrieving revision 1.25
retrieving revision 1.26
diff -u -d -r1.25 -r1.26
--- games.5c 26 Jun 2003 09:07:12 -0000 1.25
+++ games.5c 26 Jun 2003 11:20:11 -0000 1.26
@@ -253,6 +253,21 @@
}
}
+ void check_solved (&Game g) {
+ if (g.state != GameState.DONE && Boards::solved (&g.board))
+ {
+ if (g.active != ClientRef.none)
+ {
+ /* score */
+ g.active.client.score++;
+ game_send (&g, "NOTICE SCORE %s %d\n",
+ g.active.client.user.username,
+ g.active.client.score);
+ }
+ set_state (&g, GameState.DONE);
+ }
+ }
+
void set_state (&Game g, GameState state) {
if (g.state == state)
return;
@@ -284,6 +299,7 @@
case GameState.SHOW:
g.active = ClientRef.none;
set_active (&g);
+ check_solved (&g);
break;
case GameState.DONE:
g.active = ClientRef.none;
@@ -475,6 +491,8 @@
case GameState.BID:
if (!any_bids (&g))
set_state (&g, GameState.NEW);
+ else if (all_nobid (&g))
+ set_state (&g, GameState.SHOW);
break;
case GameState.SHOW:
set_active (&g);
@@ -598,18 +616,7 @@
make_move (&g, &loc, color, dir);
game_send (&g, "NOTICE MOVE %d %C %D\n", count (&g), color, dir);
game_send_loc (&g, &loc);
- if (g.state != GameState.DONE && Boards::solved (&g.board))
- {
- if (g.active != ClientRef.none)
- {
- /* score */
- g.active.client.score++;
- game_send (&g, "NOTICE SCORE %s %d\n",
- g.active.client.user.username,
- g.active.client.score);
- }
- set_state (&g, GameState.DONE);
- }
+ check_solved (&g);
}
/*
More information about the Commit
mailing list