From 10c9976e39536bbb4f9be4899f067c6390d9462d Mon Sep 17 00:00:00 2001 From: Bill Kendrick Date: Sun, 15 Oct 2017 11:03:40 -0700 Subject: [PATCH] indent playsound.c playsound.h --- src/playsound.c | 83 ++++++++++++++++++++++++------------------------- src/playsound.h | 3 +- 2 files changed, 42 insertions(+), 44 deletions(-) diff --git a/src/playsound.c b/src/playsound.c index 4238bdabf..3bed4d732 100644 --- a/src/playsound.c +++ b/src/playsound.c @@ -33,55 +33,54 @@ int mute; int use_sound = 1; static int old_sound[4] = { -1, -1, -1, -1 }; -void playsound(SDL_Surface * screen, int chan, int s, int override, int x, - int y) +void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y) { #ifndef NOSOUND int left, dist; if (!mute && use_sound && s != SND_NONE) - { - if (override || !Mix_Playing(chan)) { - Mix_PlayChannel(chan, sounds[s], 0); + if (override || !Mix_Playing(chan)) + { + Mix_PlayChannel(chan, sounds[s], 0); - old_sound[chan] = s; + old_sound[chan] = s; + } + + if (old_sound[chan] == s) + { + if (y == SNDDIST_NEAR) + dist = 0; + else + { + if (y < 0) + y = 0; + else if (y >= screen->h - 1) + y = screen->h - 1; + + dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1); + } + + if (x == SNDPOS_LEFT) + left = 255 - dist; + else if (x == SNDPOS_CENTER) + left = (255 - dist) / 2; + else if (x == SNDPOS_RIGHT) + left = 0; + else + { + if (x < 0) + x = 0; + else if (x >= screen->w) + x = screen->w - 1; + + left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1); + } + + + + Mix_SetPanning(chan, left, (255 - dist) - left); + } } - - if (old_sound[chan] == s) - { - if (y == SNDDIST_NEAR) - dist = 0; - else - { - if (y < 0) - y = 0; - else if (y >= screen->h - 1) - y = screen->h - 1; - - dist = (255 * ((screen->h - 1) - y)) / (screen->h - 1); - } - - if (x == SNDPOS_LEFT) - left = 255 - dist; - else if (x == SNDPOS_CENTER) - left = (255 - dist) / 2; - else if (x == SNDPOS_RIGHT) - left = 0; - else - { - if (x < 0) - x = 0; - else if (x >= screen->w) - x = screen->w - 1; - - left = ((255 - dist) * ((screen->w - 1) - x)) / (screen->w - 1); - } - - - - Mix_SetPanning(chan, left, (255 - dist) - left); - } - } #endif } diff --git a/src/playsound.h b/src/playsound.h index fe17dd43b..d6f39a822 100644 --- a/src/playsound.h +++ b/src/playsound.h @@ -37,7 +37,6 @@ extern Mix_Chunk *sounds[NUM_SOUNDS]; extern int mute, use_sound; -void playsound(SDL_Surface * screen, int chan, int s, int override, int x, - int y); +void playsound(SDL_Surface * screen, int chan, int s, int override, int x, int y); #endif