commit e567627f
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++) {