X-Git-Url: https://git.cworth.org/git?a=blobdiff_plain;f=src%2Fgrrobot.c;fp=src%2Fgrrobot.c;h=b27fd5054a02b4ea7d129bfe00822f0a7d32c335;hb=e27bd3ce66f33bb5d60be05a8ffae485f1f1b584;hp=a9a9d1e2a00a33e874e488ec6888410824cfdca4;hpb=f1cf379f7a0932549fde7ca0a2b86d05fcd7af62;p=grrobot diff --git a/src/grrobot.c b/src/grrobot.c index a9a9d1e..b27fd50 100644 --- a/src/grrobot.c +++ b/src/grrobot.c @@ -1,4 +1,4 @@ -/* grrobot - Ricochet Robot using GTK+ and Xr +/* grrobot - Ricochet Robot using GTK+, libxsvg, and Cairo * * Copyright © 2003 Carl Worth * @@ -106,6 +106,8 @@ main (int argc, char **argv) } game.client = NULL; } else { + GPollFD *poll_fd; + game.client = rr_client_create (args.host, args.port, args.user); if (game.client == NULL) { fprintf (stderr, "Failed connecting to %s:%s as %s\n", @@ -131,6 +133,11 @@ main (int argc, char **argv) game.last_move_robot = RR_ROBOT_NONE; source = grr_game_notices_source_new (&game); + poll_fd = g_new (GPollFD, 1); + poll_fd->fd = rr_client_fd (game.client); + poll_fd->events = G_IO_IN; + g_source_add_poll (source, poll_fd); + g_source_set_priority (source, GDK_PRIORITY_EVENTS); g_source_attach (source, NULL); g_source_unref (source); @@ -332,7 +339,7 @@ grr_game_read_notices (grr_game_t *game) break; case RR_NOTICE_ACTIVE: grr_game_printf (game, "\nUser %s now active to demonstrate solution in %d moves.", - notice->u.bid.username, + notice->u.bid.username, notice->u.bid.number); break; case RR_NOTICE_TIMER: @@ -340,10 +347,16 @@ grr_game_read_notices (grr_game_t *game) notice->u.number); break; case RR_NOTICE_POSITION: + { + int x, y; + rr_board_find_robot (board, notice->u.position.robot, &x, &y); rr_board_add_robot (board, notice->u.position.robot, notice->u.position.x, notice->u.position.y); - gtk_widget_queue_draw (GTK_WIDGET (game->window)); - break; + grr_board_view_mark_damage (game->board_view, x, y); + grr_board_view_mark_damage (game->board_view, + notice->u.position.x, notice->u.position.y); + } + break; default: fprintf (stderr, "Unknown notice: %d\n", notice->type); break;