Permalink
Browse files

Profile names are now sent lowercase

And scores are refreshed correctly
  • Loading branch information...
1 parent 0c71e31 commit 4f012aff3a9d06ca785b669d225964b38a41ea8d @SuperV1234 committed Apr 7, 2013
@@ -164,7 +164,7 @@ namespace hg
if(status.scoreInvalid || !isEligibleForScore()) return;
string validator{Online::getValidator(levelData.getPackPath(), levelData.getId(), levelData.getLevelRootPath(), levelData.getStyleRootPath(), levelData.getLuaScriptPath())};
- Online::startSendScore(getCurrentProfile().getName(), validator, difficultyMult, status.currentTime);
+ Online::startSendScore(toLower(getCurrentProfile().getName()), validator, difficultyMult, status.currentTime);
}
void HexagonGame::goToMenu(bool mSendScores)
{
@@ -142,14 +142,14 @@ namespace hg
game.addInput({{k::Return}}, [&](float)
{
playSound("beep.ogg");
- if(state == s::PROFILES) { setCurrentProfile(profileNewName); state = s::MAIN; }
+ if(state == s::PROFILES) { setCurrentProfile(profileNewName); state = s::MAIN; refreshScores(); }
else if(state == s::MAIN)
{
window.setGameState(hexagonGame.getGame());
hexagonGame.newGame(levelDataIds[currentIndex], true, difficultyMultipliers[difficultyMultIndex % difficultyMultipliers.size()]);
}
else if(state == s::OPTIONS) optionsMenu.executeCurrentItem();
- else if(state == s::PROFILE_NEW) if(!profileNewName.empty()) { createProfile(profileNewName); setCurrentProfile(profileNewName); state = States::MAIN; }
+ else if(state == s::PROFILE_NEW) if(!profileNewName.empty()) { createProfile(profileNewName); setCurrentProfile(profileNewName); state = s::MAIN; refreshScores(); }
}, t::SINGLE);
game.addInput({{k::F1}}, [&](float) { playSound("beep.ogg"); if(state == s::PROFILES) { profileNewName = ""; state = s::PROFILE_NEW; } }, t::SINGLE);
game.addInput({{k::F2}, {k::J}}, [&](float) { playSound("beep.ogg"); if(state == s::MAIN ) { profileNewName = ""; state = s::PROFILES; } }, t::SINGLE);
@@ -158,7 +158,7 @@ namespace hg
{
playSound("beep.ogg"); if(state == s::MAIN) { auto p(getPackPaths()); packIndex = (packIndex + 1) % p.size(); levelDataIds = getLevelIdsByPack(p[packIndex]); setIndex(0); }
}, t::SINGLE);
- game.addInput({{k::Escape}}, [&](float) { playSound("beep.ogg"); if(state == s::OPTIONS) state = s::MAIN; }, t::SINGLE);
+ game.addInput({{k::Escape}}, [&](float) { playSound("beep.ogg"); if(state == s::OPTIONS) state = s::MAIN; refreshScores(); }, t::SINGLE);
game.addInput({{k::Escape}}, [&](float mFrameTime) { if(state != s::OPTIONS) exitTimer += mFrameTime; });
game.addInput({{k::F12}}, [&](float){ mustTakeScreenshot = true; }, t::SINGLE);
game.addInput({{k::LAlt, k::Return}}, [&](float){ setFullscreen(window, !window.getFullscreen()); }, t::SINGLE);
@@ -189,6 +189,7 @@ namespace hg
}
string MenuGame::getLeaderboard()
{
+ if(currentLeaderboard == "NULL" || currentPlayerScore == "NULL") return "no scores";
if(currentLeaderboard == "" || currentPlayerScore == "") return "refreshing...";
unsigned int leaderboardRecordCount{8};
@@ -202,7 +203,7 @@ namespace hg
for(auto itr(root.begin()); itr != root.end(); ++itr)
{
Json::Value& record(*itr);
- string name{getValue<string>(record, "n")};
+ string name{toLower(getValue<string>(record, "n"))};
float score{getValue<float>(record, "s")};
recordPairs.push_back({name, score});
}
@@ -2,16 +2,18 @@
// License: Academic Free License ("AFL") v. 3.0
// AFL License page: http://opensource.org/licenses/AFL-3.0
+#include <SSVUtils/SSVUtils.h>
#include "SSVOpenHexagon/Data/ProfileData.h"
using namespace std;
+using namespace ssvu;
namespace hg
{
ProfileData::ProfileData(float mVersion, const string& mName, Json::Value mScores) : version{mVersion}, name{mName}, scores{mScores} { }
float ProfileData::getVersion() { return version; }
- string ProfileData::getName() { return name; }
+ string ProfileData::getName() { return toLower(name); }
Json::Value ProfileData::getScores() { return scores; }
void ProfileData::setScore(const string& mId, float mScore) { scores[mId] = mScore; }
@@ -175,7 +175,10 @@ namespace hg
{
log("Scores successfully received", "Online");
if(!startsWith(response[0], "MySQL Error") && !startsWith(response[0], "NULL")) mTargetScores = response[0];
+ else mTargetScores = "NULL";
+
if(!startsWith(response[1], "MySQL Error") && !startsWith(response[1], "NULL")) mTargetPlayerScore = response[1];
+ else mTargetPlayerScore = "NULL";
}
else log("Error: could not get scores", "Online");
}

0 comments on commit 4f012af

Please sign in to comment.