From 30ea38a28f3abd05c32093c29c67b418c6904235 Mon Sep 17 00:00:00 2001 From: Vito Caputo Date: Thu, 27 May 2021 10:34:29 -0700 Subject: play: always return 0 from play_ticks_reset() Callers manually resetting timers often need to assign the reset ticks count somewhere, this makes it so they can just assign it directly from the reset call. Otherwise this can be ignored... --- src/play.c | 11 ++++++++--- src/play.h | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src') diff --git a/src/play.c b/src/play.c index 22ae6d9..c15a26f 100644 --- a/src/play.c +++ b/src/play.c @@ -238,8 +238,11 @@ unsigned play_ticks(play_t *play, play_ticks_t timer) } -/* reset ticks counter to begin counting from now */ -void play_ticks_reset(play_t *play, play_ticks_t timer) +/* reset ticks counter to begin counting from now + * always returns 0 for convenience/ergonomic reasons to use as + * a new post-reset ticks value. + */ +unsigned play_ticks_reset(play_t *play, play_ticks_t timer) { assert(play); assert(timer < PLAY_TICKS_CNT); @@ -247,6 +250,8 @@ void play_ticks_reset(play_t *play, play_ticks_t timer) ticks_active(play); play->tick_offsets[timer] = SDL_GetTicks(); + + return 0; } @@ -272,7 +277,7 @@ int play_ticks_elapsed(play_t *play, play_ticks_t timer, unsigned duration) assert(timer < PLAY_TICKS_CNT); if (play_ticks(play, timer) >= duration) { - play_ticks_reset(play, timer); + (void) play_ticks_reset(play, timer); return 1; } diff --git a/src/play.h b/src/play.h index 73d3815..98581c8 100644 --- a/src/play.h +++ b/src/play.h @@ -65,7 +65,7 @@ void play_music_resume(play_t *play); void play_context_enter(play_t *play, int context); void * play_context(play_t *play, int context); unsigned play_ticks(play_t *play, play_ticks_t timer); -void play_ticks_reset(play_t *play, play_ticks_t timer); +unsigned play_ticks_reset(play_t *play, play_ticks_t timer); void play_ticks_pause(play_t *play); int play_ticks_elapsed(play_t *play, play_ticks_t timer, unsigned duration); void play_quit(play_t *play); -- cgit v1.2.3