|
From: Jaakko N. <jni...@us...> - 2009-11-17 21:58:57
|
Module: performous
Branch: dance
Commit: 80751319809b55c1f40dfd54bc62d306305f88c2
Author: Jaakko Nikkola <jaa...@tk...>
Date: Tue Nov 17 23:57:30 2009 +0200
Changed note container to a single vector containing all the notes.
---
game/notes.cc | 2 +-
game/notes.hh | 4 ++--
game/songparser-sm.cc | 20 ++++++++++++--------
game/songparser.hh | 2 +-
4 files changed, 16 insertions(+), 12 deletions(-)
diff --git a/game/notes.cc b/game/notes.cc
index 6e307c4..1bfe3ae 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -78,7 +78,7 @@ double Note::scoreMultiplier(double error) const {
Duration::Duration(): begin(getNaN()), end(getNaN()) {}
-DanceTrack::DanceTrack(std::string& d, DanceChords& c) : description(d), chords(c) {}
+DanceTrack::DanceTrack(std::string& description, Notes& notes) : description(description), notes(notes) {}
diff --git a/game/notes.hh b/game/notes.hh
index 3af625f..4d43e89 100644
--- a/game/notes.hh
+++ b/game/notes.hh
@@ -102,11 +102,11 @@ typedef std::vector<DanceChord> DanceChords;
struct DanceTrack {
- DanceTrack(std::string& d, DanceChords& c);
+ DanceTrack(std::string& description, Notes& notes);
//track description
std::string description;
//container for the actual note data
- DanceChords chords;
+ Notes notes;
};
enum DanceDifficulty {
diff --git a/game/songparser-sm.cc b/game/songparser-sm.cc
index edcba3f..f94f5c4 100644
--- a/game/songparser-sm.cc
+++ b/game/songparser-sm.cc
@@ -93,11 +93,11 @@ bool SongParser::smParseField(std::string line) {
//std::string radarvalues = boost::trim_copy(line.substr(0, line.size() -2));
//<NoteData>:
- DanceChords chords = smParseNotes(line, endOfInput);
+ Notes notes = smParseNotes(line, endOfInput);
if(endOfInput) throw std::runtime_error("end is here");
- DanceTrack danceTrack(description, chords);
+ DanceTrack danceTrack(description, notes);
DanceDifficultyMap danceDifficultyMap;
danceDifficultyMap.insert(std::make_pair(danceDifficulty, danceTrack));
m_song.danceTracks.insert(std::make_pair(notestype, danceDifficultyMap));
@@ -138,8 +138,9 @@ bool SongParser::smParseField(std::string line) {
return true;
}
-DanceChords SongParser::smParseNotes(std::string line, bool endOfInput) {
- DanceChords chords;
+Notes SongParser::smParseNotes(std::string line, bool endOfInput) {
+ DanceChords chords; //temporary container for notes
+ Notes notes;
int lcount = 0; //line counter for note duration
int count = 0; //total lines counter
double tm = 0; //time counter
@@ -149,7 +150,7 @@ DanceChords SongParser::smParseNotes(std::string line, bool endOfInput) {
// std::cout << line << std::endl;
if (line.empty() || line == "\r") continue;
if (line[0] == '/' && line[1] == '/') continue;
- if (line[0] == '#') return chords;
+ if (line[0] == '#') return notes;
if (line[0] == ';') continue;
if (line[0] == ',') {
/*Counting the timestamp of each note*/
@@ -161,6 +162,8 @@ DanceChords SongParser::smParseNotes(std::string line, bool endOfInput) {
if(_chord.find(i) != _chord.end()) {
_chord[i].begin = tm;
_chord[i].end = tm;
+ notes.push_back(_chord[i]); //note added to notes container used in DanceTrack
+
}
}
tm += dur;
@@ -168,12 +171,13 @@ DanceChords SongParser::smParseNotes(std::string line, bool endOfInput) {
lcount =0;
continue;
}
- //reading notes into a chord
- std::istringstream iss(line);
+ //reading notes into a temporary container chord
DanceChord chord;
+ std::istringstream iss(line);
for(int i =0; i<4; i++){
if(iss.get() == '1') {
Note note;
+ note.note = i;
chord[i] = note;
}
chords.push_back(chord);
@@ -183,5 +187,5 @@ DanceChords SongParser::smParseNotes(std::string line, bool endOfInput) {
continue;
}
endOfInput = true;
- return chords;
+ return notes;
}
diff --git a/game/songparser.hh b/game/songparser.hh
index becd2e1..9fe2cc0 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -99,7 +99,7 @@ class SongParser {
bool smCheck(std::vector<char> const& data);
void smParse();
bool smParseField(std::string line);
- DanceChords smParseNotes(std::string line, bool endOfInput);
+ Notes smParseNotes(std::string line, bool endOfInput);
double m_prevtime;
unsigned int m_prevts;
unsigned int m_relativeShift;
|