Tags: patch

The attached patch *may* alleviate the sound allocation problem when no
sounds are found.  This is my first patch, and I haven't programmed for
about 2 years since college, so it may be completely wrong.

Best regards,

Nathan A. Stine
--- Sound.cxx	2005-04-23 15:53:29.000000000 -0400
+++ Sound.cxx.new	2007-09-03 14:55:52.000000000 -0400
@@ -64,6 +64,7 @@
 	// Load chunk files to ChunkMap
 	Mix_Chunk *chunk;
 	string File;
+	int found_sound = 0;
 	for (size_t i = 0; i < sounds.size(); i++) {
 		#ifndef NDEBUG
 		cout << "Loading " << sounds[i];
@@ -80,11 +81,16 @@
 		}
 		// If chunk is NULL there is no WAV available for this sound
 		if (!chunk) cout << "WARNING *** Unable to open " << sounds[i] << endl;
+		else found_sound = 1;
 		chunks[sounds[i]] = chunk;
 		#ifndef NDEBUG
 		cout << endl;
 		#endif
 	}
+	if (!found_sound) { // sound not needed
+		cleanup();
+		has_audio_available = 0;
+	}
 }
 
 void Sound::play( const char *file, int vol )

Reply via email to