From f3a809d5fd1369a0ed74a2b370c44affb4f33160 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 14 Oct 2026 02:47:19 +0300 Subject: [PATCH 1/2] Fix soundscript entries missing the default sound parameters --- .../ISoundEmitterSystemBase.cs | 9 +++++- .../SoundEmitterSystemBase.cs | 30 +++++++++++-------- 2 files changed, 25 insertions(+), 14 deletions(-) diff --git a/Source.Common/SoundEmitterSystem/ISoundEmitterSystemBase.cs b/Source.Common/SoundEmitterSystem/ISoundEmitterSystemBase.cs index 1f80b0be7..f57318844 100644 --- a/Source.Common/SoundEmitterSystem/ISoundEmitterSystemBase.cs +++ b/Source.Common/SoundEmitterSystem/ISoundEmitterSystemBase.cs @@ -59,7 +59,14 @@ public void FromInterval(in Interval from) { public struct SoundParametersInternal : IEquatable { public SoundParametersInternal() { - + Channel = SoundEntityChannel.Auto; + SetVolume(VOL_NORM); + SetPitch(PITCH_NORM); + SetSoundLevel((float)Audio.SoundLevel.LvlNorm); + DelayMsec = 0; + bPlayToOwnerOnly = false; + bHadMissingWaveFiles = false; + bUsesGenderToken = false; } public void CopyFrom(in SoundParametersInternal src) { diff --git a/Source.SoundEmitterSystem/SoundEmitterSystemBase.cs b/Source.SoundEmitterSystem/SoundEmitterSystemBase.cs index 0f2dfedd3..7608d4e8c 100644 --- a/Source.SoundEmitterSystem/SoundEmitterSystemBase.cs +++ b/Source.SoundEmitterSystem/SoundEmitterSystemBase.cs @@ -38,6 +38,10 @@ public struct SoundEntry : IEquatable public bool Removed; public bool IsOverride; + public SoundEntry() { + SoundParams = new(); + } + public ReadOnlySpan Name { readonly get => name; set { @@ -615,19 +619,19 @@ public bool ModInit() { public bool InitSoundInternalParameters(ReadOnlySpan soundname, KeyValues kv, ref SoundParametersInternal parms) { KeyValues? key = kv.GetFirstSubKey(); while (key != null) { - if (0 == strcmp(key.Name, "channel")) { + if (0 == stricmp(key.Name, "channel")) { parms.ChannelFromString(key.GetString()); } - else if (0 == strcmp(key.Name, "volume")) { + else if (0 == stricmp(key.Name, "volume")) { parms.VolumeFromString(key.GetString()); } - else if (0 == strcmp(key.Name, "pitch")) { + else if (0 == stricmp(key.Name, "pitch")) { parms.PitchFromString(key.GetString()); } - else if (0 == strcmp(key.Name, "wave")) { + else if (0 == stricmp(key.Name, "wave")) { ExpandSoundNameMacros(ref parms, key.GetString()); } - else if (0 == strcmp(key.Name, "rndwave")) { + else if (0 == stricmp(key.Name, "rndwave")) { KeyValues? waves = key.GetFirstSubKey(); while (waves != null) { ExpandSoundNameMacros(ref parms, waves.GetString()); @@ -635,11 +639,11 @@ public bool InitSoundInternalParameters(ReadOnlySpan soundname, KeyValues waves = waves.GetNextKey(); } } - else if (0 == strcmp(key.Name, "attenuation") || 0 == strcmp(key.Name, "CompatibilityAttenuation")) { - if (key.GetString().StartsWith("SNDLVL_")) + else if (0 == stricmp(key.Name, "attenuation") || 0 == stricmp(key.Name, "CompatibilityAttenuation")) { + if (key.GetString().StartsWith("SNDLVL_", StringComparison.OrdinalIgnoreCase)) DevMsg($"SoundEmitterSystemBase.InitSoundInternalParameters: sound {soundname} has \"attenuation\" with {key.GetString()} value!\n"); - if (key.GetString().StartsWith("ATTN_")) + if (key.GetString().StartsWith("ATTN_", StringComparison.OrdinalIgnoreCase)) parms.SetSoundLevel((float)ATTN_TO_SNDLVL(TranslateAttenuation(key.GetString()))); else { Interval interval = Interval.Read(key.GetString()); @@ -653,7 +657,7 @@ public bool InitSoundInternalParameters(ReadOnlySpan soundname, KeyValues // Goldsrc compatibility mode.. feed the sndlevel value through the sound engine interface in such a way // that it can reconstruct the original sndlevel value and flag the sound as using Goldsrc attenuation. - bool bCompatibilityAttenuation = 0 == strcmp(key.Name, "CompatibilityAttenuation"); + bool bCompatibilityAttenuation = 0 == stricmp(key.Name, "CompatibilityAttenuation"); if (bCompatibilityAttenuation) { if (parms.GetSoundLevel().Range != 0) Warning($"CompatibilityAttenuation for sound {soundname} must have same start and end values.\n"); @@ -661,16 +665,16 @@ public bool InitSoundInternalParameters(ReadOnlySpan soundname, KeyValues parms.SetSoundLevel((float)SNDLEVEL_TO_COMPATIBILITY_MODE(parms.GetSoundLevel().Start)); } } - else if (0 == strcmp(key.Name, "soundlevel")) { - if (key.GetString().StartsWith("ATTN_")) + else if (0 == stricmp(key.Name, "soundlevel")) { + if (key.GetString().StartsWith("ATTN_", StringComparison.OrdinalIgnoreCase)) DevMsg($"SoundEmitterSystemBase.GetParametersForSound: sound {soundname} has \"soundlevel\" with {key.GetString()} value!\n"); parms.SoundLevelFromString(key.GetString()); } - else if (0 == strcmp(key.Name, "play_to_owner_only")) { + else if (0 == stricmp(key.Name, "play_to_owner_only")) { parms.SetOnlyPlayToOwner(key.GetInt() != 0); } - else if (0 == strcmp(key.Name, "delay_msec")) { + else if (0 == stricmp(key.Name, "delay_msec")) { // Don't allow negative delay parms.SetDelayMsec(Math.Max(0, key.GetInt())); } From 2d9385cf49af537452d5a70c66d2a1da0756c11e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=CE=B6eh=20Matt?= <5415177+ZehMatt@users.noreply.github.com> Date: Wed, 14 Oct 2026 03:04:56 +0300 Subject: [PATCH 2/2] Fix physics impact and break sounds never being emitted --- Game.Shared/PhysicsSound.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Game.Shared/PhysicsSound.cs b/Game.Shared/PhysicsSound.cs index 48de4b8b6..960af3b30 100644 --- a/Game.Shared/PhysicsSound.cs +++ b/Game.Shared/PhysicsSound.cs @@ -61,7 +61,7 @@ public static void PlayImpactSounds(List list) { ep.Pitch = parms.Pitch; ep.Origin = ref sound.Origin; - BaseEntity.EmitSound(filter, 0, ref ep, ref ep.SoundScriptHandle); + BaseEntity.EmitSound(filter, 0, in ep); } } list.Clear(); @@ -136,7 +136,7 @@ public static void PlayBreakSounds(List list) { ep.SoundLevel = parms.SoundLevel; ep.Pitch = parms.Pitch; ep.Origin = ref sound.Origin; - BaseEntity.EmitSound(filter, 0, ref ep, ref ep.SoundScriptHandle); + BaseEntity.EmitSound(filter, 0, in ep); } list.Clear(); }