Skip to content

Commit

Permalink
update read and write replay data functions to utilize new replay dir
Browse files Browse the repository at this point in the history
  • Loading branch information
MinaciousGrace committed Jun 7, 2017
1 parent feb50ec commit b6036d4
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
27 changes: 11 additions & 16 deletions src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ struct HighScoreImpl
void UnloadReplayData();
void ResetSkillsets();

bool WriteReplayData(bool duringload);
bool WriteReplayData();

float RescoreToWifeTS(float ts);

Expand Down Expand Up @@ -479,7 +479,7 @@ void HighScoreImpl::LoadFromNode(const XNode *pNode)
//if (vOffsetVector.size() > 1 && fWifeScore == 0.f)
// fWifeScore = RescoreToWifeTS(fJudgeScale);
if (vNoteRowVector.size() + vOffsetVector.size() > 2 && (vNoteRowVector.size() == vOffsetVector.size()) && fWifeScore > 0.f) {
bool writesuccess = WriteReplayData(true);
bool writesuccess = WriteReplayData();

// ensure data is written out somewhere else before destroying it
if (writesuccess)
Expand Down Expand Up @@ -546,7 +546,7 @@ void HighScoreImpl::LoadFromNode(const XNode *pNode)
grade = clamp( grade, Grade_Tier01, Grade_Failed );
}

bool HighScoreImpl::WriteReplayData(bool duringload) {
bool HighScoreImpl::WriteReplayData() {
string append;
string profiledir;

Expand Down Expand Up @@ -603,21 +603,16 @@ bool HighScore::WriteInputData(const vector<float>& oop) {
}

// should just get rid of impl -mina
bool HighScore::LoadReplayData(bool duringload) {
bool HighScore::LoadReplayData() {
// already exists
if (m_Impl->vNoteRowVector.size() > 4 && m_Impl->vOffsetVector.size() > 4)
return true;

string profiledir;
vector<int> vNoteRowVector;
vector<float> vOffsetVector;
string path = REPLAY_DIR + m_Impl->ScoreKey;

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

string path = profiledir + "ReplayData/" + m_Impl->ScoreKey;
std::ifstream fileStream(path, ios::binary);
string line;
string buffer;
Expand Down Expand Up @@ -1023,7 +1018,7 @@ void Screenshot::LoadFromNode( const XNode* pNode )
}

float HighScore::RescoreToWifeJudge(int x) {
if (!LoadReplayData(false))
if (!LoadReplayData())
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 @@ -1039,7 +1034,7 @@ float HighScore::RescoreToWifeJudge(int x) {
}

float HighScore::RescoreToWifeJudgeDuringLoad(int x) {
if (!LoadReplayData(true))
if (!LoadReplayData())
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 Down Expand Up @@ -1125,8 +1120,8 @@ Grade HighScore::GetWifeGrade() {
return m_Impl->GetWifeGrade();
}

bool HighScore::WriteReplayData(bool duringload) {
return m_Impl->WriteReplayData(duringload);
bool HighScore::WriteReplayData() {
return m_Impl->WriteReplayData();
}

// Ok I guess we can be more lenient and convert by midwindow values, but we still have to assume j4 - mina
Expand Down Expand Up @@ -1211,7 +1206,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(false)) {
if (p->LoadReplayData()) {
vector<float> doot = p->GetOffsetVector();
for (size_t i = 0; i < doot.size(); ++i)
doot[i] = doot[i] * 1000;
Expand All @@ -1224,7 +1219,7 @@ class LunaHighScore: public Luna<HighScore>
}

static int GetNoteRowVector(T* p, lua_State *L) {
if (p->LoadReplayData(false)) {
if (p->LoadReplayData()) {
LuaHelpers::CreateTableFromArray(p->GetNoteRowVector(), L);
p->UnloadReplayData();
}
Expand Down
4 changes: 2 additions & 2 deletions src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -127,9 +127,9 @@ struct HighScore
void LoadFromNode( const XNode* pNode );
void LoadFromEttNode(const XNode* pNode);

bool WriteReplayData(bool duringload);
bool WriteReplayData();
bool WriteInputData(const vector<float>& oop);
bool LoadReplayData(bool duringload);
bool LoadReplayData();
bool HasReplayData();
void UnloadReplayData();
void ResetSkillsets();
Expand Down

0 comments on commit b6036d4

Please sign in to comment.