[Commit] librr/src Makefile.am,1.2,1.3 rr.c,1.3,1.4 rr.h,1.4,1.5
rr_board.c,1.5,1.6 rr_client.c,1.1,1.2 rrint.h,1.3,1.4
Carl Worth
commit at keithp.com
Wed Jun 11 17:26:17 PDT 2003
Committed by: cworth
Update of /local/src/CVS/librr/src
In directory home.keithp.com:/tmp/cvs-serv29547/src
Modified Files:
Makefile.am rr.c rr.h rr_board.c rr_client.c rrint.h
Log Message:
Fixed rr_cell representation
Index: Makefile.am
===================================================================
RCS file: /local/src/CVS/librr/src/Makefile.am,v
retrieving revision 1.2
retrieving revision 1.3
diff -u -d -r1.2 -r1.3
--- Makefile.am 5 Jun 2003 14:32:42 -0000 1.2
+++ Makefile.am 11 Jun 2003 23:26:14 -0000 1.3
@@ -6,7 +6,6 @@
rr.h \
rrint.h \
rr_board.c \
- rr_cell.c \
rr_client.c \
rr_history.c \
rr_string.c \
Index: rr.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr.c,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rr.c 5 Jun 2003 14:32:42 -0000 1.3
+++ rr.c 11 Jun 2003 23:26:14 -0000 1.4
@@ -163,7 +163,7 @@
target_shape = RR_TARGET_TRIANGLE;
break;
case RR_TARGET_SHAPE_CHAR_WHIRL:
- target_shape = RR_TARGET_WHIRL;
+ target_shape = RR_TARGET_SHAPE_WHIRL;
break;
case RR_TARGET_SHAPE_CHAR_NONE:
default:
@@ -206,7 +206,7 @@
return RR_TARGET_SHAPE_CHAR_SQUARE;
case RR_TARGET_TRIANGLE:
return RR_TARGET_SHAPE_CHAR_TRIANGLE;
- case RR_TARGET_WHIRL:
+ case RR_TARGET_SHAPE_WHIRL:
return RR_TARGET_SHAPE_CHAR_WHIRL;
case RR_TARGET_NONE:
default:
Index: rr.h
===================================================================
RCS file: /local/src/CVS/librr/src/rr.h,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -d -r1.4 -r1.5
--- rr.h 5 Jun 2003 14:32:42 -0000 1.4
+++ rr.h 11 Jun 2003 23:26:14 -0000 1.5
@@ -27,6 +27,7 @@
#ifndef LIBRR_H
#define LIBRR_H
+typedef int rr_cell_t;
typedef struct rr_board rr_board_t;
typedef struct rr_client rr_client_t;
@@ -67,7 +68,7 @@
} rr_status_t;
typedef enum {
- RR_ROBOT_NONE = 0x0,
+ RR_ROBOT_NONE = 0,
RR_ROBOT_BLUE = 0x1,
RR_ROBOT_GREEN = 0x2,
RR_ROBOT_RED = 0x4,
@@ -76,6 +77,7 @@
#define RR_ROBOT_ANY (RR_ROBOT_BLUE | RR_ROBOT_GREEN | RR_ROBOT_RED | RR_ROBOT_YELLOW)
typedef enum {
+ RR_WALL_NONE = 0,
RR_WALL_ABOVE = 0x10,
RR_WALL_LEFT = 0x20,
RR_WALL_RIGHT = 0x40,
@@ -84,15 +86,15 @@
#define RR_WALL_ANY (RR_WALL_ABOVE | RR_WALL_LEFT | RR_WALL_RIGHT | RR_WALL_BELOW)
typedef enum {
- RR_TARGET_SHAPE_NONE = 0,
- RR_TARGET_CIRCLE = 0x0100,
- RR_TARGET_OCTAGON = 0x0200,
- RR_TARGET_SQUARE = 0x0400,
- RR_TARGET_TRIANGLE= 0x0800,
- RR_TARGET_WHIRL = 0x1000,
+ RR_TARGET_SHAPE_NONE = 0,
+ RR_TARGET_CIRCLE = 0x0100,
+ RR_TARGET_OCTAGON = 0x0200,
+ RR_TARGET_SQUARE = 0x0400,
+ RR_TARGET_TRIANGLE = 0x0800,
+ RR_TARGET_SHAPE_WHIRL = 0x1000,
} rr_target_shape_t;
#define RR_TARGET_SHAPE_ANY (RR_TARGET_CIRCLE | RR_TARGET_OCTAGON \
- | RR_TARGET_SQUARE | RR_TARGET_TRIANGLE | RR_TARGET_WHIRL)
+ | RR_TARGET_SQUARE | RR_TARGET_TRIANGLE | RR_TARGET_SHAPE_WHIRL)
typedef enum {
RR_TARGET_COLOR_NONE = 0,
@@ -122,7 +124,8 @@
RR_TARGET_YELLOW_CIRCLE = RR_TARGET_YELLOW | RR_TARGET_CIRCLE,
RR_TARGET_YELLOW_OCTAGON = RR_TARGET_YELLOW | RR_TARGET_OCTAGON,
RR_TARGET_YELLOW_SQUARE = RR_TARGET_YELLOW | RR_TARGET_SQUARE,
- RR_TARGET_YELLOW_TRIANGLE = RR_TARGET_YELLOW | RR_TARGET_TRIANGLE
+ RR_TARGET_YELLOW_TRIANGLE = RR_TARGET_YELLOW | RR_TARGET_TRIANGLE,
+ RR_TARGET_WHIRL = RR_TARGET_MULTI | RR_TARGET_SHAPE_WHIRL
} rr_target_t;
#define RR_TARGET_ANY (RR_TARGET_SHAPE_ANY | RR_TARGET_COLOR_ANY)
@@ -152,6 +155,9 @@
rr_board_destroy (rr_board_t *board);
rr_status_t
+rr_board_get_size (rr_board_t *board, int *width, int *height);
+
+rr_status_t
rr_board_empty (rr_board_t *board);
rr_status_t
@@ -226,6 +232,34 @@
rr_status_t
rr_board_parse (rr_board_t *board, const char *str);
+rr_cell_t
+rr_board_get_cell (rr_board_t *board, int x, int y);
+
+#define RR_CELL_HAS_WALL(cell, wall) ((cell) & (wall))
+#define RR_CELL_GET_WALLS(cell) ((cell) & RR_WALL_ANY)
+#define RR_CELL_GET_ROBOT(cell) ((cell) & RR_ROBOT_ANY)
+#define RR_CELL_GET_TARGET(cell) ((cell) & RR_TARGET_ANY)
+
+/* rr_cell.c */
+
+int
+rr_cell_has_wall (rr_cell_t cell, rr_wall_t wall);
+
+rr_wall_t
+rr_cell_get_walls (rr_cell_t cell);
+
+int
+rr_cell_has_robot (rr_cell_t cell);
+
+rr_robot_t
+rr_cell_get_robot (rr_cell_t cell);
+
+int
+rr_cell_has_target (rr_cell_t cell);
+
+rr_target_t
+rr_cell_get_target (rr_cell_t cell);
+
/* rr_client.c */
rr_client_t *
@@ -243,16 +277,67 @@
rr_client_games (rr_client_t *client, char **games);
rr_status_t
+rr_client_message (rr_client_t *client, const char *text);
+
+rr_status_t
+rr_client_help (rr_client_t *client, char **help);
+
+rr_status_t
+rr_client_quit (rr_client_t *client);
+
+rr_status_t
+rr_client_players (rr_client_t *client, char **players);
+
+rr_status_t
+rr_client_watchers (rr_client_t *client, char **watchers);
+
+rr_status_t
+rr_client_gameinfo (rr_client_t *client, const char *game, char **info);
+
+rr_status_t
rr_client_new (rr_client_t *client, const char *game);
rr_status_t
rr_client_join (rr_client_t *client, const char *game);
rr_status_t
+rr_client_watch (rr_client_t *client, const char *game);
+
+rr_status_t
+rr_client_dispose (rr_client_t *client, const char *game);
+
+rr_status_t
+rr_client_userinfo (rr_client_t *client, const char *user, char **info);
+
+rr_status_t
rr_client_update_board (rr_client_t *client);
rr_status_t
rr_client_show (rr_client_t *client, char **diagram);
+
+rr_status_t
+rr_client_turn (rr_client_t *client);
+
+rr_status_t
+rr_client_part (rr_client_t *client);
+
+rr_status_t
+rr_client_bid (rr_client_t *client, const char *bid);
+
+rr_status_t
+rr_client_revoke (rr_client_t *client);
+
+rr_status_t
+rr_client_abandon (rr_client_t *client);
+
+rr_status_t
+rr_client_move (rr_client_t *client, const char *move);
+
+rr_status_t
+rr_client_undo (rr_client_t *client);
+
+rr_status_t
+rr_client_reset (rr_client_t *client);
void
rr_client_destroy (rr_client_t *client);
Index: rr_board.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr_board.c,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -d -r1.5 -r1.6
--- rr_board.c 5 Jun 2003 14:32:42 -0000 1.5
+++ rr_board.c 11 Jun 2003 23:26:14 -0000 1.6
@@ -28,11 +28,14 @@
#include "rrint.h"
+static rr_cell_t *
+_rr_board_get_cell_ptr (rr_board_t *board, int x, int y);
+
static rr_status_t
-_rr_board_get_robot_char (rr_board_t *board, rr_cell_t *cell, char *r);
+_rr_board_get_robot_char (rr_board_t *board, rr_cell_t cell, char *r);
static rr_status_t
-_rr_board_get_target_chars (rr_board_t *board, rr_cell_t *cell,
+_rr_board_get_target_chars (rr_board_t *board, rr_cell_t cell,
char *color, char *shape);
rr_board_t *
@@ -77,7 +80,6 @@
_rr_board_init (rr_board_t *board, int width, int height)
{
rr_status_t status;
- int j;
board->width = width;
board->height = height;
@@ -93,21 +95,10 @@
if (board->str == NULL)
return RR_STATUS_NO_MEMORY;
- board->cell = malloc (height * sizeof (rr_cell_t *));
+ board->cell = malloc (width * height * sizeof (rr_cell_t));
if (board->cell == NULL)
return RR_STATUS_NO_MEMORY;
- for (j=0; j < height; j++) {
- board->cell[j] = malloc (width * sizeof (rr_cell_t));
- if (board->cell[j] == NULL) {
- for ( ; j >= 0; j--) {
- free (board->cell[j]);
- board->cell[j] = NULL;
- }
- return RR_STATUS_NO_MEMORY;
- }
- }
-
rr_board_empty (board);
return RR_STATUS_SUCCESS;
@@ -116,18 +107,12 @@
void
_rr_board_fini (rr_board_t *board)
{
- int j;
-
free (board->str);
board->str = NULL;
_rr_history_fini (&board->history);
if (board->cell) {
- for (j=0; j < board->height; j++) {
- free (board->cell[j]);
- board->cell[j] = NULL;
- }
free (board->cell);
board->cell = NULL;
}
@@ -141,24 +126,49 @@
free (board);
}
+static rr_cell_t *
+_rr_board_get_cell_ptr (rr_board_t *board, int x, int y)
+{
+ return board->cell + board->width * y + x;
+}
+
+rr_cell_t
+rr_board_get_cell (rr_board_t *board, int x, int y)
+{
+ rr_cell_t *cell;
+
+ cell = _rr_board_get_cell_ptr (board, x, y);
+ return *cell;
+}
+
+rr_status_t
+rr_board_get_size (rr_board_t *board, int *width, int *height)
+{
+ *width = board->width;
+ *height = board->height;
+
+ return RR_STATUS_SUCCESS;
+}
+
rr_status_t
rr_board_empty (rr_board_t *board)
{
int i, j;
rr_cell_t *cell;
+ cell = board->cell;
for (j=0; j < board->height; j++) {
for (i=0; i < board->width; i++) {
- cell = &board->cell[j][i];
- _rr_cell_empty (cell);
+ RR_CELL_INIT(*cell);
if (j==0)
- _rr_cell_add_wall (cell, RR_WALL_ABOVE);
+ RR_CELL_ADD_WALL (*cell, RR_WALL_ABOVE);
if (i==0)
- _rr_cell_add_wall (cell, RR_WALL_LEFT);
+ RR_CELL_ADD_WALL (*cell, RR_WALL_LEFT);
if (j == board->height - 1)
- _rr_cell_add_wall (cell, RR_WALL_BELOW);
+ RR_CELL_ADD_WALL (*cell, RR_WALL_BELOW);
if (i == board->width - 1)
- _rr_cell_add_wall (cell, RR_WALL_RIGHT);
+ RR_CELL_ADD_WALL (*cell, RR_WALL_RIGHT);
+ cell++;
}
}
@@ -169,24 +179,29 @@
rr_board_add_wall (rr_board_t *board,
int x, int y, rr_wall_t wall)
{
- _rr_cell_add_wall (&board->cell[y][x], wall);
+ rr_cell_t *cell = _rr_board_get_cell_ptr (board, x, y);
+
+ RR_CELL_ADD_WALL (*cell, wall);
switch (wall) {
case RR_WALL_ABOVE:
if (y > 0)
- _rr_cell_add_wall (&board->cell[y-1][x], RR_WALL_BELOW);
+ RR_CELL_ADD_WALL (*(cell - board->width), RR_WALL_BELOW);
break;
case RR_WALL_LEFT:
if (x > 0)
- _rr_cell_add_wall (&board->cell[y][x-1], RR_WALL_RIGHT);
+ RR_CELL_ADD_WALL (*(cell-1), RR_WALL_RIGHT);
break;
case RR_WALL_RIGHT:
if (x < board->width - 1)
- _rr_cell_add_wall (&board->cell[y][x+1], RR_WALL_LEFT);
+ RR_CELL_ADD_WALL (*(cell+1), RR_WALL_LEFT);
break;
case RR_WALL_BELOW:
if (y < board->height - 1)
- _rr_cell_add_wall (&board->cell[y+1][x], RR_WALL_ABOVE);
+ RR_CELL_ADD_WALL (*(cell + board->width), RR_WALL_ABOVE);
+ break;
+ case RR_WALL_NONE:
+ default:
break;
}
@@ -197,12 +212,12 @@
rr_board_add_robot (rr_board_t *board, int x, int y,
rr_robot_t robot, int is_goal_robot)
{
- rr_cell_t *cell = &board->cell[y][x];
+ rr_cell_t *cell = _rr_board_get_cell_ptr (board, x, y);
- if (_rr_cell_has_robot (cell))
+ if (RR_CELL_GET_ROBOT (*cell))
return RR_STATUS_OCCUPIED;
- _rr_cell_add_robot (cell, robot);
+ RR_CELL_ADD_ROBOT (*cell, robot);
if (is_goal_robot)
board->goal_robot = robot;
@@ -214,12 +229,12 @@
rr_board_add_target (rr_board_t *board, int x, int y,
rr_target_t target, int is_goal_target)
{
- rr_cell_t *cell = &board->cell[y][x];
+ rr_cell_t *cell = _rr_board_get_cell_ptr (board, x, y);
- if (_rr_cell_has_target (cell))
+ if (RR_CELL_GET_TARGET (*cell))
return RR_STATUS_OCCUPIED;
- _rr_cell_add_target (cell, target);
+ RR_CELL_ADD_TARGET (*cell, target);
if (is_goal_target)
board->goal_target = target;
@@ -234,15 +249,15 @@
rr_cell_t *cell;
int i, j;
+ cell = board->cell;
for (j=0; j < board->height; j++) {
for (i=0; i < board->height; i++) {
- cell = &board->cell[j][i];
- if (_rr_cell_has_robot (cell)
- && _rr_cell_get_robot (cell) == robot) {
+ if (RR_CELL_GET_ROBOT (*cell) == robot) {
*x = i;
*y = j;
return RR_STATUS_SUCCESS;
}
+ cell++;
}
}
@@ -282,45 +297,47 @@
{
rr_status_t status;
int x, y;
- int dx, dy;
+ int delta;
+ rr_cell_t *cell;
rr_wall_t wall;
status = rr_board_find_robot (board, robot, &x, &y);
if (status)
return status;
+ cell = _rr_board_get_cell_ptr (board, x, y);
+
switch (dir) {
case RR_DIRECTION_RIGHT:
- dx = 1; dy = 0; wall = RR_WALL_RIGHT;
+ delta = 1; wall = RR_WALL_RIGHT;
break;
case RR_DIRECTION_UP:
- dx = 0; dy = -1; wall = RR_WALL_ABOVE;
+ delta = - board->width; wall = RR_WALL_ABOVE;
break;
case RR_DIRECTION_LEFT:
- dx = -1; dy = 0; wall = RR_WALL_LEFT;
+ delta = -1;; wall = RR_WALL_LEFT;
break;
case RR_DIRECTION_DOWN:
- dx = 0; dy = 1; wall = RR_WALL_BELOW;
+ delta = board->width; wall = RR_WALL_BELOW;
break;
default:
return RR_STATUS_NOT_DIRECTION;
}
- if (_rr_cell_has_wall (&board->cell[y][x], wall)
- || _rr_cell_has_robot (&board->cell[y+dy][x+dx]))
+ if (RR_CELL_HAS_WALL (*cell, wall)
+ || RR_CELL_GET_ROBOT (*(cell+delta)))
return RR_STATUS_BLOCKED;
status = _rr_history_push (&board->history, robot, x, y);
if (status)
return status;
- _rr_cell_remove_robot (&board->cell[y][x]);
- do {
- x += dx;
- y += dy;
- } while (_rr_cell_has_wall (&board->cell[y][x], wall) == 0
- && _rr_cell_has_robot (&board->cell[y+dy][x+dx]) == 0);
- _rr_cell_add_robot (&board->cell[y][x], robot);
+ RR_CELL_REMOVE_ROBOT (*cell);
+ do
+ cell += delta;
+ while (RR_CELL_HAS_WALL (*cell, wall) == 0
+ && RR_CELL_GET_ROBOT (*(cell+delta)) == RR_ROBOT_NONE);
+ RR_CELL_ADD_ROBOT (*cell, robot);
return RR_STATUS_SUCCESS;
}
@@ -330,6 +347,7 @@
{
rr_status_t status;
rr_robot_t robot;
+ rr_cell_t *cell;
int x, y;
int prev_x, prev_y;
@@ -342,8 +360,10 @@
if (status)
return status;
- _rr_cell_remove_robot (&board->cell[y][x]);
- _rr_cell_add_robot (&board->cell[prev_y][prev_x], robot);
+ cell = _rr_board_get_cell_ptr (board, x, y);
+ RR_CELL_REMOVE_ROBOT (*cell);
+ cell = _rr_board_get_cell_ptr (board, prev_x, prev_y);
+ RR_CELL_ADD_ROBOT (*cell, robot);
return RR_STATUS_SUCCESS;
}
@@ -365,12 +385,12 @@
}
static rr_status_t
-_rr_board_get_robot_char (rr_board_t *board, rr_cell_t *cell,
+_rr_board_get_robot_char (rr_board_t *board, rr_cell_t cell,
char *r)
{
rr_robot_t robot;
- robot = _rr_cell_get_robot (cell);
+ robot = RR_CELL_GET_ROBOT (cell);
*r = _rr_robot_to_char (robot);
if (robot == board->goal_robot)
@@ -380,12 +400,12 @@
}
static rr_status_t
-_rr_board_get_target_chars (rr_board_t *board, rr_cell_t *cell,
+_rr_board_get_target_chars (rr_board_t *board, rr_cell_t cell,
char *color, char *shape)
{
rr_target_t target;
- target = _rr_cell_get_target (cell);
+ target = RR_CELL_GET_TARGET (cell);
*color = _rr_target_color_to_char (target & RR_TARGET_COLOR_ANY);
*shape = _rr_target_shape_to_char (target & RR_TARGET_SHAPE_ANY);
@@ -412,28 +432,31 @@
#define S(x) s += sprintf(s, "%s", (x))
s = board->str;
+ cell = board->cell;
C ('\n');
for (j=0; j < board->height; j++) {
for (i=0; i < board->width; i++) {
C (' ');
- if (_rr_cell_has_wall (&board->cell[j][i], RR_WALL_ABOVE))
+ if (RR_CELL_HAS_WALL (*cell, RR_WALL_ABOVE))
S ("===");
else
S (" ");
+ cell++;
}
S(" \n");
+ cell -= board->width;
for (i=0; i < board->width; i++) {
- cell = &board->cell[j][i];
- if (_rr_cell_has_wall (cell, RR_WALL_LEFT))
+ if (RR_CELL_HAS_WALL (*cell, RR_WALL_LEFT))
C ('|');
else
C (' ');
- _rr_board_get_robot_char (board, cell, &robot);
+ _rr_board_get_robot_char (board, *cell, &robot);
C (robot);
- _rr_board_get_target_chars (board, cell, &color, &shape);
+ _rr_board_get_target_chars (board, *cell, &color, &shape);
C (color);
C (shape);
+ cell++;
}
S ("|\n");
}
Index: rr_client.c
===================================================================
RCS file: /local/src/CVS/librr/src/rr_client.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -d -r1.1 -r1.2
--- rr_client.c 5 Jun 2003 14:32:42 -0000 1.1
+++ rr_client.c 11 Jun 2003 23:26:14 -0000 1.2
@@ -71,9 +71,26 @@
static rr_command_t RR_CLIENT_COMMAND[] = {
{ RR_CMD_HELO, "HELO"},
{ RR_CMD_GAMES, "GAMES"},
+ { RR_CMD_MESSAGE, "MESSAGE"},
+ { RR_CMD_HELP, "HELP"},
+ { RR_CMD_QUIT, "QUIT"},
+ { RR_CMD_PLAYERS, "PLAYERS"},
+ { RR_CMD_WATCHERS, "WATCHERS"},
+ { RR_CMD_GAMEINFO, "GAMEINFO"},
{ RR_CMD_NEW, "NEW"},
{ RR_CMD_JOIN, "JOIN"},
+ { RR_CMD_WATCH, "WATCH"},
+ { RR_CMD_DISPOSE, "DISPOSE"},
+ { RR_CMD_USERINFO, "USERINFO"},
{ RR_CMD_SHOW, "SHOW"},
+ { RR_CMD_TURN, "TURN"},
+ { RR_CMD_PART, "PART"},
+ { RR_CMD_BID, "BID"},
+ { RR_CMD_REVOKE, "REVOKE"},
+ { RR_CMD_ABANDON, "ABANDON"},
+ { RR_CMD_MOVE, "MOVE"},
+ { RR_CMD_UNDO, "UNDO"},
+ { RR_CMD_RESET, "RESET"},
{ RR_CMD_ERROR, "ERROR"}
};
@@ -392,6 +409,42 @@
}
rr_status_t
+rr_client_message (rr_client_t *client, const char *text)
+{
+ return _rr_client_request (client, RR_CMD_MESSAGE, text, NULL);
+}
+
+rr_status_t
+rr_client_help (rr_client_t *client, char **help)
+{
+ return _rr_client_request (client, RR_CMD_HELP, NULL, help);
+}
+
+rr_status_t
+rr_client_quit (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_QUIT, NULL, NULL);
+}
+
+rr_status_t
+rr_client_players (rr_client_t *client, char **players)
+{
+ return _rr_client_request (client, RR_CMD_PLAYERS, NULL, players);
+}
+
+rr_status_t
+rr_client_watchers (rr_client_t *client, char **watchers)
+{
+ return _rr_client_request (client, RR_CMD_WATCHERS, NULL, watchers);
+}
+
+rr_status_t
+rr_client_gameinfo (rr_client_t *client, const char *game, char **info)
+{
+ return _rr_client_request (client, RR_CMD_GAMEINFO, game, info);
+}
+
+rr_status_t
rr_client_new (rr_client_t *client, const char *game)
{
return _rr_client_request (client, RR_CMD_NEW, game, NULL);
@@ -404,6 +457,24 @@
}
rr_status_t
+rr_client_watch (rr_client_t *client, const char *game)
+{
+ return _rr_client_request (client, RR_CMD_WATCH, game, NULL);
+}
+
+rr_status_t
+rr_client_dispose (rr_client_t *client, const char *game)
+{
+ return _rr_client_request (client, RR_CMD_DISPOSE, game, NULL);
+}
+
+rr_status_t
+rr_client_userinfo (rr_client_t *client, const char *user, char **info)
+{
+ return _rr_client_request (client, RR_CMD_USERINFO, user, info);
+}
+
+rr_status_t
rr_client_update_board (rr_client_t *client)
{
rr_status_t status;
@@ -432,6 +503,54 @@
return status;
return RR_STATUS_SUCCESS;
+}
+
+rr_status_t
+rr_client_turn (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_TURN, NULL, NULL);
+}
+
+rr_status_t
+rr_client_part (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_PART, NULL, NULL);
+}
+
+rr_status_t
+rr_client_bid (rr_client_t *client, const char *bid)
+{
+ return _rr_client_request (client, RR_CMD_BID, bid, NULL);
+}
+
+rr_status_t
+rr_client_revoke (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_REVOKE, NULL, NULL);
+}
+
+rr_status_t
+rr_client_abandon (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_ABANDON, NULL, NULL);
+}
+
+rr_status_t
+rr_client_move (rr_client_t *client, const char *move)
+{
+ return _rr_client_request (client, RR_CMD_MOVE, move, NULL);
+}
+
+rr_status_t
+rr_client_undo (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_UNDO, NULL, NULL);
+}
+
+rr_status_t
+rr_client_reset (rr_client_t *client)
+{
+ return _rr_client_request (client, RR_CMD_RESET, NULL, NULL);
}
static rr_status_t
Index: rrint.h
===================================================================
RCS file: /local/src/CVS/librr/src/rrint.h,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -d -r1.3 -r1.4
--- rrint.h 5 Jun 2003 14:32:42 -0000 1.3
+++ rrint.h 11 Jun 2003 23:26:14 -0000 1.4
@@ -36,7 +36,13 @@
#include "rr.h"
-typedef int rr_cell_t;
+#define RR_CELL_INIT(cell) ((cell) = 0)
+#define RR_CELL_ADD_ROBOT(cell, robot) ((cell) |= (robot))
+#define RR_CELL_REMOVE_ROBOT(cell) ((cell) &= ~RR_ROBOT_ANY)
+#define RR_CELL_ADD_TARGET(cell, target) ((cell) |= (target))
+#define RR_CELL_REMOVE_TARGET(cell) ((cell) &= ~RR_TARGET_ANY)
+#define RR_CELL_ADD_WALL(cell, wall) ((cell) |= (wall))
+#define RR_CELL_REMOVE_WALL(cell, wall) ((cell) &= ~(wall))
typedef struct rr_history {
/* XXX: NYI */
@@ -46,7 +52,7 @@
int width;
int height;
- rr_cell_t **cell;
+ rr_cell_t *cell;
rr_robot_t goal_robot;
rr_target_t goal_target;
@@ -58,11 +64,34 @@
/* NOTE: Changes to this enum must be reflecte in RR_CLIENT_COMMAND array in rr_client.c */
typedef enum {
+ /* global commands */
RR_CMD_HELO,
RR_CMD_GAMES,
+ RR_CMD_MESSAGE,
+ RR_CMD_HELP,
+ RR_CMD_QUIT,
+ /* game management */
+ RR_CMD_PLAYERS,
+ RR_CMD_WATCHERS,
+ RR_CMD_GAMEINFO,
RR_CMD_NEW,
RR_CMD_JOIN,
+ RR_CMD_WATCH,
+ RR_CMD_DISPOSE,
+ /* user information */
+ RR_CMD_USERINFO,
+ /* in-game commands */
RR_CMD_SHOW,
+ RR_CMD_TURN,
+ RR_CMD_PART,
+ /* bidding commands */
+ RR_CMD_BID,
+ RR_CMD_REVOKE,
+ RR_CMD_ABANDON,
+ /* solving commands */
+ RR_CMD_MOVE,
+ RR_CMD_UNDO,
+ RR_CMD_RESET,
RR_CMD_ERROR,
RR_CMD_LAST
} rr_cmd_t;
@@ -114,46 +143,6 @@
void
_rr_board_fini (rr_board_t *board);
-
-/* rr_cell.c */
-void
-_rr_cell_init (rr_cell_t *cell);
-
-void
-_rr_cell_empty (rr_cell_t *cell);
-
-void
-_rr_cell_add_robot (rr_cell_t *cell, rr_robot_t robot);
-
-void
-_rr_cell_remove_robot (rr_cell_t *cell);
-
-void
-_rr_cell_add_wall (rr_cell_t *cell, rr_wall_t wall);
-
-void
-_rr_cell_remove_wall (rr_cell_t *cell, rr_wall_t wall);
-
-void
-_rr_cell_add_target (rr_cell_t *cell, rr_target_t target);
-
-void
-_rr_cell_remove_target (rr_cell_t *cell);
-
-int
-_rr_cell_has_wall (rr_cell_t *cell, rr_wall_t wall);
-
-int
-_rr_cell_has_robot (rr_cell_t *cell);
-
-rr_robot_t
-_rr_cell_get_robot (rr_cell_t *cell);
-
-int
-_rr_cell_has_target (rr_cell_t *cell);
-
-rr_target_t
-_rr_cell_get_target (rr_cell_t *cell);
/* rr_history.c */
More information about the Commit
mailing list