Skip to content

Commit

Permalink
Profile names are now sent lowercase
Browse files Browse the repository at this point in the history
And scores are refreshed correctly
  • Loading branch information
vittorioromeo committed Apr 7, 2013
1 parent 0c71e31 commit 4f012af
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 6 deletions.
2 changes: 1 addition & 1 deletion src/SSVOpenHexagon/Core/HexagonGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
9 changes: 5 additions & 4 deletions src/SSVOpenHexagon/Core/MenuGame.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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);
Expand Down Expand Up @@ -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};
Expand All @@ -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});
}
Expand Down
4 changes: 3 additions & 1 deletion src/SSVOpenHexagon/Data/ProfileData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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; }
Expand Down
3 changes: 3 additions & 0 deletions src/SSVOpenHexagon/Online/Online.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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");
}
Expand Down

0 comments on commit 4f012af

Please sign in to comment.