summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorkrzys-h <krzys_h@interia.pl>2014-11-02 13:33:37 +0100
committerkrzys-h <krzys_h@interia.pl>2014-11-02 13:35:00 +0100
commit6d152d5aeedf8207897f751bfbd179d9994f39cf (patch)
treeff702f7992ca0c7149969194a35241eef6a3f283
parentec4b71eca2466004636a55f5bd4ab9e524e803c3 (diff)
downloadcolobot-6d152d5aeedf8207897f751bfbd179d9994f39cf.tar.gz
colobot-6d152d5aeedf8207897f751bfbd179d9994f39cf.tar.bz2
colobot-6d152d5aeedf8207897f751bfbd179d9994f39cf.zip
Fixed console spam when music files are not installed
Closes #359
-rw-r--r--src/sound/oalsound/alsound.cpp10
-rw-r--r--src/sound/oalsound/alsound.h2
-rw-r--r--src/sound/oalsound/buffer.cpp2
-rw-r--r--src/sound/sound.cpp10
-rw-r--r--src/sound/sound.h12
-rw-r--r--src/ui/maindialog.cpp6
6 files changed, 38 insertions, 4 deletions
diff --git a/src/sound/oalsound/alsound.cpp b/src/sound/oalsound/alsound.cpp
index 0d8fe74..6dd991b 100644
--- a/src/sound/oalsound/alsound.cpp
+++ b/src/sound/oalsound/alsound.cpp
@@ -181,6 +181,16 @@ bool ALSound::CacheMusic(const std::string &filename)
return false;
}
+bool ALSound::IsCached(Sound sound)
+{
+ return m_sounds.find(sound) != m_sounds.end();
+}
+
+bool ALSound::IsCachedMusic(const std::string &filename)
+{
+ return m_music.find("music/"+filename) != m_music.end();
+}
+
int ALSound::GetPriority(Sound sound)
{
if ( sound == SOUND_FLYh ||
diff --git a/src/sound/oalsound/alsound.h b/src/sound/oalsound/alsound.h
index 08caac3..895b5ac 100644
--- a/src/sound/oalsound/alsound.h
+++ b/src/sound/oalsound/alsound.h
@@ -53,6 +53,8 @@ public:
bool Create() override;
bool Cache(Sound, const std::string &) override;
bool CacheMusic(const std::string &) override;
+ bool IsCached(Sound) override;
+ bool IsCachedMusic(const std::string &) override;
bool GetEnable() override;
diff --git a/src/sound/oalsound/buffer.cpp b/src/sound/oalsound/buffer.cpp
index 7584767..df31b82 100644
--- a/src/sound/oalsound/buffer.cpp
+++ b/src/sound/oalsound/buffer.cpp
@@ -58,7 +58,7 @@ bool Buffer::LoadFromFile(std::string filename, Sound sound)
if (!file->IsOpen())
{
- GetLogger()->Warn("Could not load file. Reason: %s\n", file->GetLastError().c_str());
+ GetLogger()->Warn("Could not load file %s. Reason: %s\n", filename.c_str(), file->GetLastError().c_str());
m_loaded = false;
return false;
}
diff --git a/src/sound/sound.cpp b/src/sound/sound.cpp
index abc18f6..ab92ec1 100644
--- a/src/sound/sound.cpp
+++ b/src/sound/sound.cpp
@@ -72,6 +72,16 @@ bool CSoundInterface::CacheMusic(const std::string &bFile)
return true;
}
+bool CSoundInterface::IsCached(Sound bSound)
+{
+ return false;
+}
+
+bool CSoundInterface::IsCachedMusic(const std::string& bFile)
+{
+ return false;
+}
+
bool CSoundInterface::GetEnable()
{
return true;
diff --git a/src/sound/sound.h b/src/sound/sound.h
index 2ed4199..20f459c 100644
--- a/src/sound/sound.h
+++ b/src/sound/sound.h
@@ -180,6 +180,18 @@ public:
* \return return true on success
*/
virtual bool CacheMusic(const std::string &bFile);
+
+ /** Function to check if sound effect file was cached.
+ * \param bSound - id of a sound effect file
+ * \return return true if the file was cached
+ */
+ virtual bool IsCached(Sound bSound);
+
+ /** Function called to check if music file was cached.
+ * \param bFile - file to check
+ * \return return true if the file was cached
+ */
+ virtual bool IsCachedMusic(const std::string &bFile);
/** Return if plugin is enabled
* \return return true if plugin is enabled
diff --git a/src/ui/maindialog.cpp b/src/ui/maindialog.cpp
index 4b1c8f2..0bb1e36 100644
--- a/src/ui/maindialog.cpp
+++ b/src/ui/maindialog.cpp
@@ -707,7 +707,7 @@ void CMainDialog::ChangePhase(Phase phase)
m_phase != PHASE_SETUPcs &&
m_phase != PHASE_SETUPss )
{
- if (!m_sound->IsPlayingMusic())
+ if (!m_sound->IsPlayingMusic() && m_sound->IsCachedMusic("Intro1.ogg"))
{
m_sound->PlayMusic("Intro1.ogg", false);
}
@@ -733,7 +733,7 @@ void CMainDialog::ChangePhase(Phase phase)
}
if ( m_phase == PHASE_TRAINER ) strcpy(m_sceneName, "exercises");
- if ( m_phase == PHASE_DEFI ) strcpy(m_sceneName, "challenges" );
+ if ( m_phase == PHASE_DEFI ) strcpy(m_sceneName, "challenges");
if ( m_phase == PHASE_MISSION ) strcpy(m_sceneName, "missions");
if ( m_phase == PHASE_FREE ) strcpy(m_sceneName, "freemissions");
if ( m_phase == PHASE_USER ) strcpy(m_sceneName, "custom");
@@ -1760,7 +1760,7 @@ bool CMainDialog::EventProcess(const Event &event)
m_phase != PHASE_SETUPcs &&
m_phase != PHASE_SETUPss )
{
- if (!m_sound->IsPlayingMusic())
+ if (!m_sound->IsPlayingMusic() && m_sound->IsCachedMusic("Intro2.ogg"))
{
m_sound->PlayMusic("Intro2.ogg", true);
}