[Commit] librr/src rr.h,1.7,1.8 rr_board.c,1.7,1.8
Keith Packard
commit at keithp.com
Thu Jun 12 16:56:49 PDT 2003
Committed by: keithp
Update of /local/src/CVS/librr/src
In directory home.keithp.com:/tmp/cvs-serv20091
Modified Files:
rr.h rr_board.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 22:56:46 -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 22:56:46 -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)
More information about the Commit
mailing list