From: Ingo Ruhnke Date: Thu, 14 Aug 2014 03:19:46 +0000 (+0200) Subject: Fill the savegame with all levels from a levelset on start, so the ContribMenu shows... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=55ee761513b8dabfc26ed31bca634afabe368e11;p=supertux.git Fill the savegame with all levels from a levelset on start, so the ContribMenu shows the correct number --- diff --git a/src/supertux/levelset_screen.cpp b/src/supertux/levelset_screen.cpp index 0aec48ac9..9ce906ccf 100644 --- a/src/supertux/levelset_screen.cpp +++ b/src/supertux/levelset_screen.cpp @@ -18,6 +18,7 @@ #include "supertux/game_session.hpp" #include "supertux/globals.hpp" +#include "supertux/levelset.hpp" #include "supertux/savegame.hpp" #include "supertux/screen_fade.hpp" #include "supertux/screen_manager.hpp" @@ -31,6 +32,13 @@ LevelsetScreen::LevelsetScreen(const std::string& basedir, const std::string& le m_level_started(false), m_solved(false) { + Levelset levelset(basedir); + for(int i = 0; i < levelset.get_num_levels(); ++i) + { + std::string lev = levelset.get_level_filename(i); + m_savegame.set_levelset_state(m_basedir, lev, false); + } + LevelsetState state = m_savegame.get_levelset_state(basedir); LevelState level_state = state.get_level_state(level_filename); m_solved = level_state.solved; diff --git a/src/supertux/savegame.cpp b/src/supertux/savegame.cpp index c7a7330fc..4119a2dd4 100644 --- a/src/supertux/savegame.cpp +++ b/src/supertux/savegame.cpp @@ -466,7 +466,9 @@ Savegame::set_levelset_state(const std::string& basedir, get_or_create_table_entry(vm, "levels"); get_or_create_table_entry(vm, level_filename); - scripting::store_bool(vm, "solved", solved); + bool old_solved = false; + scripting::get_bool(vm, "solved", old_solved); + scripting::store_bool(vm, "solved", solved || old_solved); } catch(const std::exception& err) {