Navigation Menu

Skip to content

Commit

Permalink
Fill the savegame with all levels from a levelset on start, so the Co…
Browse files Browse the repository at this point in the history
…ntribMenu shows the correct number
  • Loading branch information
Grumbel committed Aug 14, 2014
1 parent 1b5749c commit 55ee761
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/supertux/levelset_screen.cpp
Expand Up @@ -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"
Expand All @@ -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;
Expand Down
4 changes: 3 additions & 1 deletion src/supertux/savegame.cpp
Expand Up @@ -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)
{
Expand Down

0 comments on commit 55ee761

Please sign in to comment.