[Commit] rrserver games.5c,1.22,1.23 server.5c,1.13,1.14
Keith Packard
commit at keithp.com
Sat Jun 14 01:00:43 PDT 2003
Committed by: keithp
Update of /local/src/CVS/rrserver
In directory home.keithp.com:/tmp/cvs-serv18214
Modified Files:
games.5c server.5c
Log Message:
Track robot positions at done and POSITION on TURN
Index: games.5c
===================================================================
RCS file: /local/src/CVS/rrserver/games.5c,v
retrieving revision 1.22
retrieving revision 1.23
diff -u -d -r1.22 -r1.23
--- games.5c 12 Jun 2003 17:59:16 -0000 1.22
+++ games.5c 14 Jun 2003 07:00:41 -0000 1.23
@@ -277,7 +277,12 @@
break;
case GameState.DONE:
g.active = ClientRef.none;
- g.next_board = (BoardOrNone.board) g.board;
+ g.done_robots = (ObjectLoc[4]) {
+ Boards::find_robot (&g.board, Color.Red),
+ Boards::find_robot (&g.board, Color.Yellow),
+ Boards::find_robot (&g.board, Color.Green),
+ Boards::find_robot (&g.board, Color.Blue)
+ };
break;
}
}
@@ -321,9 +326,18 @@
return;
}
- union switch (g.next_board) {
- case none: break;
- case board b: g.board = b; break;
+ Track::Loc loc = Track::new();
+ for (int i = 0; i < dim (g.done_robots); i++)
+ {
+ Color color = g.done_robots[i].object.robot.robot.color;
+ int x = g.done_robots[i].x;
+ int y = g.done_robots[i].y;
+ ObjectLoc now = Boards::find_robot (&g.board, color);
+ if (now.x != x || now.y != y)
+ {
+ Track::note (&loc, color, x, y);
+ Boards::position_robot (&g.board, color, x, y);
+ }
}
g.target = g.targets[0];
g.targets = (Target[dim(g.targets)-1]) { [i] = g.targets[i+1] };
@@ -340,6 +354,7 @@
}
iterate_client (&g, reset_client, true, false);
game_send (&g, "NOTICE TURN %C %S\n", g.target.color, g.target.shape);
+ game_send_loc (&g, &loc);
}
Target[*] random_targets () {
@@ -369,7 +384,7 @@
g.targets = random_targets ();
g.active = ClientRef.none;
g.timer_serial = 0;
- g.next_board = BoardOrNone.none;
+ g.done_robots = (ObjectLoc[0]) {};
next_target (&g);
}
Index: server.5c
===================================================================
RCS file: /local/src/CVS/rrserver/server.5c,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- server.5c 12 Jun 2003 17:59:16 -0000 1.13
+++ server.5c 14 Jun 2003 07:00:41 -0000 1.14
@@ -117,7 +117,7 @@
ClientRef active;
ObjectLoc[*] history;
int timer_serial;
- BoardOrNone next_board;
+ ObjectLoc[*] done_robots;
} Game;
public exception notreached ();
More information about the Commit
mailing list