diff --git a/source/code/BlockGame.hpp b/source/code/BlockGame.hpp index db90d9b..2b272c3 100644 --- a/source/code/BlockGame.hpp +++ b/source/code/BlockGame.hpp @@ -261,6 +261,7 @@ public: int getLevel() const; bool GetAIenabled() const; bool IsNearDeath() const; + double GetBaseSpeed() const { return baseSpeed; } const BlockGameInfo& GetBlockGameInfo() { return replayInfo; } diff --git a/source/code/highscore.cpp b/source/code/highscore.cpp index b37d5f5..758177f 100644 --- a/source/code/highscore.cpp +++ b/source/code/highscore.cpp @@ -28,6 +28,7 @@ https://blockattack.net #include "cereal/archives/json.hpp" #include "sago/SagoMisc.hpp" #include +#include "common.h" namespace cereal { @@ -51,6 +52,13 @@ bool record_sorter (const record& i,const record& j) { } Highscore::Highscore(const std::string& type, double speed) : filename(type+".json.dat"), type(type), speed(speed) { + if (speed < 0.4) { + std::string old_locale = setlocale (LC_NUMERIC, nullptr); + setlocale (LC_NUMERIC, "C"); + //Use special filenames for higher speeds (higher speed = lower number) + filename = SPrintStringF("%s_%.4f.json.dat", type.c_str(), speed); + setlocale(LC_NUMERIC, old_locale.c_str()); + } std::string readFileContent = sago::GetFileContent(filename.c_str()); if (readFileContent.length() > 0) { try { diff --git a/source/code/main.cpp b/source/code/main.cpp index 784483a..3b5c601 100644 --- a/source/code/main.cpp +++ b/source/code/main.cpp @@ -1205,8 +1205,7 @@ int main(int argc, char* argv[]) { } int runGame(Gametype gametype, int level) { - Highscore theTopScoresEndless = Highscore("endless", 0.5); - Highscore theTopScoresTimeTrial = Highscore("timetrial", 0.5); + Highscore theTopScoresTimeTrial = Highscore("timetrial", 0.5); drawBalls = true; puzzleLoaded = false; bool bNearDeath = false; //Play music faster or louder while tru @@ -1733,6 +1732,7 @@ int runGame(Gametype gametype, int level) { theTopScoresTimeTrial.addScore(theGame2.name, theGame2.GetScore()); } if (theGame.isGameOver() && registerEndlessHighscore) { + Highscore theTopScoresEndless = Highscore("endless", theGame.GetBaseSpeed()); registerEndlessHighscore = false; theTopScoresEndless.addScore(theGame.name, theGame.GetScore()); theGame.EndlessHighscoreEvent();