summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-07-10 15:38:37 +0200
committerkrzys-h <krzys_h@interia.pl>2014-07-10 15:38:37 +0200
commit7b04f673580f0c24aecc103a25c4c4b82da1380f (patch)
tree57fa168513ab2bc99daa434032f538abfc3bf444
parent1ee0c0e8fe2b4f0cba35b65b2c17deaa9f1dc8e8 (diff)
downloadcolobot-7b04f673580f0c24aecc103a25c4c4b82da1380f.tar.gz
colobot-7b04f673580f0c24aecc103a25c4c4b82da1380f.tar.bz2
colobot-7b04f673580f0c24aecc103a25c4c4b82da1380f.zip
Fixed music loading
-rw-r--r--src/sound/oalsound/alsound.cpp20
-rw-r--r--src/sound/sound.cpp8
-rw-r--r--src/ui/maindialog.cpp7
3 files changed, 17 insertions, 18 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index e9bc116..54c94a5 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -173,12 +173,12 @@ bool ALSound::Cache(Sound sound, const std::string &filename)
bool ALSound::CacheMusic(const std::string &filename)
{
- if (m_music.find(filename) == m_music.end())
+ if (m_music.find("music/"+filename) == m_music.end())
{
Buffer *buffer = new Buffer();
- if (buffer->LoadFromFile(filename, static_cast<Sound>(-1)))
+ if (buffer->LoadFromFile("music/"+filename, static_cast<Sound>(-1)))
{
- m_music[filename] = buffer;
+ m_music["music/"+filename] = buffer;
return true;
}
}
@@ -609,7 +609,7 @@ void ALSound::SetListener(const Math::Vector &eye, const Math::Vector &lookat)
bool ALSound::PlayMusic(int rank, bool bRepeat, float fadeTime)
{
std::stringstream filename;
- filename << "music/music" << std::setfill('0') << std::setw(3) << rank << ".ogg";
+ filename << "music" << std::setfill('0') << std::setw(3) << rank << ".ogg";
return PlayMusic(filename.str(), bRepeat, fadeTime);
}
@@ -636,26 +636,26 @@ bool ALSound::PlayMusic(const std::string &filename, bool bRepeat, float fadeTim
Buffer *buffer;
// check if we have music in cache
- if (m_music.find(filename) == m_music.end())
+ if (m_music.find("music/"+filename) == m_music.end())
{
GetLogger()->Debug("Music %s was not cached!\n", filename.c_str());
- if (!boost::filesystem::exists(filename))
+ /* TODO: if (!boost::filesystem::exists("music/"+filename))
{
GetLogger()->Debug("Requested music %s was not found.\n", filename.c_str());
return false;
- }
+ } */
buffer = new Buffer();
- if (!buffer->LoadFromFile(filename, static_cast<Sound>(-1)))
+ if (!buffer->LoadFromFile("music/"+filename, static_cast<Sound>(-1)))
{
return false;
}
- m_music[filename] = buffer;
+ m_music["music/"+filename] = buffer;
}
else
{
GetLogger()->Debug("Music loaded from cache\n");
- buffer = m_music[filename];
+ buffer = m_music["music/"+filename];
}
if (m_currentMusic)
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
index 9c9f483..5d99cdb 100644
--- a/src/sound/sound.cpp
+++ b/src/sound/sound.cpp
@@ -54,10 +54,10 @@ void CSoundInterface::CacheAll()
void CSoundInterface::AddMusicFiles()
{
- CacheMusic("music/Intro1.ogg");
- CacheMusic("music/Intro2.ogg");
- CacheMusic("music/music010.ogg");
- CacheMusic("music/music011.ogg");
+ CacheMusic("Intro1.ogg");
+ CacheMusic("Intro2.ogg");
+ CacheMusic("music010.ogg");
+ CacheMusic("music011.ogg");
}
bool CSoundInterface::Cache(Sound bSound, const std::string &bFile)
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index c6322b6..2699b46 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -764,7 +764,7 @@ pb->SetState(STATE_SHADOW);
{
if (!m_sound->IsPlayingMusic())
{
- m_sound->PlayMusic("music/Intro1.ogg", false);
+ m_sound->PlayMusic("Intro1.ogg", false);
}
}
@@ -2013,7 +2013,7 @@ bool CMainDialog::EventProcess(const Event &event)
{
if (!m_sound->IsPlayingMusic())
{
- m_sound->PlayMusic("music/Intro2.ogg", true);
+ m_sound->PlayMusic("Intro2.ogg", true);
}
}
@@ -3579,7 +3579,7 @@ void CMainDialog::SetUserDir(char *base, int rank)
void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank)
{
- //TODO: Support for more than 100
+ //TODO: Support for more than 9 chapters
int chapter = rank/100;
int new_rank = rank%100;
@@ -3614,7 +3614,6 @@ void CMainDialog::BuildSceneName(std::string &filename, char *base, int rank)
outstream << "scene.txt";
}
filename = outstream.str();
- std::cout << filename.c_str() << std::endl;
}
}