From c67c5a6fb17d231539ba8722426bd05510880938 Mon Sep 17 00:00:00 2001 From: unitraxx Date: Thu, 5 Sep 2013 23:20:39 +0000 Subject: [PATCH] Achievements progress now actually gets saved.. how cool is that? git-svn-id: svn+ssh://svn.code.sf.net/p/supertuxkart/code/main/branches/uni@13634 178a84e3-b1eb-0310-8ba1-8eac791a3b58 --- src/achievements/achievement.cpp | 10 ++++++---- src/achievements/achievement_info.hpp | 1 - src/achievements/achievements_manager.cpp | 8 ++++++-- src/main.cpp | 2 +- 4 files changed, 13 insertions(+), 8 deletions(-) diff --git a/src/achievements/achievement.cpp b/src/achievements/achievement.cpp index 49105f099..580084715 100644 --- a/src/achievements/achievement.cpp +++ b/src/achievements/achievement.cpp @@ -75,6 +75,8 @@ void Achievement::check() SingleAchievement::SingleAchievement(const AchievementInfo * info) : Achievement(info) { + m_progress = 0; + m_achieved = false; } // ============================================================================ @@ -92,7 +94,7 @@ void SingleAchievement::load(XMLNode * input) // ============================================================================ void SingleAchievement::save(std::ofstream & out) { - out << "\n"; @@ -142,12 +144,12 @@ void MapAchievement::load(XMLNode * input) // ============================================================================ void MapAchievement::save(std::ofstream & out) { - out << "\n"; + out << " \n"; std::map::iterator iter; for ( iter = m_progress_map.begin(); iter != m_progress_map.end(); ++iter ) { - out << " first.c_str() << "\" value=\"" << StringUtils::toString(iter->second) << "\"/>\n"; + out << " first.c_str() << "\" value=\"" << StringUtils::toString(iter->second) << "\"/>\n"; } - out << "\n"; + out << " \n"; } // save // ============================================================================ diff --git a/src/achievements/achievement_info.hpp b/src/achievements/achievement_info.hpp index f52a45039..11a936adc 100644 --- a/src/achievements/achievement_info.hpp +++ b/src/achievements/achievement_info.hpp @@ -77,7 +77,6 @@ public: virtual ~MapAchievementInfo () {}; int getGoalValue (const std::string & key) { return m_goal_values[key];} virtual bool checkCompletion (Achievement * achievement) const; - virtual Achievement::AchievementType getType() const { return Achievement::AT_MAP; }; }; // class MapAchievementInfo diff --git a/src/achievements/achievements_manager.cpp b/src/achievements/achievements_manager.cpp index 50cb1a871..ce914a70e 100644 --- a/src/achievements/achievements_manager.cpp +++ b/src/achievements/achievements_manager.cpp @@ -152,14 +152,18 @@ void AchievementsManager::createSlotsIfNeeded() } } - if(something_changed) save(); + if(something_changed){ + Log::warn("AchievementsManager::save", + "errueeeur"); + save(); + } } // UnlockManager::createSlotsIfNeeded // ============================================================================ void AchievementsManager::save() { - std::string filename = file_manager->getConfigFile("challenges.xml"); + std::string filename = file_manager->getConfigFile("achievements.xml"); std::ofstream achievements_file(filename.c_str(), std::ios::out); diff --git a/src/main.cpp b/src/main.cpp index bee57504e..731705985 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -1367,7 +1367,6 @@ int main(int argc, char *argv[] ) file_manager->getGUIDir() + "options_video.png") ); kart_properties_manager -> loadAllKarts (); unlock_manager = new UnlockManager(); - AchievementsManager::get(); //m_tutorial_manager = new TutorialManager(); GUIEngine::addLoadingIcon( irr_driver->getTexture( file_manager->getTextureFile("gui_lock.png")) ); @@ -1524,6 +1523,7 @@ int main(int argc, char *argv[] ) // Go straight to the race StateManager::get()->enterGameState(); } + AchievementsManager::get(); // If an important news message exists it is shown in a popup dialog.