[Supertux-Commit] r5449 - in trunk/supertux: data/sounds src/audio

wansti at millhouse.dreamhost.com wansti at millhouse.dreamhost.com
Fri May 9 03:39:13 PDT 2008


Author: wansti
Date: 2008-05-09 03:39:11 -0700 (Fri, 09 May 2008)
New Revision: 5449

Added:
   trunk/supertux/data/sounds/empty.wav
Modified:
   trunk/supertux/src/audio/sound_file.cpp
Log:
to prevent crashes on missing data, load empty wave file and throw a warning when a sound file cannot be found


Added: trunk/supertux/data/sounds/empty.wav
===================================================================
(Binary files differ)


Property changes on: trunk/supertux/data/sounds/empty.wav
___________________________________________________________________
Name: svn:mime-type
   + application/octet-stream

Modified: trunk/supertux/src/audio/sound_file.cpp
===================================================================
--- trunk/supertux/src/audio/sound_file.cpp	2008-05-09 10:17:38 UTC (rev 5448)
+++ trunk/supertux/src/audio/sound_file.cpp	2008-05-09 10:39:11 UTC (rev 5449)
@@ -398,9 +398,13 @@
 
   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 {




More information about the Supertux-Commit mailing list