diff options
author | P. J. McDermott <pj@pehjota.net> | 2021-03-24 10:42:25 (EDT) |
---|---|---|
committer | P. J. McDermott <pj@pehjota.net> | 2021-03-24 10:42:25 (EDT) |
commit | 2dc013c782ce461b68484a49bd0cd0d2e1e3e8c9 (patch) | |
tree | bdc9afa8e45b08d4c926ff4f311cfbee521be033 | |
parent | 51fe7e54a2c10457d3dd1380aca5bb9a6692ba2b (diff) | |
download | dodge-balls-2dc013c782ce461b68484a49bd0cd0d2e1e3e8c9.zip dodge-balls-2dc013c782ce461b68484a49bd0cd0d2e1e3e8c9.tar.gz dodge-balls-2dc013c782ce461b68484a49bd0cd0d2e1e3e8c9.tar.bz2 |
game: Play ALL the levels
-rw-r--r-- | src/game.c | 11 | ||||
-rw-r--r-- | src/level.c | 6 | ||||
-rw-r--r-- | src/level.h | 2 |
3 files changed, 18 insertions, 1 deletions
@@ -463,7 +463,16 @@ db_game_get_desc(struct db_game *game) int db_game_play(SDL_Renderer *renderer, struct db_game *game) { - return db_level_play(renderer, game->level_head); + struct db_level *level; + + for (level = game->level_head; level != NULL; + level = db_level_next(level)) { + if (db_level_play(renderer, level) != 0) { + return -1; + } + } + + return 0; } void diff --git a/src/level.c b/src/level.c index cc81b2f..aecec71 100644 --- a/src/level.c +++ b/src/level.c @@ -96,3 +96,9 @@ db_level_play(SDL_Renderer *renderer, struct db_level *level) return 0; } + +struct db_level * +db_level_next(struct db_level *level) +{ + return level->next; +} diff --git a/src/level.h b/src/level.h index 666af3c..0486edd 100644 --- a/src/level.h +++ b/src/level.h @@ -27,5 +27,7 @@ struct db_level; struct db_level *db_level_new(const char *game_id, const char *level_id, struct db_level *prev); int db_level_play(SDL_Renderer *renderer, struct db_level *level); +struct db_level *db_level_next(struct db_level *level) + __attribute__((__pure__)); #endif /* DB_LEVEL_H_ */ |