From 45027e4620d55cbe2897a6e9f03249ce71fb4fc8 Mon Sep 17 00:00:00 2001 From: Randy Heit Date: Mon, 7 May 2012 01:16:56 +0000 Subject: [PATCH] - Added SNDINFO $attenuation command. This multiplies the attenuation passed to S_Sound. e.g. $attenuation Boom 0 Will make the "Boom" sound play with 0 attenuation, or in other words, at full volume throughout the level. SVN r3629 (trunk) --- src/s_advsound.cpp | 14 ++++++++++++++ src/s_sound.cpp | 5 +++++ src/s_sound.h | 2 +- 3 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/s_advsound.cpp b/src/s_advsound.cpp index a381e91cde..cea8950ac8 100644 --- a/src/s_advsound.cpp +++ b/src/s_advsound.cpp @@ -152,6 +152,7 @@ enum SICommands SI_Volume, SI_MusicAlias, SI_EDFOverride, + SI_Attenuation, }; // Blood was a cool game. If Monolith ever releases the source for it, @@ -247,6 +248,7 @@ static const char *SICommandStrings[] = "$volume", "$musicalias", "$edfoverride", + "$attenuation", NULL }; @@ -501,6 +503,7 @@ int S_AddSoundLump (const char *logicalname, int lump) newsfx.next = 0; newsfx.index = 0; newsfx.Volume = 1; + newsfx.Attenuation = 1; newsfx.PitchMask = CurrentPitchMask; newsfx.NearLimit = 2; newsfx.LimitRange = 256*256; @@ -1204,6 +1207,17 @@ static void S_AddSNDINFO (int lump) } break; + case SI_Attenuation: { + // $attenuation + int sfx; + + sc.MustGetString(); + sfx = S_FindSoundTentative(sc.String); + sc.MustGetFloat(); + S_sfx[sfx].Attenuation = (float)sc.Float; + } + break; + case SI_Rolloff: { // $rolloff *| [linear|log|custom] // Using * for the name makes it the default for sounds that don't specify otherwise. diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 212658a133..c2e3b0f766 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -901,6 +901,8 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO } else if (sfx->bRandomHeader) { + // Random sounds attenuate based on the original (random) sound as well as the chosen one. + attenuation *= sfx->Attenuation; sound_id = FSoundID(S_PickReplacement (sound_id)); if (near_limit < 0) { @@ -928,6 +930,9 @@ static FSoundChan *S_StartSound(AActor *actor, const sector_t *sec, const FPolyO sfx = &S_sfx[sound_id]; } + // Attenuate the attenuation based on the sound. + attenuation *= sfx->Attenuation; + // The passed rolloff overrides any sound-specific rolloff. if (forcedrolloff != NULL && forcedrolloff->MinDistance != 0) { diff --git a/src/s_sound.h b/src/s_sound.h index d82e273ac2..84881862ca 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -41,7 +41,6 @@ struct sfxinfo_t int lumpnum; // lump number of sfx unsigned int next, index; // [RH] For hashing -// unsigned int frequency; // [RH] Preferred playback rate float Volume; BYTE PitchMask; @@ -65,6 +64,7 @@ struct sfxinfo_t enum { NO_LINK = 0xffffffff }; FRolloffInfo Rolloff; + float Attenuation; // Multiplies the attenuation passed to S_Sound. }; // Rolloff types