diff options
author | krzys-h <krzys_h@interia.pl> | 2013-05-02 16:37:11 +0200 |
---|---|---|
committer | krzys-h <krzys_h@interia.pl> | 2013-05-02 16:37:11 +0200 |
commit | 166a6b44035f4b70a3edcc0dcaa04c8220e6e4ca (patch) | |
tree | 99cbcafe0126dfa277d51786299f91cc6acc39de /src/sound | |
parent | 56709f0e5630a2874ccd133d08604a99f6095157 (diff) | |
download | colobot-166a6b44035f4b70a3edcc0dcaa04c8220e6e4ca.tar.gz colobot-166a6b44035f4b70a3edcc0dcaa04c8220e6e4ca.tar.bz2 colobot-166a6b44035f4b70a3edcc0dcaa04c8220e6e4ca.zip |
Improved music cache
Diffstat (limited to 'src/sound')
-rw-r--r-- | src/sound/oalsound/alsound.cpp | 15 |
1 files changed, 8 insertions, 7 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp index a37cced..ef8ff8d 100644 --- a/src/sound/oalsound/alsound.cpp +++ b/src/sound/oalsound/alsound.cpp @@ -169,17 +169,18 @@ bool ALSound::Cache(Sound sound, std::string filename) bool ALSound::CacheMusic(std::string filename) { - Buffer *buffer = new Buffer(); - std::stringstream file; - file << m_soundPath << "/" << filename; - if (buffer->LoadFromFile(file.str(), static_cast<Sound>(-1))) { - mMusic[filename] = buffer; - return true; + if(mMusic.find(filename) == mMusic.end()) { + Buffer *buffer = new Buffer(); + std::stringstream file; + file << m_soundPath << "/" << filename; + if (buffer->LoadFromFile(file.str(), static_cast<Sound>(-1))) { + mMusic[filename] = buffer; + return true; + } } return false; } - int ALSound::GetPriority(Sound sound) { if ( sound == SOUND_FLYh || |