From 0e135ff90105bee6fff111265da839e05147f3b5 Mon Sep 17 00:00:00 2001 From: Daniel Gibson Date: Mon, 31 Oct 2022 03:16:16 +0100 Subject: [PATCH] StartSoundShader() event: special-case for soundName "", refs #494 Some level scripts in d3xp (erebus4, erebus4, phobos2) use $entity.startSoundShader( "", SND_CHANNEL_BODY ); (or whatever channel) to stop the sound currently playing there. With s_playDefaultSound 1 that results in a beep.. Added a special case to that event implementation to call StopSound() instead when the soundName is "" (or NULL) --- d3xp/Entity.cpp | 8 ++++++++ game/Entity.cpp | 8 ++++++++ 2 files changed, 16 insertions(+) diff --git a/d3xp/Entity.cpp b/d3xp/Entity.cpp index ec636a6..c641fde 100644 --- a/d3xp/Entity.cpp +++ b/d3xp/Entity.cpp @@ -4171,6 +4171,14 @@ idEntity::Event_StartSoundShader ================ */ void idEntity::Event_StartSoundShader( const char *soundName, int channel ) { + // DG: at least some map scripts in d3xp seem to use $ent.startSoundShader( "", SND_CHANNEL_whatever ); + // to stop a playing sound. special-casing this to avoid playing beep sound (if s_playDefaultSound 1) + if ( soundName == NULL || soundName[0] == '\0' ) { + StopSound( (s_channelType)channel, false ); + idThread::ReturnFloat( 0.0f ); + return; + } + int length; StartSoundShader( declManager->FindSound( soundName ), (s_channelType)channel, 0, false, &length ); diff --git a/game/Entity.cpp b/game/Entity.cpp index 4842759..f72a664 100644 --- a/game/Entity.cpp +++ b/game/Entity.cpp @@ -4438,6 +4438,14 @@ idEntity::Event_StartSoundShader ================ */ void idEntity::Event_StartSoundShader( const char *soundName, int channel ) { + // DG: at least some map scripts in d3xp seem to use $ent.startSoundShader( "", SND_CHANNEL_whatever ); + // to stop a playing sound. special-casing this to avoid playing beep sound (if s_playDefaultSound 1) + if ( soundName == NULL || soundName[0] == '\0' ) { + StopSound( (s_channelType)channel, false ); + idThread::ReturnFloat( 0.0f ); + return; + } + int length; StartSoundShader( declManager->FindSound( soundName ), (s_channelType)channel, 0, false, &length );