From db3b63e6fda49420ef832b3fc14e983ea80d0691 Mon Sep 17 00:00:00 2001 From: Unknown Date: Fri, 27 Jul 2018 17:11:09 -0400 Subject: [PATCH] update client key validation --- src/DownloadManager.cpp | 13 ++++++------- src/HighScore.cpp | 12 +++++++----- src/HighScore.h | 3 +++ 3 files changed, 16 insertions(+), 12 deletions(-) diff --git a/src/DownloadManager.cpp b/src/DownloadManager.cpp index 4843fb6ca6..86b901f645 100644 --- a/src/DownloadManager.cpp +++ b/src/DownloadManager.cpp @@ -36,7 +36,7 @@ static Preference serverURL("UploadServerAPIURL", "https://api.etternao static Preference automaticSync("automaticScoreSync", 1); static Preference downloadPacksToAdditionalSongs("downloadPacksToAdditionalSongs", 0); static const string TEMP_ZIP_MOUNT_POINT = "/@temp-zip/"; -static const string CLIENT_DATA_KEY = "6EE45A0D6997622C67A6064AFAE8D93A8CAEE575D17D5E16DA3EDBFC8D7D2477"; +static const string CLIENT_DATA_KEY = "2EEF1FCF01B97335548DE7CB9CF4DD749882AF6D5DC080316CC71A3A0BB3BB83"; static const string DL_DIR = SpecialFiles::CACHE_DIR + "Downloads/"; size_t write_memory_buffer(void *contents, size_t size, size_t nmemb, void *userp) @@ -678,7 +678,8 @@ bool DownloadManager::ShouldUploadScores() inline void SetCURLPOSTScore(CURL*& curlHandle, curl_httppost*& form, curl_httppost*& lastPtr, HighScore*& hs) { SetCURLFormPostField(curlHandle, form, lastPtr, "scorekey", hs->GetScoreKey()); - SetCURLFormPostField(curlHandle, form, lastPtr, "ssr_norm", hs->GetSSRNormPercent()); + SetCURLFormPostField(curlHandle, form, lastPtr, "ValidString", hs->GenerateValidationKeys()); + SetCURLFormPostField(curlHandle, form, lastPtr, "ssr_norm", hs->norms); SetCURLFormPostField(curlHandle, form, lastPtr, "max_combo", hs->GetMaxCombo()); SetCURLFormPostField(curlHandle, form, lastPtr, "valid", static_cast(hs->GetEtternaValid())); SetCURLFormPostField(curlHandle, form, lastPtr, "mods", hs->GetModifiers()); @@ -694,7 +695,7 @@ inline void SetCURLPOSTScore(CURL*& curlHandle, curl_httppost*& form, curl_httpp SetCURLFormPostField(curlHandle, form, lastPtr, "letgo", hs->GetHoldNoteScore(HNS_LetGo)); SetCURLFormPostField(curlHandle, form, lastPtr, "ng", hs->GetHoldNoteScore(HNS_Missed)); SetCURLFormPostField(curlHandle, form, lastPtr, "chartkey", hs->GetChartKey()); - SetCURLFormPostField(curlHandle, form, lastPtr, "rate", hs->GetMusicRate()); + SetCURLFormPostField(curlHandle, form, lastPtr, "rate", hs->musics); auto chart = SONGMAN->GetStepsByChartkey(hs->GetChartKey()); SetCURLFormPostField(curlHandle, form, lastPtr, "negsolo", chart->GetTimingData()->HasWarps() || chart->m_StepsType != StepsType_dance_single); SetCURLFormPostField(curlHandle, form, lastPtr, "nocc", static_cast(!hs->GetChordCohesion())); @@ -703,12 +704,10 @@ inline void SetCURLPOSTScore(CURL*& curlHandle, curl_httppost*& form, curl_httpp SetCURLFormPostField(curlHandle, form, lastPtr, "hash", hs->GetValidationKey(ValidationKey_Brittle)); SetCURLFormPostField(curlHandle, form, lastPtr, "wife", hs->GetWifeScore()); SetCURLFormPostField(curlHandle, form, lastPtr, "wifePoints", hs->GetWifePoints()); - SetCURLFormPostField(curlHandle, form, lastPtr, "judgeScale", hs->GetJudgeScale()); + SetCURLFormPostField(curlHandle, form, lastPtr, "judgeScale", hs->judges); SetCURLFormPostField(curlHandle, form, lastPtr, "machineGuid", hs->GetMachineGuid()); SetCURLFormPostField(curlHandle, form, lastPtr, "grade", hs->GetGrade()); - SetCURLFormPostField(curlHandle, form, lastPtr, "wifeGrade", string(GradeToString(hs->GetWifeGrade()).c_str())); - SetCURLFormPostField(curlHandle, form, lastPtr, "ValidString", hs->GenerateValidationKeys()); - + SetCURLFormPostField(curlHandle, form, lastPtr, "wifeGrade", string(GradeToString(hs->GetWifeGrade()).c_str())); } void DownloadManager::UploadScore(HighScore* hs) { diff --git a/src/HighScore.cpp b/src/HighScore.cpp index 03888d7c89..7b6a5eb452 100644 --- a/src/HighScore.cpp +++ b/src/HighScore.cpp @@ -864,15 +864,17 @@ string HighScore::GenerateValidationKeys() { key.append(to_string(GetHoldNoteScore(hns))); } + norms = lround(GetSSRNormPercent() * 1000000.f); + musics = lround(GetMusicRate() * 100.f); + judges = lround(GetJudgeScale() * 100.f); + key.append(GetScoreKey()); key.append(GetChartKey()); key.append(GetModifiers()); key.append(GetMachineGuid()); - key.append(to_string(static_cast(GetWifeScore()))); - key.append(to_string(static_cast(GetSSRNormPercent()))); - key.append(to_string(static_cast(GetMusicRate()))); - key.append(to_string(static_cast(GetJudgeScale()))); - key.append(to_string(static_cast(GetWifePoints()))); + key.append(to_string(norms)); + key.append(to_string(musics)); + key.append(to_string(judges)); key.append(to_string(static_cast(!GetChordCohesion()))); key.append(to_string(static_cast(GetEtternaValid()))); key.append(GradeToString(GetWifeGrade())); diff --git a/src/HighScore.h b/src/HighScore.h index 9401209e3d..5ae6a88d6f 100644 --- a/src/HighScore.h +++ b/src/HighScore.h @@ -177,6 +177,9 @@ struct HighScore int userid; string avatar; + int norms = 0; + int musics = 0; + int judges = 0; // Lua void PushSelf( lua_State *L ); private: