to prevent crashes on missing data, load empty wave file and throw a warning when...
authorMarek Moeckel <wansti@gmx.de>
Fri, 9 May 2008 10:39:11 +0000 (10:39 +0000)
committerMarek Moeckel <wansti@gmx.de>
Fri, 9 May 2008 10:39:11 +0000 (10:39 +0000)
SVN-Revision: 5449

data/sounds/empty.wav [new file with mode: 0644]
src/audio/sound_file.cpp

diff --git a/data/sounds/empty.wav b/data/sounds/empty.wav
new file mode 100644 (file)
index 0000000..36f2b7d
Binary files /dev/null and b/data/sounds/empty.wav differ
index 2495bbb..98a615b 100644 (file)
@@ -398,9 +398,13 @@ SoundFile* load_sound_file(const std::string& filename)
 
   PHYSFS_file* file = PHYSFS_openRead(filename.c_str());
   if(!file) {
+    log_warning << "Couldn't open '" << filename << "': " << PHYSFS_getLastError() << ", using dummy sound file." << std::endl;
+    file = PHYSFS_openRead("sounds/empty.wav");
+       if (!file) {
     std::stringstream msg;
-    msg << "Couldn't open '" << filename << "': " << PHYSFS_getLastError();
-    throw std::runtime_error(msg.str());
+       msg << "Couldn't open dummy sound file '" << filename << "': " << PHYSFS_getLastError();
+               throw std::runtime_error(msg.str());
+       }
   }
 
   try {