[Commit] grrobot/src grr_board_view.c,1.8,1.9 grrobot.c,1.8,1.9

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


Committed by: cworth

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

Modified Files:
	grr_board_view.c grrobot.c 
Log Message:
Added support for RR_NOTICE_GAMEOVER.
Tracked some librr changes

Index: grr_board_view.c
===================================================================
RCS file: /local/src/CVS/grrobot/src/grr_board_view.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- grr_board_view.c	25 Jun 2003 10:52:59 -0000	1.8
+++ grr_board_view.c	26 Jun 2003 01:19:40 -0000	1.9
@@ -550,8 +550,7 @@
 			       GdkEventButton *event)
 {
     grr_board_view_t *view;
-    const char *dir;
-    const char *robot;
+    rr_direction_t dir;
     int x, y;
     int robot_x, robot_y;
     int dx, dy;
@@ -577,41 +576,17 @@
 
     if (abs(dx) > abs(dy))
 	if (x > robot_x)
-	    dir = "east";
+	    dir = RR_DIRECTION_EAST;
 	else
-	    dir = "west";
+	    dir = RR_DIRECTION_WEST;
     else
 	if (y > robot_y)
-	    dir = "south";
+	    dir = RR_DIRECTION_SOUTH;
 	else
-	    dir = "north";
-    
-    switch (view->drag_robot) {
-    case RR_ROBOT_BLUE:
-	robot = "blue";
-	break;
-    case RR_ROBOT_GREEN:
-	robot = "green";
-	break;
-    case RR_ROBOT_RED:
-	robot = "RED";
-	break;
-    case RR_ROBOT_YELLOW:
-	robot = "YELLOW";
-	break;
-    default:
-	return FALSE;
-    }
+	    dir = RR_DIRECTION_NORTH;
     
-    if (view->client) {
-	char *move_str;
-	
-	grr_sprintf_alloc (&move_str, "%s %s", robot, dir);
-	if (move_str == NULL)
-	    return FALSE;
-	rr_client_move (view->client, move_str);
-	free (move_str);
-    }
+    if (view->client)
+	rr_client_move (view->client, view->drag_robot, dir);
 
   return FALSE;
 }

Index: grrobot.c
===================================================================
RCS file: /local/src/CVS/grrobot/src/grrobot.c,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -d -r1.8 -r1.9
--- grrobot.c	25 Jun 2003 10:52:59 -0000	1.8
+++ grrobot.c	26 Jun 2003 01:19:40 -0000	1.9
@@ -220,6 +220,22 @@
 	    grr_game_printf (game, "\nGame state changed to: %s.",
 			     rr_gamestate_str (notice->u.gamestate));
 	    break;
+	case RR_NOTICE_TURN:
+	    grr_game_print (game, "\nNew round!");
+	    rr_board_set_goal_target (board, notice->u.target);
+	    gtk_widget_queue_draw (GTK_WIDGET (game->window));
+	    break;
+	case RR_NOTICE_GAMEOVER:
+	{
+	    char *diagram;
+	    grr_game_printf (game, "\nGame over. New game will begin now.");
+	    /* XXX: Can drop this when the BOARD NOTICE is added in the server */
+	    rr_client_show (game->client, &diagram);
+	    rr_board_parse (board, diagram);
+	    free (diagram);
+	    gtk_widget_queue_draw (GTK_WIDGET (game->window));
+	}
+	break;
 	case RR_NOTICE_JOIN:
 	    grr_game_printf (game, "\nUser %s has joined the game.",
 			     notice->u.string);
@@ -289,11 +305,6 @@
 	case RR_NOTICE_POSITION:
 	    rr_board_position_robot (board, notice->u.position.robot,
 				     notice->u.position.x, notice->u.position.y);
-	    gtk_widget_queue_draw (GTK_WIDGET (game->window));
-	    break;
-	case RR_NOTICE_TURN:
-	    grr_game_print (game, "\nNew round!");
-	    rr_board_set_goal_target (board, notice->u.target);
 	    gtk_widget_queue_draw (GTK_WIDGET (game->window));
 	    break;
 	}




More information about the Commit mailing list