diff options
-rw-r--r-- | src/grobot.c | 20 | ||||
-rw-r--r-- | src/ui-arena.c | 20 |
2 files changed, 20 insertions, 20 deletions
diff --git a/src/grobot.c b/src/grobot.c index 3cacadc..73e12a0 100644 --- a/src/grobot.c +++ b/src/grobot.c @@ -347,11 +347,9 @@ void g_robot_turn(GRobot *robot, gint num_turns) } /* animate the robot */ - gdk_threads_enter(); ui_arena_move_robot(robot->ui, robot->x, robot->y, robot->x, robot->y, robot->dir, robot->energy, robot->score, robot->shields); - gdk_threads_leave(); robot->energy -= 2; @@ -443,13 +441,11 @@ gboolean g_robot_move(GRobot *robot, gint steps) break; } - gdk_threads_enter(); /* Animate/update the robot/arena/status regardless of whether the movement-attempt succeeded: */ ui_arena_move_robot(robot->ui, robot->x, robot->y, x_to, y_to, robot->dir, robot->energy, robot->score, robot->shields); - gdk_threads_leave(); if (robot->energy < 1 || robot->shields < 1) { @@ -488,11 +484,9 @@ gboolean g_robot_smell(GRobot *robot, gchar *str) g_signal_emit(robot, g_robot_signals[DEATH], 0); } - gdk_threads_enter(); ui_arena_robot_smell(robot->ui, robot->x, robot->y, robot->dir, robot->energy, robot->score, robot->shields, str); - gdk_threads_leave(); /* Smell for the thing */ @@ -555,10 +549,8 @@ gboolean g_robot_feel(GRobot *robot, gchar *str) x_to = robot->x + dx; y_to = robot->y + dy; - gdk_threads_enter(); ui_arena_robot_feel(robot->ui, robot->x, robot->y, robot->dir, x_to, y_to, robot->energy, robot->score, robot->shields, str); - gdk_threads_leave(); if (MAP_GET_OBJECT(robot->map, x_to, y_to) == BADDIE) { @@ -619,10 +611,8 @@ gboolean g_robot_look(GRobot *robot, gchar *str) x_to = robot->x + dx; y_to = robot->y + dy; - gdk_threads_enter(); ui_arena_robot_look(robot->ui, robot->x, robot->y, robot->dir, x_to, y_to, robot->energy, robot->score, robot->shields, str); - gdk_threads_leave(); while (MAP_GET_OBJECT(robot->map, x_to, y_to) == SPACE) { @@ -681,10 +671,8 @@ gboolean g_robot_grab(GRobot *robot) g_signal_emit(robot, g_robot_signals[DEATH], 0); } - gdk_threads_enter(); ui_arena_robot_grab(robot->ui, robot->x, robot->y, robot->dir, x_to, y_to, robot->energy, robot->score, robot->shields); - gdk_threads_leave(); /* Did we grab it? */ @@ -716,9 +704,7 @@ gboolean g_robot_grab(GRobot *robot) /* only successful grabs get here */ MAP_SET_OBJECT(robot->map, x_to, y_to, SPACE); - gdk_threads_enter(); ui_arena_add_thing(robot->ui, x_to, y_to, SPACE); - gdk_threads_leave(); return TRUE; } @@ -763,10 +749,8 @@ gboolean g_robot_zap(GRobot *robot) g_signal_emit(robot, g_robot_signals[DEATH], 0); } robot->shots++; - gdk_threads_enter(); ui_arena_robot_zap(robot->ui, robot->x, robot->y, robot->dir, x_to, y_to, robot->energy, robot->score, robot->shields); - gdk_threads_leave(); /* Did we destroy it? */ switch (MAP_GET_OBJECT(robot->map, x_to, y_to)) @@ -780,17 +764,13 @@ gboolean g_robot_zap(GRobot *robot) case BADDIE: case FOOD: case PRIZE: - gdk_threads_enter(); ui_arena_add_thing(robot->ui, x_to, y_to, SPACE); - gdk_threads_leave(); break; } /* only success gets here */ MAP_SET_OBJECT(robot->map, x_to, y_to, SPACE); - gdk_threads_enter(); ui_arena_add_thing(robot->ui, x_to, y_to, SPACE); - gdk_threads_leave(); return TRUE; } diff --git a/src/ui-arena.c b/src/ui-arena.c index 854d75d..e6ce836 100644 --- a/src/ui-arena.c +++ b/src/ui-arena.c @@ -305,6 +305,8 @@ void ui_arena_add_thing(UIArena *arena, gint x, gint y, gint thing) w_x = x * TILE_SIZE; w_y = y * TILE_SIZE; + gdk_threads_enter (); + switch (thing) { case SPACE: @@ -332,6 +334,8 @@ void ui_arena_add_thing(UIArena *arena, gint x, gint y, gint thing) gtk_widget_queue_draw_area(GTK_WIDGET(arena), 0, 0, arena->priv->width, arena->priv->height); + + gdk_threads_leave (); } void ui_arena_move_robot(UIArena *arena, gint from_x, gint from_y, @@ -345,6 +349,8 @@ void ui_arena_move_robot(UIArena *arena, gint from_x, gint from_y, g_assert(distance <= 1); + gdk_threads_enter (); + ui_arena_update_status(arena, "Robot moves..", NULL, energy, score, shields); @@ -359,6 +365,7 @@ void ui_arena_move_robot(UIArena *arena, gint from_x, gint from_y, gtk_widget_queue_draw_area(GTK_WIDGET(arena), 0, 0, arena->priv->width, arena->priv->height); + gdk_threads_leave (); return; } @@ -416,12 +423,15 @@ void ui_arena_move_robot(UIArena *arena, gint from_x, gint from_y, arena->priv->width, arena->priv->height); gdk_window_process_all_updates(); + gdk_threads_leave (); g_usleep(USLEEP_TIME / 16); + gdk_threads_enter (); if (!ok) break; } + gdk_threads_leave (); g_usleep(USLEEP_TIME); } @@ -429,9 +439,11 @@ void ui_arena_move_robot(UIArena *arena, gint from_x, gint from_y, void ui_arena_robot_smell(UIArena *arena, gint x, gint y, gint cdir, glong energy, glong score, glong shields, const gchar *thing) { + gdk_threads_enter (); /* If we want to change the pic, do it here */ ui_arena_update_status(arena, "Robot sniffs for %s...", thing, energy, score, shields); + gdk_threads_leave (); g_usleep(USLEEP_TIME); } @@ -439,8 +451,10 @@ void ui_arena_robot_smell(UIArena *arena, gint x, gint y, gint cdir, void ui_arena_robot_zap(UIArena *arena, gint x, gint y, gint cdir, gint x_to, gint y_to, glong energy, glong score, glong shields) { + gdk_threads_enter (); ui_arena_update_status(arena, "Robot fires his little gun...", NULL, energy, score, shields); + gdk_threads_leave (); g_usleep(USLEEP_TIME); } @@ -450,8 +464,10 @@ void ui_arena_robot_feel(UIArena *arena, gint x_to, gint y_to, glong energy, glong score, glong shields, const gchar *thing) { + gdk_threads_enter (); ui_arena_update_status(arena, "Robot feels for %s...", thing, energy, score, shields); + gdk_threads_leave (); g_usleep(USLEEP_TIME); } @@ -459,8 +475,10 @@ void ui_arena_robot_feel(UIArena *arena, void ui_arena_robot_grab(UIArena *arena, gint x, gint y, gint cdir, gint x_to, gint y_to, glong energy, glong score, glong shields) { + gdk_threads_enter (); ui_arena_update_status(arena, "Robot grabs...", NULL, energy, score, shields); + gdk_threads_leave (); g_usleep(USLEEP_TIME); } @@ -469,8 +487,10 @@ void ui_arena_robot_look(UIArena *arena, gint x, gint y, gint cdir, gint x_to, gint y_to, glong energy, glong score, glong shields, const gchar *thing) { + gdk_threads_enter (); ui_arena_update_status(arena, "Robot looks for %s...", thing, energy, score, shields); + gdk_threads_leave (); g_usleep(USLEEP_TIME); } |