I'm ok with the fact that old mods are not compatible, but completely exiting because a sound file isn't found?! come on! do you expect windows to BSOD you when it can't find a sound for an event? No, ofcourse not, you expect it to write a warning to the logfile, and then go on without it!
So yeah, I tracked it down quite quickly, and this is what I came up with. Basically what it changes is this:
- Loading a non-existing sound
Previous behaviour: MessageBox and disable sound altogether.
New behaviour: if possible, display an error in the info-log, keeps sound enabled. - Getting ID for non-existing sound
Previous behaviour: if loading failed, returns the number associated with a non-existant wav-file. Basically: random number
New behaviour: return id 0 if sound is not found and can not be loaded. - Getting buffer of non-existing or invalid sound id
Previous behaviour: start doing stuff with an uninitialized pointer -> crashy!
New behaviour: return -1 if an invalid ID

As I am unaware of how to properly send in a patch, and cannot find an attach function on this forum, I am just going to paste the .diff file here:
Code: Select all
Index: System/Platform/Win/DxSound.cpp
===================================================================
--- System/Platform/Win/DxSound.cpp (revision 1716)
+++ System/Platform/Win/DxSound.cpp (working copy)
@@ -130,9 +130,9 @@
// Create the sound buffer object from the wave file data
if( !CreateStaticBuffer(name.c_str()) )
- {
- MessageBox(0,"Couldnt create sound buffer","Sound error",0);
- noSound=true;
+ {
+ if (info)
+ (*info) << "no such sound: " << name.c_str() << "\n";
return -1;
}
@@ -159,13 +159,15 @@
InitFile(name);
si=waveid.find(name);
}
- int ret=si->second;
+ int ret=(si!=waveid.end())?si->second:0;
POP_CODE_MODE;
return ret;
}
int CDxSound::GetBuf(int id,float volume)
{
+ if(id<=0 || id>=loadedSounds.size())
+ return -1;
SoundInfo* s=loadedSounds[id];
int num;
if(s->freebufs.empty()){
@@ -348,7 +350,7 @@
buf = new Uint8[fileSize];
file.Read(buf, fileSize);
} else {
- handleerror(0, "Couldnt open wav file",path.c_str(),0);
+ //handleerror(0, "Couldnt open wav file",path.c_str(),0);
return false;
}
// Read the WAV file
