Skip to content

Commit

Permalink
EO stuff
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Dec 27, 2017
1 parent c9fc19f commit a169c22
Show file tree
Hide file tree
Showing 8 changed files with 95 additions and 54 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -707,6 +707,10 @@ local profilebuttons = Def.ActorFrame{
easyInputStringWithFunction("Password:", 50, true, password)
easyInputStringWithFunction("Username:",50, false, username)
else
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).UserName = ""
playerConfig:get_data(pn_to_profile_slot(PLAYER_1)).Password = ""
playerConfig:set_dirty(pn_to_profile_slot(PLAYER_1))
playerConfig:save(pn_to_profile_slot(PLAYER_1))
DLMAN:Logout()
end
end
Expand Down
18 changes: 12 additions & 6 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ DownloadManager::~DownloadManager()
}
curl_global_cleanup();
if (LoggedIn())
EndSessionIfExists();
EndSession();
}

Download* DownloadManager::DownloadAndInstallPack(const string &url)
Expand Down Expand Up @@ -592,7 +592,7 @@ void DownloadManager::UploadScore(HighScore* hs)
curl_easy_setopt(curlHandle, CURLOPT_HTTPPOST, form);
function<void(HTTPRequest&)> done = [hs](HTTPRequest& req) {
if (req.result == "\"Success\"") {
hs->SetUploaded(true);
hs->AddUploadedServer(serverURL.Get());
}
};
HTTPRequest* req = new HTTPRequest(curlHandle, done);
Expand Down Expand Up @@ -625,7 +625,7 @@ void DownloadManager::UploadScoreWithReplayData(HighScore* hs)
curl_easy_setopt(curlHandle, CURLOPT_HTTPPOST, form);
function<void(HTTPRequest&)> done = [hs](HTTPRequest& req) {
if (req.result == "\"Success\"") {
hs->SetUploaded(true);
hs->AddUploadedServer(serverURL.Get());
}
};
HTTPRequest* req = new HTTPRequest(curlHandle, done);
Expand All @@ -638,6 +638,11 @@ void DownloadManager::EndSessionIfExists()
{
if (!LoggedIn())
return;
EndSession();
MESSAGEMAN->Broadcast("LogOut");
}
void DownloadManager::EndSession()
{
string url = serverURL.Get() + "/destroy";
CURL *curlHandle = initCURLHandle();
SetCURLPostToURL(curlHandle, url);
Expand All @@ -647,7 +652,6 @@ void DownloadManager::EndSessionIfExists()
session = sessionUser = sessionPass = sessionCookie = "";
scores.clear();
sessionRatings.clear();
MESSAGEMAN->Broadcast("LogOut");
}

std::vector<std::string> split(const std::string& s, char delimiter)
Expand Down Expand Up @@ -700,6 +704,7 @@ OnlineScore DownloadManager::GetTopSkillsetScore(unsigned int rank, Skillset ss,
result=false;
return OnlineScore();
}

void DownloadManager::RefreshTop25(Skillset ss)
{
if (!LoggedIn())
Expand Down Expand Up @@ -861,9 +866,10 @@ bool DownloadManager::UploadScores()
auto scores = SCOREMAN->GetAllPBPtrs();
for (auto&vec : scores) {
for (auto&scorePtr : vec) {
if (!scorePtr->GetUploaded())
if (!scorePtr->IsUploadedToServer(serverURL.Get())) {
UploadScore(scorePtr);
scorePtr->SetUploaded(true);
scorePtr->AddUploadedServer(serverURL.Get());
}
}
}
return true;
Expand Down
1 change: 1 addition & 0 deletions src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ class DownloadManager
map<Skillset, int> sessionRanks;
bool LoggedIn();
void EndSessionIfExists();
void EndSession();
void StartSession(string user, string pass);
bool UploadScores();
vector<DownloadablePack>* GetPackList(string url, bool &result);
Expand Down
67 changes: 44 additions & 23 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ struct HighScoreImpl
float fJudgeScale;
bool bNoChordCohesion;
bool bEtternaValid;
bool uploaded{ false };
vector<string> uploaded;
vector<float> vOffsetVector;
vector<int> vNoteRowVector;
vector<int> vRescoreJudgeVector;
Expand Down Expand Up @@ -258,24 +258,28 @@ HighScoreImpl::HighScoreImpl()

XNode *HighScoreImpl::CreateNode() const
{
XNode *pNode = new XNode( "HighScore" );
XNode *pNode = new XNode("HighScore");

// TRICKY: Don't write "name to fill in" markers.
pNode->AppendChild( "Name", IsRankingToFillIn(sName) ? RString("") : sName );
pNode->AppendChild( "HistoricChartKey", ChartKey);
pNode->AppendChild( "ScoreKey", ScoreKey);
pNode->AppendChild( "SSRCalcVersion", SSRCalcVersion);
pNode->AppendChild( "Grade", GradeToString(grade) );
pNode->AppendChild( "Score", iScore );
pNode->AppendChild( "PercentDP", fPercentDP );
pNode->AppendChild( "WifeScore", fWifeScore);
pNode->AppendChild( "SSRNormPercent", fSSRNormPercent);
pNode->AppendChild( "Rate", fMusicRate);
pNode->AppendChild( "JudgeScale", fJudgeScale);
pNode->AppendChild( "NoChordCohesion", bNoChordCohesion);
pNode->AppendChild( "EtternaValid", bEtternaValid);
pNode->AppendChild("Uploaded", uploaded);

pNode->AppendChild("Name", IsRankingToFillIn(sName) ? RString("") : sName);
pNode->AppendChild("HistoricChartKey", ChartKey);
pNode->AppendChild("ScoreKey", ScoreKey);
pNode->AppendChild("SSRCalcVersion", SSRCalcVersion);
pNode->AppendChild("Grade", GradeToString(grade));
pNode->AppendChild("Score", iScore);
pNode->AppendChild("PercentDP", fPercentDP);
pNode->AppendChild("WifeScore", fWifeScore);
pNode->AppendChild("SSRNormPercent", fSSRNormPercent);
pNode->AppendChild("Rate", fMusicRate);
pNode->AppendChild("JudgeScale", fJudgeScale);
pNode->AppendChild("NoChordCohesion", bNoChordCohesion);
pNode->AppendChild("EtternaValid", bEtternaValid);
if (!uploaded.empty()) {
XNode *pServerNode = new XNode("Servers");
for (auto server : uploaded)
pServerNode->AppendChild("server", server);
pNode->AppendChild(pServerNode);
}
if (vOffsetVector.size() > 1) {
pNode->AppendChild("Offsets", OffsetsToString(vOffsetVector));
pNode->AppendChild("NoteRows", NoteRowsToString(vNoteRowVector));
Expand Down Expand Up @@ -338,7 +342,12 @@ XNode *HighScoreImpl::CreateEttNode() const {
pNode->AppendChild("Modifiers", sModifiers);
pNode->AppendChild("DateTime", dateTime.GetString());
pNode->AppendChild("TopScore", TopScore);
pNode->AppendChild("Uploaded", uploaded);
if (!uploaded.empty()) {
XNode *pServerNode = new XNode("Servers");
for (auto server : uploaded)
pServerNode->AppendChild("server", server);
pNode->AppendChild(pServerNode);
}

XNode* pTapNoteScores = pNode->AppendChild("TapNoteScores");
FOREACH_ENUM(TapNoteScore, tns)
Expand Down Expand Up @@ -378,7 +387,15 @@ void HighScoreImpl::LoadFromEttNode(const XNode *pNode) {
pNode->GetChildValue("JudgeScale", fJudgeScale);
pNode->GetChildValue("NoChordCohesion", bNoChordCohesion);
pNode->GetChildValue("EtternaValid", bEtternaValid);
pNode->GetChildValue("Uploaded", uploaded);
const XNode* pUploadedServers = pNode->GetChild("Servers");
if (pUploadedServers != nullptr) {
FOREACH_CONST_Child(pUploadedServers, p)
{
RString server;
p->GetTextValue(server);
uploaded.emplace_back(server.c_str());
}
}
pNode->GetChildValue("SurviveSeconds", fSurviveSeconds);
pNode->GetChildValue("MaxCombo", iMaxCombo);
pNode->GetChildValue("Modifiers", s); sModifiers = s;
Expand Down Expand Up @@ -715,10 +732,11 @@ float HighScore::GetWifePoints() const { return m_Impl->fWifePoints; }
float HighScore::GetSSRNormPercent() const { return m_Impl->fSSRNormPercent; }
float HighScore::GetMusicRate() const { return m_Impl->fMusicRate; }
float HighScore::GetJudgeScale() const { return m_Impl->fJudgeScale; }
bool HighScore::GetChordCohesion() const {
return !m_Impl->bNoChordCohesion; }
bool HighScore::GetChordCohesion() const { return !m_Impl->bNoChordCohesion; }
bool HighScore::GetEtternaValid() const { return m_Impl->bEtternaValid; }
bool HighScore::GetUploaded() const { return m_Impl->uploaded; }
bool HighScore::IsUploadedToServer(string s) const {
return find(m_Impl->uploaded.begin(), m_Impl->uploaded.end(), s) != m_Impl->uploaded.end();
}
vector<float> HighScore::GetOffsetVector() const { return m_Impl->vOffsetVector; }
vector<int> HighScore::GetNoteRowVector() const { return m_Impl->vNoteRowVector; }
string HighScore::GetScoreKey() const { return m_Impl->ScoreKey; }
Expand Down Expand Up @@ -753,7 +771,10 @@ void HighScore::SetMusicRate(float f) { m_Impl->fMusicRate = f; }
void HighScore::SetJudgeScale(float f) { m_Impl->fJudgeScale = f; }
void HighScore::SetChordCohesion(bool b) { m_Impl->bNoChordCohesion = b; }
void HighScore::SetEtternaValid(bool b) { m_Impl->bEtternaValid = b; }
bool HighScore::SetUploaded(bool b) { return m_Impl->uploaded = b; }
void HighScore::AddUploadedServer(string s) {
if (find(m_Impl->uploaded.begin(), m_Impl->uploaded.end(), s) == m_Impl->uploaded.end())
m_Impl->uploaded.emplace_back(s);
}
void HighScore::SetOffsetVector(const vector<float>& v) { m_Impl->vOffsetVector = v; }
void HighScore::SetNoteRowVector(const vector<int>& v) { m_Impl->vNoteRowVector = v; }
void HighScore::SetScoreKey(const string& sk) { m_Impl->ScoreKey = sk; }
Expand Down
4 changes: 2 additions & 2 deletions src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ struct HighScore
float GetJudgeScale() const;
bool GetChordCohesion() const;
bool GetEtternaValid() const;
bool GetUploaded() const;
bool IsUploadedToServer(string s) const;
vector<float> GetOffsetVector() const;
vector<int> GetNoteRowVector() const;
vector<float> timeStamps;
Expand Down Expand Up @@ -96,7 +96,7 @@ struct HighScore
void SetJudgeScale(float f);
void SetChordCohesion(bool b);
void SetEtternaValid(bool b);
bool SetUploaded(bool b);
void AddUploadedServer(string s);
void SetOffsetVector(const vector<float>& v);
void SetNoteRowVector(const vector<int>& v);
void SetScoreKey(const string& ck);
Expand Down
32 changes: 20 additions & 12 deletions src/ScoreManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -260,6 +260,25 @@ void ScoreManager::SetAllTopScores() {
}
}

bool ScoresAtRate::HandleNoCCPB(HighScore& hs) {
// lurker says:
// don't even TRY to fuck with nocc pb unless the score is nocc
if (hs.GetChordCohesion() == 0) {
// Set any nocc pb
if (noccPBptr == nullptr) {
noccPBptr = &hs;
return true;
}
else {
// update nocc pb if a better score is found
if (noccPBptr->GetSSRNormPercent() < hs.GetSSRNormPercent()) {
noccPBptr = &hs;
return true;
}
}
}
return false;
}
static const float ld_update = 0.02f;
void ScoreManager::RecalculateSSRs(LoadingWindow *ld) {
RageTimer ld_timer;
Expand Down Expand Up @@ -498,18 +517,7 @@ void ScoresAtRate::LoadFromNode(const XNode* node, const string& ck, const float
PBptr = &scores.find(sk)->second;
}

// lurker says:
// don't even TRY to fuck with nocc pb unless the score is nocc
if (scores[sk].GetChordCohesion() == 0) {
// Set any nocc pb
if (noccPBptr == nullptr)
noccPBptr = &scores.find(sk)->second;
else {
// update nocc pb if a better score is found
if (noccPBptr->GetSSRNormPercent() < scores[sk].GetSSRNormPercent())
noccPBptr = &scores.find(sk)->second;
}
}
HandleNoCCPB(scores[sk]);

// Fill in stuff for the highscores
scores[sk].SetChartKey(ck);
Expand Down
3 changes: 2 additions & 1 deletion src/ScoreManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,8 @@ struct ScoresAtRate

vector<string> GetSortedKeys();
void PushSelf(lua_State *L);


bool HandleNoCCPB(HighScore& hs);

XNode* CreateNode(const int& rate) const;
void LoadFromNode(const XNode* node, const string& key, const float& rate);
Expand Down
20 changes: 10 additions & 10 deletions src/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -274,15 +274,6 @@ static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState
hs.SetSkillsetSSR(ss, 0.f);
}

if (DLMAN->ShouldUploadScores()) {
auto steps = SONGMAN->GetStepsByChartkey(hs.GetChartKey());
auto td = steps->GetTimingData();
SCOREMAN->SetAllTopScores(); // this is super lazy and a chart specific function should be made -mina
hs.timeStamps = td->ConvertReplayNoteRowsToTimestamps(pss.GetNoteRowVector(), hs.GetMusicRate());
DLMAN->UploadScoreWithReplayData(&hs);
hs.timeStamps.clear();
hs.timeStamps.shrink_to_fit();
}
bool writesuccess = hs.WriteReplayData();
if (writesuccess)
hs.UnloadReplayData();
Expand Down Expand Up @@ -327,7 +318,7 @@ void StageStats::FinalizeScores(bool bSummary)
m_multiPlayer[mp].m_HighScore = FillInHighScore(m_multiPlayer[mp], *GAMESTATE->m_pMultiPlayerState[mp], "", sPlayerGuid);
}

const HighScore &hs = m_player[PLAYER_1].m_HighScore;
HighScore &hs = m_player[PLAYER_1].m_HighScore;
StepsType st = GAMESTATE->GetCurrentStyle(PLAYER_1)->m_StepsType;

const Song* pSong = GAMESTATE->m_pCurSong;
Expand All @@ -337,6 +328,15 @@ void StageStats::FinalizeScores(bool bSummary)
// new score structure -mina
Profile* zzz = PROFILEMAN->GetProfile(PLAYER_1);
SCOREMAN->AddScore(hs);
if (DLMAN->ShouldUploadScores()) {
auto steps = SONGMAN->GetStepsByChartkey(hs.GetChartKey());
auto td = steps->GetTimingData();
SCOREMAN->SetAllTopScores(); // this is super lazy and a chart specific function should be made -mina
hs.timeStamps = td->ConvertReplayNoteRowsToTimestamps(m_player[PLAYER_1].GetNoteRowVector(), hs.GetMusicRate());
DLMAN->UploadScoreWithReplayData(&hs);
hs.timeStamps.clear();
hs.timeStamps.shrink_to_fit();
}
zzz->SetAnyAchievedGoals(GAMESTATE->m_pCurSteps[PLAYER_1]->GetChartKey(), GAMESTATE->m_SongOptions.GetCurrent().m_fMusicRate, hs);
mostrecentscorekey = hs.GetScoreKey();
zzz->m_lastSong.FromSong(GAMESTATE->m_pCurSong);
Expand Down

0 comments on commit a169c22

Please sign in to comment.