summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/game.c11
-rw-r--r--src/level.c6
-rw-r--r--src/level.h2
3 files changed, 18 insertions, 1 deletions
diff --git a/src/game.c b/src/game.c
index a94c401..c69a1b7 100644
--- a/src/game.c
+++ b/src/game.c
@@ -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_ */