[colobot] 167/390: Fixed console spam when music files are not installed

Didier Raboud odyx at moszumanska.debian.org
Fri Jun 12 14:21:41 UTC 2015


This is an automated email from the git hooks/post-receive script.

odyx pushed a commit to branch upstream/latest
in repository colobot.

commit 6d152d5aeedf8207897f751bfbd179d9994f39cf
Author: krzys-h <krzys_h at interia.pl>
Date:   Sun Nov 2 13:33:37 2014 +0100

    Fixed console spam when music files are not installed
    
    Closes #359
---
 src/sound/oalsound/alsound.cpp | 10 ++++++++++
 src/sound/oalsound/alsound.h   |  2 ++
 src/sound/oalsound/buffer.cpp  |  2 +-
 src/sound/sound.cpp            | 10 ++++++++++
 src/sound/sound.h              | 12 ++++++++++++
 src/ui/maindialog.cpp          |  6 +++---
 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);
             }

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-games/colobot.git



More information about the Pkg-games-commits mailing list