Skip to content

Commit

Permalink
fix broken paths preventing read/write of replaydata
Browse files Browse the repository at this point in the history
diffrentiate between profile dirs in the loadreplay function similar to write
  • Loading branch information
MinaciousGrace committed May 1, 2017
1 parent 63a4637 commit 814214d
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
36 changes: 27 additions & 9 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -495,11 +495,10 @@ bool HighScoreImpl::WriteReplayData(bool duringload) {
RString append;
RString profiledir;

//open file
if (duringload)
profiledir = PROFILEMAN->currentlyloadingprofile;
else
profiledir = PROFILEMAN->GetProfileDir(ProfileSlot_Player1);
profiledir = PROFILEMAN->GetProfileDir(ProfileSlot_Player1).substr(1); // THIS NEEDS TO BE HERE CAUSE LOL!!! -mina

RString path = profiledir + "ReplayData/" + ScoreKey;
ofstream fileStream(path, ios::binary);
Expand All @@ -522,14 +521,20 @@ bool HighScoreImpl::WriteReplayData(bool duringload) {
return true;
}

bool HighScore::LoadReplayData() {
bool HighScore::LoadReplayData(bool duringload) {
// already exists
if (m_Impl->vNoteRowVector.size() > 4 && m_Impl->vOffsetVector.size() > 4)
return true;

RString profiledir;
vector<int> vNoteRowVector;
vector<float> vOffsetVector;
RString profiledir = PROFILEMAN->GetProfileDir(ProfileSlot_Player1);

if (duringload)
profiledir = PROFILEMAN->currentlyloadingprofile;
else
profiledir = PROFILEMAN->GetProfileDir(ProfileSlot_Player1).substr(1);

RString path = profiledir + "ReplayData/" + m_Impl->ScoreKey;
std::ifstream fileStream(path, ios::binary);
string line;
Expand All @@ -545,7 +550,6 @@ bool HighScore::LoadReplayData() {
return false;
}


//loop until eof
while (getline(fileStream, line))
{
Expand Down Expand Up @@ -728,7 +732,7 @@ void HighScore::LoadFromNode( const XNode* pNode )

if (m_Impl->fSSRNormPercent == 11111.f) {
if (m_Impl->grade != Grade_Failed)
m_Impl->fSSRNormPercent = RescoreToWifeJudge(4);
m_Impl->fSSRNormPercent = RescoreToWifeJudgeDuringLoad(4);
else
m_Impl->fSSRNormPercent = m_Impl->fWifeScore;

Expand Down Expand Up @@ -923,7 +927,7 @@ void Screenshot::LoadFromNode( const XNode* pNode )
}

float HighScore::RescoreToWifeJudge(int x) {
if (!LoadReplayData())
if (!LoadReplayData(false))
return m_Impl->fWifeScore;

const float tso[] = { 1.50f,1.33f,1.16f,1.00f,0.84f,0.66f,0.50f,0.33f,0.20f };
Expand All @@ -936,6 +940,20 @@ float HighScore::RescoreToWifeJudge(int x) {
return p / static_cast<float>(m_Impl->vOffsetVector.size() * 2);
}

float HighScore::RescoreToWifeJudgeDuringLoad(int x) {
if (!LoadReplayData(true))
return m_Impl->fWifeScore;

const float tso[] = { 1.50f,1.33f,1.16f,1.00f,0.84f,0.66f,0.50f,0.33f,0.20f };
float ts = tso[x - 1];
float p = 0;
FOREACH_CONST(float, m_Impl->vOffsetVector, f)
p += wife2(*f, ts);

p += (m_Impl->iHoldNoteScores[HNS_LetGo] + m_Impl->iHoldNoteScores[HNS_Missed]) * -6.f;
return p / static_cast<float>(m_Impl->vOffsetVector.size() * 2);
}

// do not use for now- mina
float HighScoreImpl::RescoreToWifeTS(float ts) {
float p = 0;
Expand Down Expand Up @@ -1093,7 +1111,7 @@ class LunaHighScore: public Luna<HighScore>

// Convert to MS so lua doesn't have to
static int GetOffsetVector(T* p, lua_State *L) {
if (p->LoadReplayData()) {
if (p->LoadReplayData(false)) {
vector<float> doot = p->GetOffsetVector();
for (size_t i = 0; i < doot.size(); ++i)
doot[i] = doot[i] * 1000;
Expand All @@ -1106,7 +1124,7 @@ class LunaHighScore: public Luna<HighScore>
}

static int GetNoteRowVector(T* p, lua_State *L) {
if (p->LoadReplayData()) {
if (p->LoadReplayData(false)) {
LuaHelpers::CreateTableFromArray(p->GetNoteRowVector(), L);
p->UnloadReplayData();
}
Expand Down
3 changes: 2 additions & 1 deletion src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ struct HighScore
* @return true if no judgments were recorded, false otherwise. */
bool IsEmpty() const;
Grade GetWifeGrade();
bool LoadReplayData();
float ConvertDpToWife();
float GetPercentDP() const;
float GetWifeScore() const;
Expand Down Expand Up @@ -126,12 +125,14 @@ struct HighScore
void LoadFromEttNode(const XNode* pNode);

bool WriteReplayData(bool duringload);
bool LoadReplayData(bool duringload);
void UnloadReplayData();

RString GetDisplayName() const;

// Mina stuff - Mina
float RescoreToWifeJudge(int x);
float RescoreToWifeJudgeDuringLoad(int x); //uuugh -mina
float RescoreToDPJudge(int x);
float GetSkillsetSSR(Skillset ss) const;
void SetSkillsetSSR(Skillset ss, float ssr);
Expand Down

0 comments on commit 814214d

Please sign in to comment.