[Commit] rrserver dispatch.5c,1.15,1.16 games.5c,1.13,1.14
protocol,1.23,1.24 rr.5c,1.7,1.8 send.5c,1.5,1.6
Keith Packard
commit at keithp.com
Fri May 30 23:28:16 PDT 2003
Committed by: keithp
Update of /local/src/CVS/rrserver
In directory home.keithp.com:/tmp/cvs-serv14823
Modified Files:
dispatch.5c games.5c protocol rr.5c send.5c
Log Message:
Dont let watching users manipulate the game
Index: dispatch.5c
===================================================================
RCS file: /local/src/CVS/rrserver/dispatch.5c,v
retrieving revision 1.15
retrieving revision 1.16
diff -u -d -r1.15 -r1.16
--- dispatch.5c 31 May 2003 02:47:47 -0000 1.15
+++ dispatch.5c 31 May 2003 05:28:14 -0000 1.16
@@ -279,7 +279,7 @@
if (c.game == GameRef.none)
raise error (Error.NOTINGAME);
}
-
+
void print_client_score (&Client o) {
Clients::print_client_score (&c, &o);
}
@@ -480,7 +480,7 @@
void turn () {
assert_user ();
assert_game ();
- Games::next_turn (&c.game.game);
+ Games::next_turn (&c.game.game, &c);
respond ("TURN\n");
}
Index: games.5c
===================================================================
RCS file: /local/src/CVS/rrserver/games.5c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- games.5c 31 May 2003 02:45:27 -0000 1.13
+++ games.5c 31 May 2003 05:28:14 -0000 1.14
@@ -47,6 +47,16 @@
public exception no_such_game (string name);
+ void assert_active (&Game g, &Client c) {
+ if (g.active != (ClientRef.client) (&c))
+ raise error (Error.NOTACTIVE);
+ }
+
+ void assert_playing (&Game c, &Client c) {
+ if (!c.playing)
+ raise error (Error.NOTPLAYING);
+ }
+
/* find a game by name */
public &Game find (string name) {
exception found (&Game g);
@@ -276,7 +286,8 @@
game_send (&g, "NOTICE TURN %C %S\n", g.target.color, g.target.shape);
}
- public void next_turn (&Game g) {
+ public void next_turn (&Game g, &Client c) {
+ assert_playing (&g, &c);
switch (g.state) {
case GameState.New:
case GameState.Bidding:
@@ -368,11 +379,6 @@
return g.active;
}
- void assert_active (&Game g, &Client c) {
- if (g.active != (ClientRef.client) (&c))
- raise error (Error.NOTACTIVE);
- }
-
void assert_bidding (&Game g) {
switch (g.state) {
case GameState.New:
@@ -387,6 +393,7 @@
}
public void undo (&Game g, &Client c) {
+ assert_playing (&g, &c);
assert_active (&g, &c);
if (dim (g.history) > 0)
{
@@ -396,11 +403,13 @@
}
public void reset (&Game g, &Client c) {
+ assert_playing (&g, &c);
assert_active (&g, &c);
reset_move (&g);
}
public void pass (&Game g, &Client c) {
+ assert_playing (&g, &c);
assert_active (&g, &c);
reset (&g, &c);
c.bid = Bid.none;
@@ -408,6 +417,7 @@
}
public void bid (&Game g, &Client c, int number) {
+ assert_playing (&g, &c);
assert_bidding (&g);
if (g.state == GameState.New)
set_state (&g, GameState.Bidding);
@@ -420,6 +430,7 @@
}
public void revoke (&Game g, &Client c) {
+ assert_playing (&g, &c);
assert_bidding (&g);
if (c.bid == Bid.none)
raise error (Error.NOBID);
@@ -430,6 +441,7 @@
}
public void abandon (&Game g, &Client c) {
+ assert_playing (&g, &c);
assert_bidding (&g);
if (!c.abandon) {
c.abandon = true;
@@ -444,6 +456,7 @@
}
public void move (&Game g, &Client c, Color color, Direction dir) {
+ assert_playing (&g, &c);
assert_active (&g, &c);
if (count (&g) >= c.bid.number)
raise error (Error.TOOMANYMOVES);
Index: protocol
===================================================================
RCS file: /local/src/CVS/rrserver/protocol,v
retrieving revision 1.23
retrieving revision 1.24
diff -u -d -r1.23 -r1.24
--- protocol 31 May 2003 03:29:58 -0000 1.23
+++ protocol 31 May 2003 05:28:14 -0000 1.24
@@ -1,6 +1,6 @@
Ricochet Robots Game Protocol (RRGP)
- Version 0.1
- 2003-5-27
+ Version 0.1.1
+ 2003-5-30
Keith Packard Carl Worth
keithp at keithp.com cworth at isi.edu
@@ -587,7 +587,7 @@
3.6.1. Global game errors
- 3.1. Not in game
+ 3.6.1.1. Not in game
ERROR NOTINGAME
@@ -597,7 +597,14 @@
Possibly returned by: SHOW, MOVE, RESET, UNDO, TURN, PASS,
MESSAGE.
- 3.3.3. Not finished
+ 3.6.1.2. Not playing
+
+ ERROR NOTPLAYING
+
+ A command was executed by a watching user that is
+ permitted only to players
+
+ 3.6.1.3. Not finished
ERROR NOTFINISHED
Index: rr.5c
===================================================================
RCS file: /local/src/CVS/rrserver/rr.5c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rr.5c 31 May 2003 02:45:27 -0000 1.7
+++ rr.5c 31 May 2003 05:28:14 -0000 1.8
@@ -208,6 +208,7 @@
NOGAME,
NOUSER,
NOTINGAME,
+ NOTPLAYING,
NOTBIDDING,
NOTLOWER,
NOBID,
Index: send.5c
===================================================================
RCS file: /local/src/CVS/rrserver/send.5c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- send.5c 30 May 2003 22:15:14 -0000 1.5
+++ send.5c 31 May 2003 05:28:14 -0000 1.6
@@ -103,6 +103,7 @@
case Error.NOGAME: File::fprintf (f, "NOGAME"); break;
case Error.NOUSER: File::fprintf (f, "NOUSER"); break;
case Error.NOTINGAME: File::fprintf (f, "NOTINGAME"); break;
+ case Error.NOTPLAYING: File::fprintf (f, "NOTPLAYING"); break;
case Error.NOTBIDDING: File::fprintf (f, "NOTBIDDING"); break;
case Error.NOTLOWER: File::fprintf (f, "NOTLOWER"); break;
case Error.NOBID: File::fprintf (f, "NOBID"); break;
More information about the Commit
mailing list