Mercurial > molko
changeset 73:b49d8475a611
molko: avoid double painter_present call
author | David Demelier <markand@malikania.fr> |
---|---|
date | Fri, 31 Jan 2020 08:09:05 +0100 |
parents | 6203e1ac9b18 |
children | 4991bf5f2343 |
files | src/adventure/main.c src/core/game.c src/core/map_state.c src/core/script.c |
diffstat | 4 files changed, 8 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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); }
--- 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
--- 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,