|
From: Tapio V. <aa...@us...> - 2010-01-27 13:52:45
|
Module: performous
Branch: master
Commit: 6541a99ed896a0bf6bed8a2224e4c1d03b8d9ef9
Author: Tapio Vierros <tap...@gm...>
Date: Wed Jan 27 15:00:28 2010 +0200
Drop note data when exiting song.
---
game/screen_sing.cc | 1 +
game/song.cc | 20 ++++++++++++++++++++
game/song.hh | 2 ++
3 files changed, 23 insertions(+), 0 deletions(-)
diff --git a/game/screen_sing.cc b/game/screen_sing.cc
index 76dd130..5cefeb3 100644
--- a/game/screen_sing.cc
+++ b/game/screen_sing.cc
@@ -171,6 +171,7 @@ void ScreenSing::exit() {
m_pause_icon.reset();
m_video.reset();
m_background.reset();
+ m_song->dropNotes();
theme.reset();
if (m_audio.isPaused()) m_audio.togglePause();
}
diff --git a/game/song.cc b/game/song.cc
index a67015d..0d2af5b 100644
--- a/game/song.cc
+++ b/game/song.cc
@@ -38,6 +38,26 @@ void Song::reload(bool errorIgnore) {
collateUpdate();
}
+void Song::dropNotes() {
+ // Singing
+ if (!notes.empty()) {
+ notes.clear();
+ notes.push_back(Note()); // Dummy note to indicate there is a track
+ }
+ // Instruments
+ if (!track_map.empty()) {
+ for (TrackMap::iterator it = track_map.begin(); it != track_map.end(); ++it)
+ it->second.nm.clear();
+ }
+ // Dancing
+ if (!danceTracks.empty()) {
+ for (DanceTracks::iterator it = danceTracks.begin(); it != danceTracks.end(); ++it)
+ it->second.clear();
+ }
+ b0rkedTracks = false;
+ loadStatus = HEADER;
+}
+
void Song::collateUpdate() {
collateByTitle = collate(title + artist) + '\0' + filename;
collateByTitleOnly = collate(title);
diff --git a/game/song.hh b/game/song.hh
index 33b29cd..9718265 100644
--- a/game/song.hh
+++ b/game/song.hh
@@ -29,6 +29,8 @@ class Song: boost::noncopyable {
void reload(bool errorIgnore = true);
/// parse field
bool parseField(std::string const& line);
+ /// drop notes (to conserve memory), but keep info about available tracks
+ void dropNotes();
/** Get formatted song label. **/
std::string str() const { return title + " by " + artist; }
/** Get full song information (used by the search function). **/
|