|
From: Lasse Kärkkäi. <tr...@us...> - 2009-11-14 18:45:24
|
Module: performous
Branch: dance
Commit: fad338dde91edd99262e642fe8ee1f8acd0a674b
Author: Lasse Karkkainen <tro...@tr...>
Date: Sat Nov 14 19:23:24 2009 +0200
No global variables for failsamples (this should avoid the mutex assertion failure on exit)
---
game/guitargraph.cc | 32 +++++++++++++++-----------------
game/guitargraph.hh | 1 +
2 files changed, 16 insertions(+), 17 deletions(-)
diff --git a/game/guitargraph.cc b/game/guitargraph.cc
index eff9119..ed011d3 100644
--- a/game/guitargraph.cc
+++ b/game/guitargraph.cc
@@ -41,8 +41,6 @@ namespace {
return score;
}
- std::vector<Sample> g_samplesG, g_samplesD;
-
}
GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
@@ -75,19 +73,20 @@ GuitarGraph::GuitarGraph(Audio& audio, Song const& song, std::string track):
m_use3d = false;
}
unsigned int sr = m_audio.getSR();
- if (g_samplesD.empty()) {
- g_samplesD.push_back(Sample(getPath("sounds/drum_bass.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_snare.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_hi-hat.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_tom1.ogg"), sr));
- g_samplesD.push_back(Sample(getPath("sounds/drum_cymbal.ogg"), sr));
- //g_samplesD.push_back(Sample(getPath("sounds/drum_tom2.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail1.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail2.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail3.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail4.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail5.ogg"), sr));
- g_samplesG.push_back(Sample(getPath("sounds/guitar_fail6.ogg"), sr));
+ if (m_drums) {
+ m_samples.push_back(Sample(getPath("sounds/drum_bass.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_snare.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_hi-hat.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_tom1.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/drum_cymbal.ogg"), sr));
+ //m_samples.push_back(Sample(getPath("sounds/drum_tom2.ogg"), sr));
+ } else {
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail1.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail2.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail3.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail4.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail5.ogg"), sr));
+ m_samples.push_back(Sample(getPath("sounds/guitar_fail6.ogg"), sr));
}
unsigned int i = 0;
for (TrackMap::const_iterator it = m_song.track_map.begin(); it != m_song.track_map.end(); ++it,++i) {
@@ -193,8 +192,7 @@ void GuitarGraph::fail(double time, int fret) {
if (fret == -2) return; // Tapped note
m_events.push_back(Event(time, 0, fret));
if (fret < 0) fret = std::rand();
- std::vector<Sample> const& samples = (m_drums ? g_samplesD : g_samplesG);
- m_audio.play(samples[unsigned(fret) % samples.size()], "audio/fail_volume");
+ m_audio.play(m_samples[unsigned(fret) % m_samples.size()], "audio/fail_volume");
m_score -= 50;
m_streak = 0;
}
diff --git a/game/guitargraph.hh b/game/guitargraph.hh
index 8adaafc..b4a6a15 100644
--- a/game/guitargraph.hh
+++ b/game/guitargraph.hh
@@ -73,6 +73,7 @@ class GuitarGraph {
Object3d m_fretObj;
Object3d m_tappableObj;
AnimValue m_hit[6];
+ std::vector<Sample> m_samples;
boost::scoped_ptr<Texture> m_neck;
bool m_drums;
bool m_use3d;
|