Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions Game.Shared/PhysicsSound.cs
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public static void PlayImpactSounds(List<ImpactSound> 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();
Expand Down Expand Up @@ -136,7 +136,7 @@ public static void PlayBreakSounds(List<BreakSound> 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();
}
Expand Down
9 changes: 8 additions & 1 deletion Source.Common/SoundEmitterSystem/ISoundEmitterSystemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,14 @@ public void FromInterval(in Interval from) {
public struct SoundParametersInternal : IEquatable<SoundParametersInternal>
{
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) {
Expand Down
30 changes: 17 additions & 13 deletions Source.SoundEmitterSystem/SoundEmitterSystemBase.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ public struct SoundEntry : IEquatable<SoundEntry>
public bool Removed;
public bool IsOverride;

public SoundEntry() {
SoundParams = new();
}

public ReadOnlySpan<char> Name {
readonly get => name;
set {
Expand Down Expand Up @@ -615,31 +619,31 @@ public bool ModInit() {
public bool InitSoundInternalParameters(ReadOnlySpan<char> 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());

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());
Expand All @@ -653,24 +657,24 @@ public bool InitSoundInternalParameters(ReadOnlySpan<char> 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");

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()));
}
Expand Down
Loading