Adds safety check to SoundAsset's playSound so if we don't have a source, it doesn't crash

Adds logic to SoundAsset's load sound to 'nudge' the SFX system to load the required data for first use
Shifts SimSoundAssetEvent constructor to utilize assetId instead of raw asset so we can safely fail if for whatever reason we end up default constructor'ing blanks
Standardizes the shapeImage playList lookup a bit into a common function and ensures that on packet receive we force an update of the state's sound
This commit is contained in:
JeffR 2022-06-03 02:04:39 -05:00
parent 956bd51d6d
commit 943cf8351b
6 changed files with 43 additions and 27 deletions

View file

@ -228,6 +228,9 @@ bool SoundAsset::loadSound()
mSFXProfile.setDescription(&mProfileDesc);
mSFXProfile.setSoundFileName(mSoundPath);
mSFXProfile.setPreload(mPreload);
//give it a nudge to preload if required
mSFXProfile.getBuffer();
}
}
@ -341,7 +344,10 @@ DefineEngineMethod(SoundAsset, playSound, S32, (Point3F position), (Point3F::Zer
MatrixF transform;
transform.setPosition(position);
SFXSource* source = SFX->playOnce(object->getSfxProfile(), &transform, NULL, -1);
return source->getId();
if(source)
return source->getId();
else
return 0;
}
else
return 0;