Skip to content

Commit

Permalink
dummy up stuff to save out input-data for replays and move replays fo…
Browse files Browse the repository at this point in the history
…lder into the save folder rather than having an individual folder for each profile
  • Loading branch information
MinaciousGrace committed Jun 3, 2017
1 parent eab1dfa commit 909517c
Show file tree
Hide file tree
Showing 7 changed files with 42 additions and 1 deletion.
32 changes: 31 additions & 1 deletion src/HighScore.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

ThemeMetric<string> EMPTY_NAME("HighScore","EmptyName");

const string REPLAY_DIR = "Save/Replays/";

struct HighScoreImpl
{
string sName; // name that shows in the machine's ranking screen
Expand Down Expand Up @@ -567,6 +569,34 @@ bool HighScoreImpl::WriteReplayData(bool duringload) {
return true;
}

bool HighScore::WriteInputData(const vector<float>& oop) {
string append;
string profiledir;

string path = REPLAY_DIR + m_Impl->ScoreKey;
ofstream fileStream(path, ios::binary);
//check file

ASSERT(oop.size() > 0);

if (!fileStream) {
LOG->Warn("Failed to create replay file at %s", path.c_str());
return false;
}

unsigned int idx = oop.size() - 1;
//loop for writing both vectors side by side
for (unsigned int i = 0; i < idx; i++) {
append = to_string(oop[i]) + "\n";
fileStream.write(append.c_str(), append.size());
}
append = to_string(oop[idx]);
fileStream.write(append.c_str(), append.size());
fileStream.close();
LOG->Trace("Created replay file at %s", path.c_str());
return true;
}

// should just get rid of impl -mina
bool HighScore::LoadReplayData(bool duringload) {
// already exists
Expand Down Expand Up @@ -596,7 +626,7 @@ bool HighScore::LoadReplayData(bool duringload) {
LOG->Warn("Failed to load replay data at %s", path.c_str());
return false;
}

//loop until eof
while (getline(fileStream, line))
{
Expand Down
1 change: 1 addition & 0 deletions src/HighScore.h
Original file line number Diff line number Diff line change
Expand Up @@ -128,6 +128,7 @@ struct HighScore
void LoadFromEttNode(const XNode* pNode);

bool WriteReplayData(bool duringload);
bool WriteInputData(const vector<float>& oop);
bool LoadReplayData(bool duringload);
bool HasReplayData();
void UnloadReplayData();
Expand Down
3 changes: 3 additions & 0 deletions src/Player.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1829,6 +1829,9 @@ void Player::Step( int col, int row, const std::chrono::steady_clock::time_point
const float fPositionSeconds = m_pPlayerState->m_Position.m_fMusicSeconds - stepAgo;
const float fTimeSinceStep = stepAgo;

// idk if this is the correct value for input logs but we'll use them to test -mina
m_pPlayerStageStats->InputData.emplace_back(fPositionSeconds);

float fSongBeat = m_pPlayerState->m_Position.m_fSongBeat;

if( GAMESTATE->m_pCurSteps[m_pPlayerState->m_PlayerNumber] )
Expand Down
1 change: 1 addition & 0 deletions src/PlayerStageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ void PlayerStageStats::InternalInit()
m_fTimingScale = 0.f;
m_vOffsetVector.clear();
m_vNoteRowVector.clear();
InputData.clear();
m_iPossibleGradePoints = 0;
m_iCurCombo = 0;
m_iMaxCombo = 0;
Expand Down
1 change: 1 addition & 0 deletions src/PlayerStageStats.h
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ class PlayerStageStats
float m_fTimingScale;
vector<float> m_vOffsetVector;
vector<int> m_vNoteRowVector;
vector<float> InputData;
int m_iTapNoteScores[NUM_TapNoteScore];
int m_iHoldNoteScores[NUM_HoldNoteScore];
/** @brief The Player's current combo. */
Expand Down
2 changes: 2 additions & 0 deletions src/StageStats.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,8 @@ static HighScore FillInHighScore(const PlayerStageStats &pss, const PlayerState
// this whole thing needs to be redone, ssr calculation should be moved into highscore -mina
hs.SetSSRCalcVersion(GetCalcVersion());

hs.WriteInputData(pss.InputData);

return hs;
}

Expand Down
3 changes: 3 additions & 0 deletions stepmania.nsi
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,9 @@ Section "Main Section" SecMain
File /r /x CVS /x .svn "Save\LocalProfiles\00000000\Editable.ini"
SetOverwrite on

; i dont know where these dirs are created sooo
CreateDirectory "$INSTDIR\Save\Replays"

SetOutPath "$INSTDIR\Program"
!ifdef INSTALL_EXECUTABLES
; normal exec
Expand Down

0 comments on commit 909517c

Please sign in to comment.