|
From: Yoda-JM <yo...@us...> - 2011-02-08 23:16:04
|
Module: performous
Branch: master
Commit: d4ae07c79dbebc60b70dd077f3a6c202e706a178
Author: Vincent Le Ligeour <yo...@us...>
Date: Wed Feb 9 00:14:50 2011 +0100
Fixed score computation on multi-vocal tracks
---
game/notes.cc | 19 ++++++++++++++++++-
game/songparser-ini.cc | 2 --
game/songparser-txt.cc | 1 -
game/songparser.cc | 8 ++++++--
game/songparser.hh | 1 -
5 files changed, 24 insertions(+), 7 deletions(-)
diff --git a/game/notes.cc b/game/notes.cc
index ed7c6c0..ed9f4ea 100644
--- a/game/notes.cc
+++ b/game/notes.cc
@@ -63,7 +63,24 @@ double Note::score(double n, double b, double e) const {
return scoreMultiplier() * powerFactor(n) * len;
}
-double Note::scoreMultiplier() const { return type == GOLDEN ? 2.0 : 1.0; }
+double Note::scoreMultiplier() const {
+ switch(type) {
+ case GOLDEN:
+ return 2.0;
+ case SLEEP:
+ return 0.0;
+ case FREESTYLE:
+ case NORMAL:
+ case SLIDE:
+ case TAP:
+ case HOLDBEGIN:
+ case HOLDEND:
+ case ROLL:
+ case MINE:
+ case LIFT:
+ return 1.0;
+ }
+}
double Note::powerFactor(double note) const {
if (type == FREESTYLE) return 1.0;
diff --git a/game/songparser-ini.cc b/game/songparser-ini.cc
index 8548f15..36e724b 100644
--- a/game/songparser-ini.cc
+++ b/game/songparser-ini.cc
@@ -245,7 +245,6 @@ void SongParser::iniParse() {
inter.note = n.note;
inter.type = Note::SLIDE;
inter.syllable = std::string("~");
- m_maxScore += inter.maxScore();
vocal.noteMin = std::min(vocal.noteMin, inter.note);
vocal.noteMax = std::max(vocal.noteMax,inter.note);
vocal.notes.push_back(inter);
@@ -255,7 +254,6 @@ void SongParser::iniParse() {
n.type = Note::NORMAL;
}
}
- m_maxScore += n.maxScore();
vocal.noteMin = std::min(vocal.noteMin, n.note);
vocal.noteMax = std::max(vocal.noteMax, n.note);
vocal.notes.push_back(n);
diff --git a/game/songparser-txt.cc b/game/songparser-txt.cc
index fd9d451..856ff9f 100644
--- a/game/songparser-txt.cc
+++ b/game/songparser-txt.cc
@@ -142,7 +142,6 @@ bool SongParser::txtParseNote(std::string line, VocalTrack &vocal) {
if (n.type != Note::SLEEP && n.end > n.begin) {
vocal.noteMin = std::min(vocal.noteMin, n.note);
vocal.noteMax = std::max(vocal.noteMax, n.note);
- m_maxScore += n.maxScore();
}
if (n.type == Note::SLEEP) {
if (notes.empty()) return true; // Ignore sleeps at song beginning
diff --git a/game/songparser.cc b/game/songparser.cc
index 8a20d98..2b7b9b4 100644
--- a/game/songparser.cc
+++ b/game/songparser.cc
@@ -43,7 +43,6 @@ SongParser::SongParser(Song& s):
m_prevtime(),
m_prevts(),
m_relativeShift(),
- m_maxScore(),
m_tsPerBeat(),
m_tsEnd()
{
@@ -131,7 +130,12 @@ void SongParser::finalize() {
}
// Set begin/end times
if (!vocal.notes.empty()) vocal.beginTime = vocal.notes.front().begin, vocal.endTime = vocal.notes.back().end;
- vocal.m_scoreFactor = 1.0 / m_maxScore;
+ // Compute maximum score
+ double max_score = 0.0;
+ for (Notes::iterator it = vocal.notes.begin(); it != vocal.notes.end(); ++it) {
+ max_score += it->maxScore();
+ }
+ vocal.m_scoreFactor = 1.0 / max_score;
}
if (m_tsPerBeat) {
// Add song beat markers
diff --git a/game/songparser.hh b/game/songparser.hh
index a0bb6e5..601fbce 100644
--- a/game/songparser.hh
+++ b/game/songparser.hh
@@ -48,7 +48,6 @@ class SongParser {
double m_prevtime;
unsigned int m_prevts;
unsigned int m_relativeShift;
- double m_maxScore;
struct BPM {
BPM(double _begin, double _ts, double bpm): begin(_begin), step(0.25 * 60.0 / bpm), ts(_ts) {}
double begin; // Time in seconds
|