[Commit] librr/src rr.h,1.7,1.8 rr_board.c,1.7,1.8 rr_client.c,1.4,1.5

Keith Packard commit at keithp.com
Thu Jun 12 15:25:13 PDT 2003


Committed by: keithp

Update of /local/src/CVS/librr/src
In directory evo:/local/src/librr/src

Modified Files:
	rr.h rr_board.c rr_client.c 
Log Message:
Add rr_board_position

Index: rr.h
===================================================================
RCS file: /local/src/CVS/librr/src/rr.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rr.h	12 Jun 2003 18:00:56 -0000	1.7
+++ rr.h	12 Jun 2003 19:25:10 -0000	1.8
@@ -289,12 +289,16 @@
 rr_status_t
 rr_board_move (rr_board_t *board, rr_robot_t robot, rr_direction_t dir);
 
-/* Possible errors: RR_STATUS_NOY_FOUND */
+/* Possible errors: RR_STATUS_NOT_FOUND */
 rr_status_t
 rr_board_undo (rr_board_t *board);
 
 rr_status_t
 rr_board_reset (rr_board_t *board);
+
+/* rr_board_position: Reposition a robot */
+rr_status_t
+rr_board_position (rr_board_t *board, rr_robot_t robot, int x, int y);
 
 /* rr_board_to_str:  Return a string containing a diagram of the board.
    

Index: rr_board.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr_board.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rr_board.c	12 Jun 2003 07:09:09 -0000	1.7
+++ rr_board.c	12 Jun 2003 19:25:10 -0000	1.8
@@ -384,6 +384,23 @@
     }
 }
 
+rr_status_t
+rr_board_position (rr_board_t *board, rr_robot_t robot, int x, int y)
+{
+    rr_status_t	status;
+    rr_cell_t	*ocell, *cell;
+    int		ox, oy;
+
+    status = rr_board_find_robot (board, robot, &ox, &oy);
+    if (status != RR_STATUS_SUCCESS)
+	return status;
+    ocell = _rr_board_get_cell_ptr (board, ox, oy);
+    cell = _rr_board_get_cell_ptr (board, x, y);
+    RR_CELL_REMOVE_ROBOT (*ocell);
+    RR_CELL_ADD_ROBOT (*cell, robot);
+    return RR_STATUS_SUCCESS;
+}
+		    
 static rr_status_t
 _rr_board_get_robot_char (rr_board_t *board, rr_cell_t cell,
 			  char *r)

Index: rr_client.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr_client.c,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rr_client.c	12 Jun 2003 18:00:56 -0000	1.4
+++ rr_client.c	12 Jun 2003 19:25:10 -0000	1.5
@@ -123,6 +123,8 @@
 {
     rr_status_t status;
 
+    client->ptr = client->end = 0;
+    client->notice_queue = 0;
     status = _rr_client_connect (client, host, port);
     if (status)
 	return status;




More information about the Commit mailing list