diff options
-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_ */ |