From 88891f52b571983a2f7407a39bed6eb6269af708 Mon Sep 17 00:00:00 2001 From: =?utf8?q?R=C3=A9mi=20Verschelde?= Date: Tue, 13 Dec 2016 19:12:36 +0100 Subject: [PATCH] Save progress upon level completion Fixes #47. Also made Folder::getUserDataPath() inline, hope that's good style. --- Source/GameInitDispose.cpp | 4 ++-- Source/GameTick.cpp | 1 + Source/Utils/Folders.cpp | 5 ----- Source/Utils/Folders.hpp | 9 ++++++--- 4 files changed, 9 insertions(+), 10 deletions(-) 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); -- 2.39.2