]> git.xonotic.org Git - xonotic/darkplaces.git/commitdiff
Underwater sound filter: fix warning and code style, add function docstring
authorJames O'Neill <hemebond@gmail.com>
Mon, 4 Mar 2024 03:24:07 +0000 (12:24 +0900)
committerbones_was_here <bones_was_here@xonotic.au>
Sun, 10 Mar 2024 15:46:27 +0000 (01:46 +1000)
snd_main.h
snd_mix.c

index 23541bcc15bcaaddee3cc069f629d7d62374ea6f..1ce9e1693ebf1c5a4ef31d0be142ebce90e61ac6 100644 (file)
@@ -153,6 +153,8 @@ extern qbool simsound;
 //         Architecture-independent functions
 // ====================================================================
 
+void S_SetUnderwaterIntensity(void);
+
 void S_MixToBuffer(void *stream, unsigned int frames);
 
 qbool S_LoadSound (struct sfx_s *sfx, qbool complain);
index 499c16f487a40bb9336d9fcaf22de9d949f60008..b83c3ae74373782b643d50dbfb7891eb64546dd1 100644 (file)
--- a/snd_mix.c
+++ b/snd_mix.c
@@ -309,19 +309,25 @@ static void S_ConvertPaintBuffer(portable_sampleframe_t *painted_ptr, void *rb_p
        }
 }
 
+
+
 /*
 ===============================================================================
 
 UNDERWATER EFFECT
 
+Muffles the intensity of sounds when the player is underwater
+
 ===============================================================================
 */
 
-static struct {
+static struct
+{
        float   intensity;
        float   alpha;
        float   accum[SND_LISTENERS];
-} underwater = {0.f, 1.f, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}};
+}
+underwater = {0.f, 1.f, {0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f, 0.f}};
 
 void S_SetUnderwaterIntensity(void)
 {
@@ -353,22 +359,25 @@ static void S_UnderwaterFilter(int endtime)
 {
        int i;
        int sl;
-       if (!underwater.intensity) {
-               if (endtime > 0) {
-                       for (sl = 0; sl < SND_LISTENERS; sl++) {
+
+       if (!underwater.intensity)
+       {
+               if (endtime > 0)
+                       for (sl = 0; sl < SND_LISTENERS; sl++)
                                underwater.accum[sl] = paintbuffer[endtime-1].sample[sl];
-                       }
-               }
                return;
        }
-       for (i = 0; i < endtime; i++) {
-               for (sl = 0; sl < SND_LISTENERS; sl++) {
+
+       for (i = 0; i < endtime; i++)
+               for (sl = 0; sl < SND_LISTENERS; sl++)
+               {
                        underwater.accum[sl] += underwater.alpha * (paintbuffer[i].sample[sl] - underwater.accum[sl]);
                        paintbuffer[i].sample[sl] = underwater.accum[sl];
                }
-       }
 }
 
+
+
 /*
 ===============================================================================