Skip to content

Commit

Permalink
Unload replay data after saving it
Browse files Browse the repository at this point in the history
  • Loading branch information
nico-abram committed Apr 2, 2018
1 parent 74516bb commit 8de1477
Showing 1 changed file with 14 additions and 12 deletions.
26 changes: 14 additions & 12 deletions src/DBProfile.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -843,19 +843,21 @@ void DBProfile::SavePlayerScores(SQLite::Database* db, const Profile* profile, D
int scoreID = sqlite3_last_insert_rowid(db->getHandle());
try {
//Save Replay Data
hs->LoadReplayData();
auto &offsets = hs->GetOffsetVector();
auto &rows = hs->GetNoteRowVector();
unsigned int idx = rows.size() >= 1 ? rows.size() - 1 : 0U;
//loop for writing both vectors side by side
for (unsigned int offsetIndex = 0; offsetIndex < idx; offsetIndex++) {
SQLite::Statement insertOffset(*db, "INSERT INTO offsets VALUES (NULL, ?, ?, ?)");
insertOffset.bind(1, rows[offsetIndex]);
insertOffset.bind(2, offsets[offsetIndex]);
insertOffset.bind(3, scorekeyID);
insertOffset.exec();
if (hs->LoadReplayData()) {
auto &offsets = hs->GetOffsetVector();
auto &rows = hs->GetNoteRowVector();
unsigned int idx = rows.size() >= 1 ? rows.size() - 1 : 0U;
//loop for writing both vectors side by side
for (unsigned int offsetIndex = 0; offsetIndex < idx; offsetIndex++) {
SQLite::Statement insertOffset(*db, "INSERT INTO offsets VALUES (NULL, ?, ?, ?)");
insertOffset.bind(1, rows[offsetIndex]);
insertOffset.bind(2, offsets[offsetIndex]);
insertOffset.bind(3, scorekeyID);
insertOffset.exec();
}
}
} catch (std::exception& e) { }
} catch (std::exception& e) { //No replay data for this score }
hs->UnloadReplayData();
}
}
}
Expand Down

0 comments on commit 8de1477

Please sign in to comment.