From: Marek Moeckel Date: Fri, 9 May 2008 10:39:11 +0000 (+0000) Subject: to prevent crashes on missing data, load empty wave file and throw a warning when... X-Git-Url: https://git.verplant.org/?a=commitdiff_plain;h=bdc4269b5f5a074bb34b4d085ec24aaff8c9c347;p=supertux.git to prevent crashes on missing data, load empty wave file and throw a warning when a sound file cannot be found SVN-Revision: 5449 --- diff --git a/data/sounds/empty.wav b/data/sounds/empty.wav new file mode 100644 index 000000000..36f2b7d6b Binary files /dev/null and b/data/sounds/empty.wav differ diff --git a/src/audio/sound_file.cpp b/src/audio/sound_file.cpp index 2495bbbb0..98a615b14 100644 --- a/src/audio/sound_file.cpp +++ b/src/audio/sound_file.cpp @@ -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 {