Skip to content

Commit

Permalink
update scoreupload process
Browse files Browse the repository at this point in the history
- store last result message from upload and expose it to lua
- no longer store timestamp vectors, rebuild it from noterows while uploading
- assign calcversion before uploading score
- call settopscore before uploading
  • Loading branch information
MinaciousGrace committed Nov 20, 2017
1 parent 7f038c4 commit bfaaeb8
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/DownloadManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -510,6 +510,9 @@ bool DownloadManager::UploadScore(HighScore* hs)
LOG->Trace(result.c_str());
return false;
}

mostrecentresult = result;

return ret == 0;
}
void DownloadManager::EndSessionIfExists()
Expand Down Expand Up @@ -811,6 +814,11 @@ class LunaDownloadManager : public Luna<DownloadManager>
}
return 1;
}
static int GetMostRecentUploadResult(T* p, lua_State* L)
{
lua_pushstring(L, p->mostrecentresult);
return 1;
}
LunaDownloadManager()
{
ADD_METHOD(GetPackList);
Expand All @@ -819,6 +827,7 @@ class LunaDownloadManager : public Luna<DownloadManager>
ADD_METHOD(GetFilteredAndSearchedPackList);
ADD_METHOD(IsLoggedIn);
ADD_METHOD(Login);
ADD_METHOD(GetMostRecentUploadResult);
}
};
LUA_REGISTER_CLASS(DownloadManager)
Expand Down
2 changes: 2 additions & 0 deletions src/DownloadManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ class DownloadManager
inline void AddSessionCookieToCURL(CURL *curlHandle);
inline void SetCURLPostToURL(CURL *curlHandle, string url);

// most recent single score upload result -mina
RString mostrecentresult = "";

// Lua
void PushSelf(lua_State *L);
Expand Down
1 change: 0 additions & 1 deletion src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,6 @@ void Player::SetJudgment( int iRow, int iTrack, const TapNote &tn, TapNoteScore
m_pPlayerStageStats->CurWifeScore = curwifescore;
m_pPlayerStageStats->MaxWifeScore = maxwifescore;
m_pPlayerStageStats->m_vOffsetVector.emplace_back(tn.result.fTapNoteOffset);
m_pPlayerStageStats->timeStamps.emplace_back(m_Timing->WhereUAtBroNoOffset(iRow));
m_pPlayerStageStats->m_vNoteRowVector.emplace_back(iRow);
}
else {
Expand Down
1 change: 0 additions & 1 deletion src/PlayerStageStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ class PlayerStageStats
// Calculate the difficulty rating for a specific score obtained by a player - Mina
Grade GetWifeGrade();
vector<float> CalcSSR(float ssrpercent) const;
vector<float> timeStamps;
void GenerateValidationKeys(HighScore& hs) const;
float GetPercentDancePoints() const;
float GetWifeScore() const;
Expand Down
13 changes: 9 additions & 4 deletions src/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -266,23 +266,28 @@ static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState
vector<float> dakine = pss.CalcSSR(hs.GetSSRNormPercent());
FOREACH_ENUM(Skillset, ss)
hs.SetSkillsetSSR(ss, dakine[ss]);

hs.SetSSRCalcVersion(GetCalcVersion());
}
else {
FOREACH_ENUM(Skillset, ss)
hs.SetSkillsetSSR(ss, 0.f);
}
hs.timeStamps = pss.timeStamps;

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());
DLMAN->UploadScore(&hs);
hs.timeStamps.clear();
hs.timeStamps.shrink_to_fit();
}
bool writesuccess = hs.WriteReplayData();
if (writesuccess)
hs.UnloadReplayData();
}

// this whole thing needs to be redone, ssr calculation should be moved into highscore -mina
hs.SetSSRCalcVersion(GetCalcVersion());

pss.GenerateValidationKeys(hs);

if (!pss.InputData.empty())
Expand Down
7 changes: 7 additions & 0 deletions src/TimingData.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1413,6 +1413,13 @@ float TimingData::WhereUAtBroNoOffset(float beat) const {
return GetElapsedTimeFromBeatNoOffset(beat);
}

vector<float> TimingData::ConvertReplayNoteRowsToTimestamps(vector<int> nrv) {
vector<float> o;
for (auto nr : nrv)
o.emplace_back(WhereUAtBroNoOffset(nr));
return o;
}

const vector<float>& TimingData::BuildAndGetEtaner(const vector<int>& nerv) {
ElapsedTimesAtNonEmptyRows.clear();

Expand Down
2 changes: 2 additions & 0 deletions src/TimingData.h
Original file line number Diff line number Diff line change
Expand Up @@ -483,6 +483,8 @@ class TimingData
float WhereUAtBroNoOffset(float beat);
float WhereUAtBro(int row);

vector<float> ConvertReplayNoteRowsToTimestamps(vector<int> nrv);

bool ValidSequentialAssumption = true;
void InvalidateSequentialAssmption() { ValidSequentialAssumption = false; }
bool IsSequentialAssumptionValid() { return ValidSequentialAssumption; }
Expand Down

0 comments on commit bfaaeb8

Please sign in to comment.