to prevent crashes on missing data, load empty wave file and throw a warning when...
[supertux.git] / src / audio / sound_file.cpp
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 {