commit e8475d0d
Also changed Stage clear saves
Changed files
diff --git a/source/code/main.cpp b/source/code/main.cpp
index 64ac92a..370a258 100644
--- a/source/code/main.cpp
+++ b/source/code/main.cpp
@@ -1536,7 +1536,6 @@ void changePuzzleLevels() {
theFileName[i]=0;
}
PuzzleSetName(theFileName);
- PuzzleSetSavePath(getPathToSaveFiles()+"/"+PuzzleGetName()+".save");
}
}
@@ -1718,8 +1717,6 @@ int main(int argc, char* argv[]) {
theBallManager = BallManager();
theExplosionManager = ExplosionManager();
- stageClearSavePath = getStageClearSavePath();
- PuzzleSetSavePath(getPuzzleSetSavePath());
PuzzleSetName("puzzle.levels");
//Init SDL
diff --git a/source/code/os.cpp b/source/code/os.cpp
index 6c37e68..abe08a1 100644
--- a/source/code/os.cpp
+++ b/source/code/os.cpp
@@ -115,18 +115,6 @@ void setPathToSaveFiles(const std::string& path) {
overrideSavePath = path;
}
-std::string getStageClearSavePath() {
- std::string ret;
-#if defined(__unix__)
- ret = getHome()+"/.gamesaves/blockattack/stageClear.SCsave";
-#elif defined(_WIN32)
- ret = getMyDocumentsPath()+"/My Games/blockattack/stageClear.SCsave";
-#else
- ret = "stageClear.SCsave";
-#endif
- return ret;
-}
-
std::string getPuzzleSetSavePath() {
std::string ret;
#if defined(__unix__)
diff --git a/source/code/os.hpp b/source/code/os.hpp
index c78336f..e2cd929 100644
--- a/source/code/os.hpp
+++ b/source/code/os.hpp
@@ -34,7 +34,6 @@ std::string getMyDocumentsPath();
void setPathToSaveFiles(const std::string& path);
-std::string getStageClearSavePath();
std::string getPuzzleSetSavePath();
void OsCreateFolders();
\ No newline at end of file
diff --git a/source/code/puzzlehandler.cpp b/source/code/puzzlehandler.cpp
index 5965871..e6877db 100644
--- a/source/code/puzzlehandler.cpp
+++ b/source/code/puzzlehandler.cpp
@@ -23,7 +23,6 @@ http://blockattack.net
#include "puzzlehandler.hpp"
#include <vector>
-#include <fstream>
#include <iostream>
#include "stats.h"
#include <physfs.h> //Abstract file system. To use containers
@@ -61,10 +60,7 @@ const std::string& PuzzleGetName() {
void PuzzleSetName(const std::string& name) {
puzzleName = name;
-}
-
-void PuzzleSetSavePath(const std::string& filepath) {
- puzzleSavePath = filepath;
+ puzzleSavePath = name + ".save";
}
void PuzzleSetClear(int Level) {
@@ -72,7 +68,7 @@ void PuzzleSetClear(int Level) {
Stats::getInstance()->addOne("puzzlesSolved");
}
puzzleCleared[Level] = true;
- std::ofstream outfile;
+ PhysFS::ofstream outfile;
outfile.open(puzzleSavePath.c_str(), ios::binary |ios::trunc);
if (!outfile) {
std::cerr << "Error writing to file: " << puzzleSavePath << endl;
diff --git a/source/code/puzzlehandler.hpp b/source/code/puzzlehandler.hpp
index d8db7c5..ac54eaf 100644
--- a/source/code/puzzlehandler.hpp
+++ b/source/code/puzzlehandler.hpp
@@ -35,7 +35,6 @@ int PuzzleGetNumberOfPuzzles();
void PuzzleSetClear(int level);
const std::string& PuzzleGetName();
void PuzzleSetName(const std::string& name);
-void PuzzleSetSavePath(const std::string& filepath);
#endif /* PUZZLEHANDLER_HPP */
diff --git a/source/code/stageclearhandler.cpp b/source/code/stageclearhandler.cpp
index 017f7ed..397d40a 100644
--- a/source/code/stageclearhandler.cpp
+++ b/source/code/stageclearhandler.cpp
@@ -23,13 +23,12 @@ http://blockattack.net
#include "stageclearhandler.hpp"
#include "SDL.h"
-#include <fstream>
#include <vector>
#include <iostream>
+#include "physfs_stream.hpp"
//paths
-std::string stageClearSavePath;
-
+const char* const stageClearSaveName = "stageClear.SCsave";
std::vector<bool> stageCleared(nrOfStageLevels); //vector that tells if a stage is cleared
std::vector<Sint32> stageTimes(nrOfStageLevels); //For statistical puposes
@@ -47,10 +46,10 @@ void StageClearSetClear(int Level, int score, int time) {
stageTimes[Level] = gameEndedAfter;
}
- ofstream outfile;
- outfile.open(stageClearSavePath.c_str(), ios::binary |ios::trunc);
+ PhysFS::ofstream outfile;
+ outfile.open(stageClearSaveName, ios::binary |ios::trunc);
if (!outfile) {
- cerr << "Error writing to file: " << stageClearSavePath << endl;
+ cerr << "Error writing to file: " << stageClearSaveName << endl;
}
else {
for (int i=0; i<nrOfStageLevels; i++) {
@@ -72,7 +71,7 @@ void StageClearSetClear(int Level, int score, int time) {
void LoadStageClearStages() {
bool tempBool;
Uint32 tempUInt32;
- ifstream stageFile(stageClearSavePath.c_str(),ios::binary);
+ PhysFS::ifstream stageFile(stageClearSaveName, ios::binary);
if (stageFile) {
for (int i = 0; i<nrOfStageLevels; i++) {
stageFile.read(reinterpret_cast<char*>(&tempBool),sizeof(bool));
diff --git a/source/code/stageclearhandler.hpp b/source/code/stageclearhandler.hpp
index c80a184..47e629f 100644
--- a/source/code/stageclearhandler.hpp
+++ b/source/code/stageclearhandler.hpp
@@ -34,8 +34,6 @@ http://blockattack.net
#include <string>
-extern std::string stageClearSavePath;
-
void StageClearSetClear(int level, int score, int time);
void LoadStageClearStages();
int GetTotalScore();