# HG changeset patch # User David Demelier # Date 1580454545 -3600 # Node ID b49d8475a61105d0a9b1bdc26d2d17b12e0edc0c # Parent 6203e1ac9b18e97fa183b7a486b5773e764d0487 molko: avoid double painter_present call diff -r 6203e1ac9b18 -r b49d8475a611 src/adventure/main.c --- a/src/adventure/main.c Tue Jan 28 14:02:45 2020 +0100 +++ b/src/adventure/main.c Fri Jan 31 08:09:05 2020 +0100 @@ -128,8 +128,6 @@ game_update(elapsed); game_draw(); - painter_present(); - if ((elapsed = clock_elapsed(&clock)) < 20) delay(20 - elapsed); } diff -r 6203e1ac9b18 -r b49d8475a611 src/core/game.c --- a/src/core/game.c Tue Jan 28 14:02:45 2020 +0100 +++ b/src/core/game.c Fri Jan 31 08:09:05 2020 +0100 @@ -34,9 +34,9 @@ { static struct action null; - for (size_t i = 0; i < GAME_ACTIONS_MAX; ++i) - if (memcmp(&game.actions[i], &null, sizeof (struct action)) == 0) - return &game.actions[i]; + for (struct action *a = game.actions; a != &game.actions[GAME_ACTIONS_MAX]; ++a) + if (memcmp(a, &null, sizeof (struct action)) == 0) + return a; return NULL; } @@ -44,9 +44,7 @@ static void clear_actions(void) { - for (size_t i = 0; i < GAME_ACTIONS_MAX; ++i) { - struct action *a = &game.actions[i]; - + for (struct action *a = game.actions; a != &game.actions[GAME_ACTIONS_MAX]; ++a) { /* These actions are removed on state change. */ if (a->flags & ACTION_AUTO_LEAVE) { if (a->finish) @@ -60,9 +58,9 @@ static void handle_actions(const union event *event) { - for (size_t i = 0; i < GAME_ACTIONS_MAX; ++i) - if (game.actions[i].handle) - game.actions[i].handle(&game.actions[i], event); + for (struct action *a = game.actions; a != &game.actions[GAME_ACTIONS_MAX]; ++a) + if (a->handle) + a->handle(a, event); } static void diff -r 6203e1ac9b18 -r b49d8475a611 src/core/map_state.c --- a/src/core/map_state.c Tue Jan 28 14:02:45 2020 +0100 +++ b/src/core/map_state.c Fri Jan 31 08:09:05 2020 +0100 @@ -319,8 +319,6 @@ static void draw(void) { - painter_set_color(0x000000ff); - painter_clear(); map_draw(&map_state_data.map.map, map_state_data.view.x, map_state_data.view.y); walksprite_draw( &cache.player.ws, diff -r 6203e1ac9b18 -r b49d8475a611 src/core/script.c --- a/src/core/script.c Tue Jan 28 14:02:45 2020 +0100 +++ b/src/core/script.c Fri Jan 31 08:09:05 2020 +0100 @@ -94,7 +94,7 @@ assert(s); assert(ev); - if (s->iter) + if (s->iter && s->iter->action.handle) s->iter->action.handle(&s->iter->action, ev); }