[Commit] librr/src rr.h,1.12,1.13 rr_client.c,1.7,1.8 rr_notice.c,1.2,1.3 rrint.h,1.7,1.8

Carl Worth commit at keithp.com
Wed Jun 25 19:18:37 PDT 2003


Committed by: cworth

Update of /local/src/CVS/librr/src
In directory home.keithp.com:/tmp/cvs-serv26744/src

Modified Files:
	rr.h rr_client.c rr_notice.c rrint.h 
Log Message:
Fixed support for GAMEOVER request.
Fixed datatypes for rr_client_bid and rr_client_move.
Added rr_client_nobid and rr_client_pass.

Index: rr.h
===================================================================
RCS file: /local/src/CVS/librr/src/rr.h,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -d -r1.12 -r1.13
--- rr.h	25 Jun 2003 10:48:02 -0000	1.12
+++ rr.h	26 Jun 2003 01:18:34 -0000	1.13
@@ -155,14 +155,16 @@
 } rr_direction_t;
 
 typedef enum {
-    /* global game notices */
+    /* global notices */
     RR_NOTICE_USER,
     RR_NOTICE_QUIT,
     RR_NOTICE_GAME,
     RR_NOTICE_DISPOSE,
     RR_NOTICE_MESSAGE,
+    /* game notices */
     RR_NOTICE_GAMESTATE,
     RR_NOTICE_TURN,
+    RR_NOTICE_GAMEOVER,
     RR_NOTICE_JOIN,
     RR_NOTICE_WATCH,
     RR_NOTICE_PART,
@@ -196,7 +198,7 @@
 	
 	/*
 	 * USER,  QUIT, JOIN, WATCH, PART, REVOKE, 
-	 * ABANDON, NOBID, GAME, DISPOSE
+	 * ABANDON, NOBID, GAME, DISPOSE, GAMEOVER
 	 */
 	char *string;
 	
@@ -422,7 +424,7 @@
 rr_client_part (rr_client_t *client);
 
 rr_status_t
-rr_client_bid (rr_client_t *client, const char *bid);
+rr_client_bid (rr_client_t *client, int bid);
 
 rr_status_t
 rr_client_revoke (rr_client_t *client);
@@ -431,13 +433,19 @@
 rr_client_abandon (rr_client_t *client);
 
 rr_status_t
-rr_client_move (rr_client_t *client, const char *move);
+rr_client_nobid (rr_client_t *client);
+
+rr_status_t
+rr_client_move (rr_client_t *client, rr_robot_t robot, rr_direction_t dir);
 
 rr_status_t
 rr_client_undo (rr_client_t *client);
 
 rr_status_t
 rr_client_reset (rr_client_t *client);
+
+rr_status_t
+rr_client_pass (rr_client_t *client);
 
 void
 rr_client_destroy (rr_client_t *client);

Index: rr_client.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr_client.c,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rr_client.c	19 Jun 2003 11:39:15 -0000	1.7
+++ rr_client.c	26 Jun 2003 01:18:34 -0000	1.8
@@ -84,9 +84,11 @@
     { RR_CMD_BID,	"BID"},
     { RR_CMD_REVOKE,	"REVOKE"},
     { RR_CMD_ABANDON,	"ABANDON"},
+    { RR_CMD_NOBID,	"NOBID" },
     { RR_CMD_MOVE,	"MOVE"},
     { RR_CMD_UNDO,	"UNDO"},
     { RR_CMD_RESET,	"RESET"},
+    { RR_CMD_PASS,	"PASS" },
     { RR_CMD_ERROR,	"ERROR"}
 };
 
@@ -526,9 +528,20 @@
 }
 
 rr_status_t
-rr_client_bid (rr_client_t *client, const char *bid)
+rr_client_bid (rr_client_t *client, const int bid)
 {
-    return _rr_client_cmd_request (client, RR_CMD_BID, bid, NULL);
+    rr_status_t status;
+    char *bid_str;
+
+    _rr_string_sprintf_alloc (&bid_str, "%d", bid);
+    if (bid_str == NULL)
+	return RR_STATUS_NO_MEMORY;
+
+    status = _rr_client_cmd_request (client, RR_CMD_BID, bid_str, NULL);
+
+    free (bid_str);
+
+    return status;
 }
 
 rr_status_t
@@ -544,9 +557,28 @@
 }
 
 rr_status_t
-rr_client_move (rr_client_t *client, const char *move)
+rr_client_nobid (rr_client_t *client)
 {
-    return _rr_client_cmd_request (client, RR_CMD_MOVE, move, NULL);
+    return _rr_client_cmd_request (client, RR_CMD_NOBID, NULL, NULL);
+}
+
+rr_status_t
+rr_client_move (rr_client_t *client, rr_robot_t robot, rr_direction_t dir)
+{
+    rr_status_t status;
+    char *move_str;
+
+    _rr_string_sprintf_alloc (&move_str, "%s %s",
+			      rr_robot_str (robot),
+			      rr_direction_str (dir));
+    if (move_str == NULL)
+	return RR_STATUS_NO_MEMORY;
+
+    status = _rr_client_cmd_request (client, RR_CMD_MOVE, move_str, NULL);
+
+    free (move_str);
+
+    return status;
 }
 
 rr_status_t
@@ -559,6 +591,12 @@
 rr_client_reset (rr_client_t *client)
 {
     return _rr_client_cmd_request (client, RR_CMD_RESET, NULL, NULL);
+}
+
+rr_status_t
+rr_client_pass (rr_client_t *client)
+{
+    return _rr_client_cmd_request (client, RR_CMD_PASS, NULL, NULL);
 }
 
 static rr_status_t

Index: rr_notice.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr_notice.c,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- rr_notice.c	25 Jun 2003 19:14:00 -0000	1.2
+++ rr_notice.c	26 Jun 2003 01:18:34 -0000	1.3
@@ -165,15 +165,16 @@
     rr_notice_type_t	type;
     rr_notice_t		*(*func) (rr_notice_type_t, char **);
 } notices[] = {
-    /* global game notices */
+    /* global notices */
     { "USER",		RR_NOTICE_USER, 	_rr_notice_string },
     { "QUIT",		RR_NOTICE_QUIT, 	_rr_notice_void },
     { "GAME",		RR_NOTICE_GAME, 	_rr_notice_string },
     { "DISPOSE",	RR_NOTICE_DISPOSE,	_rr_notice_string },
     { "MESSAGE",	RR_NOTICE_MESSAGE,	_rr_notice_message },
+    /* game notices */
     { "GAMESTATE",	RR_NOTICE_GAMESTATE,	_rr_notice_gamestate },
     { "TURN",		RR_NOTICE_TURN,		_rr_notice_target },
-    { "GAME",		RR_NOTICE_GAME,		_rr_notice_string },
+    { "GAMEOVER",	RR_NOTICE_GAMEOVER,	_rr_notice_void },
     { "JOIN",		RR_NOTICE_JOIN,		_rr_notice_string },
     { "WATCH",		RR_NOTICE_WATCH,	_rr_notice_string },
     { "PART",		RR_NOTICE_PART,		_rr_notice_string },
@@ -204,6 +205,8 @@
     for (i = 0; i < NUM_NOTICES; i++)
 	if (!strcmp (words[0], notices[i].name))
 	    return (*notices[i].func) (notices[i].type, words);
+
+    fprintf (stderr, "ERROR: Unexpected NOTICE string: %s\n", words[0]);
 
     return NULL;
 }

Index: rrint.h
===================================================================
RCS file: /local/src/CVS/librr/src/rrint.h,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -d -r1.7 -r1.8
--- rrint.h	25 Jun 2003 10:48:02 -0000	1.7
+++ rrint.h	26 Jun 2003 01:18:34 -0000	1.8
@@ -95,10 +95,12 @@
     RR_CMD_BID,
     RR_CMD_REVOKE,
     RR_CMD_ABANDON,
+    RR_CMD_NOBID,
     /* solving commands */
     RR_CMD_MOVE,
     RR_CMD_UNDO,
     RR_CMD_RESET,
+    RR_CMD_PASS,
     RR_CMD_ERROR,
     RR_CMD_LAST
 } rr_cmd_t;




More information about the Commit mailing list