From: RĂ©mi Verschelde Date: Tue, 13 Dec 2016 18:12:36 +0000 (+0100) Subject: Save progress upon level completion X-Git-Url: https://git.jsancho.org/?a=commitdiff_plain;h=88891f52b571983a2f7407a39bed6eb6269af708;p=lugaru.git Save progress upon level completion Fixes #47. Also made Folder::getUserDataPath() inline, hope that's good style. --- diff --git a/Source/GameInitDispose.cpp b/Source/GameInitDispose.cpp index fefba87..a8d3ce8 100644 --- a/Source/GameInitDispose.cpp +++ b/Source/GameInitDispose.cpp @@ -83,7 +83,7 @@ void Dispose() Game::endgame = 0; } - Account::saveFile(Folders::getUserDataPath()+"/users"); + Account::saveFile(Folders::getUserSavePath()); //textures.clear(); @@ -458,7 +458,7 @@ void Game::InitGame() numchallengelevels = 14; - Account::loadFile(Folders::getUserDataPath()+"/users"); + Account::loadFile(Folders::getUserSavePath()); whichjointstartarray[0] = righthip; whichjointendarray[0] = rightfoot; diff --git a/Source/GameTick.cpp b/Source/GameTick.cpp index aff6c86..216a81c 100644 --- a/Source/GameTick.cpp +++ b/Source/GameTick.cpp @@ -6233,6 +6233,7 @@ void Game::TickOnceAfter() Account::active().winLevel(whichlevel, bonustotal - startbonustotal, leveltime); } won = 1; + Account::active().saveFile(Folders::getUserSavePath()); } } diff --git a/Source/Utils/Folders.cpp b/Source/Utils/Folders.cpp index 43b399e..8de69db 100644 --- a/Source/Utils/Folders.cpp +++ b/Source/Utils/Folders.cpp @@ -45,11 +45,6 @@ std::string Folders::getScreenshotDir() return screenshotDir; } -std::string Folders::getResourcePath(std::string filepath) -{ - return dataDir + '/' + filepath; -} - std::string Folders::getUserDataPath() { std::string userDataPath; diff --git a/Source/Utils/Folders.hpp b/Source/Utils/Folders.hpp index 52be0f0..9d52c49 100644 --- a/Source/Utils/Folders.hpp +++ b/Source/Utils/Folders.hpp @@ -47,9 +47,6 @@ public: /* Returns path to the screenshot directory. Creates it if needed. */ static std::string getScreenshotDir(); - /* Returns full path for a game resource */ - static std::string getResourcePath(std::string filepath); - /* Returns full path for user data */ static std::string getUserDataPath(); @@ -58,6 +55,12 @@ public: static FILE* openMandatoryFile(std::string filename, const char* mode); + /* Returns full path for a game resource */ + static inline std::string getResourcePath(std::string filepath) { return dataDir + '/' + filepath; } + + /* Returns full path for user progress save */ + static inline std::string getUserSavePath() { return getUserDataPath() + "/users"; } + private: static const char* getHomeDirectory(); static std::string getGenericDirectory(const char* ENVVAR, const std::string fallback);