]> git.jsancho.org Git - lugaru.git/commitdiff
Save progress upon level completion
authorRémi Verschelde <rverschelde@gmail.com>
Tue, 13 Dec 2016 18:12:36 +0000 (19:12 +0100)
committerRémi Verschelde <rverschelde@gmail.com>
Tue, 13 Dec 2016 18:12:36 +0000 (19:12 +0100)
Fixes #47.
Also made Folder::getUserDataPath() inline, hope that's good style.

Source/GameInitDispose.cpp
Source/GameTick.cpp
Source/Utils/Folders.cpp
Source/Utils/Folders.hpp

index fefba877857be0d8a1c4abc12158fcb1aa3ac623..a8d3ce82c93ceda305dbce7d70100694c00b1a6d 100644 (file)
@@ -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;
index aff6c86b7961f2e3521b8d99ff6fa55403ac612b..216a81c3fd11d1c25ab5879688d0bfb8dee851ef 100644 (file)
@@ -6233,6 +6233,7 @@ void Game::TickOnceAfter()
                     Account::active().winLevel(whichlevel, bonustotal - startbonustotal, leveltime);
                 }
                 won = 1;
+                Account::active().saveFile(Folders::getUserSavePath());
             }
         }
 
index 43b399e9a86334d3245fff8d8afd9ce944e973e3..8de69db5098383ec1cb47db41401ba38d2226da9 100644 (file)
@@ -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;
index 52be0f0d8b59d0b81042a6ef44308bfd3eb4e936..9d52c49291958df83401ed7ccd1496a9aab9af40 100644 (file)
@@ -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);