git repos / blockattack-game

commit e567627f

Poul Sander · 2016-02-17 18:47
e567627f4cbef3e5a62e2d6e584eb540ece3395f patch · browse files
parent 63acc19f496037def33149b694abfeb5e41c87d3

Make it work even if the highscore files are not present

Changed files

M source/code/highscore.cpp before
diff --git a/source/code/highscore.cpp b/source/code/highscore.cpp index 9d3e888..99a6bbe 100644 --- a/source/code/highscore.cpp +++ b/source/code/highscore.cpp
@@ -53,10 +53,12 @@ Highscore::Highscore(const std::string& type) {
this->type = type;
filename = type+".json.dat";
std::string readFileContent = sago::GetFileContent(filename.c_str());
- std::stringstream ss(readFileContent);
- {
- cereal::JSONInputArchive archive(ss);
- archive(cereal::make_nvp("highscore", table));
+ if (readFileContent.length() > 0) {
+ std::stringstream ss(readFileContent);
+ {
+ cereal::JSONInputArchive archive(ss);
+ archive(cereal::make_nvp("highscore", table));
+ }
}
if (table.size() < top) {
for (int i = 0; i<top; i++) {