From d77c74596cfc678072a5280fbc4717ab040214e4 Mon Sep 17 00:00:00 2001 From: avolkov Date: Wed, 16 Mar 2005 05:48:32 +0000 Subject: [PATCH] Misc sfx bug and semantical fixes git-svn-id: svn://svn.code.sf.net/p/sc2/code/trunk@1578 8092fc87-c524-0410-9efc-e669fe64eaf9 --- sc2/src/sc2code/libs/sndlib.h | 6 ++++++ sc2/src/sc2code/libs/sound/sound.h | 2 +- sc2/src/sc2code/sounds.c | 19 ++++++------------- 3 files changed, 13 insertions(+), 14 deletions(-) diff --git a/sc2/src/sc2code/libs/sndlib.h b/sc2/src/sc2code/libs/sndlib.h index 8173f4ab4..852d5b137 100644 --- a/sc2/src/sc2code/libs/sndlib.h +++ b/sc2/src/sc2code/libs/sndlib.h @@ -60,6 +60,12 @@ extern BOOLEAN DestroyMusic (MUSIC_REF MusicRef); #define MAX_CHANNELS 8 #define MAX_VOLUME 255 +#define FIRST_SFX_CHANNEL 0 +#define MIN_FX_CHANNEL 1 +#define NUM_FX_CHANNELS 4 +#define LAST_SFX_CHANNEL (MIN_FX_CHANNEL + NUM_FX_CHANNELS - 1) +#define NUM_SFX_CHANNELS (MIN_FX_CHANNEL + NUM_FX_CHANNELS) + extern void PLRPlaySong (MUSIC_REF MusicRef, BOOLEAN Continuous, BYTE Priority); extern void PLRStop (MUSIC_REF MusicRef); diff --git a/sc2/src/sc2code/libs/sound/sound.h b/sc2/src/sc2code/libs/sound/sound.h index f8ef1abba..807e8e398 100644 --- a/sc2/src/sc2code/libs/sound/sound.h +++ b/sc2/src/sc2code/libs/sound/sound.h @@ -26,7 +26,7 @@ #define FIRST_SFX_SOURCE 0 -#define LAST_SFX_SOURCE 4 +#define LAST_SFX_SOURCE (FIRST_SFX_SOURCE + NUM_SFX_CHANNELS - 1) #define MUSIC_SOURCE (LAST_SFX_SOURCE + 1) #define SPEECH_SOURCE (MUSIC_SOURCE + 1) #define NUM_SOUNDSOURCES (SPEECH_SOURCE + 1) diff --git a/sc2/src/sc2code/sounds.c b/sc2/src/sc2code/sounds.c index c35c3b0b3..09cfe857c 100644 --- a/sc2/src/sc2code/sounds.c +++ b/sc2/src/sc2code/sounds.c @@ -23,7 +23,7 @@ SOUND MenuSounds; SOUND GameSounds; #define MAX_SOUNDS 8 -static BYTE num_sounds; +static BYTE num_sounds = 0; static SOUND sound_buf[MAX_SOUNDS]; static ELEMENTPTR sound_posobj[MAX_SOUNDS]; @@ -32,12 +32,10 @@ void PlaySound (SOUND S, SoundPosition Pos, ELEMENTPTR PositionalObject, BYTE Priority) { -#define MIN_FX_CHANNEL 1 -#define NUM_FX_CHANNELS 4 /* obviously number of channels is assumed to be at least 5 */ BYTE chan, c; static BYTE lru_channel[NUM_FX_CHANNELS] = {0, 1, 2, 3}; - static SOUND channel[NUM_FX_CHANNELS]; + static SOUND channel[NUM_FX_CHANNELS] = {0, 0, 0, 0}; if (S == 0) return; @@ -134,14 +132,12 @@ NotPositional (void) /* Updates positional sound effects */ void -UpdateSoundPositions (void) { +UpdateSoundPositions (void) +{ COUNT i; - for (i = 0; i <= NUM_FX_CHANNELS; ++i) + for (i = FIRST_SFX_CHANNEL; i <= LAST_SFX_CHANNEL; ++i) { - // XXX: (possible BUG): shouldn't the "<=" be "<" - // TODO: investigate - SvdB - ELEMENTPTR posobj; if (!ChannelPlaying(i)) continue; @@ -181,11 +177,8 @@ RemoveSoundsForObject (ELEMENTPTR PosObj) { int i; - for (i = 0; i <= NUM_FX_CHANNELS; ++i) + for (i = FIRST_SFX_CHANNEL; i <= LAST_SFX_CHANNEL; ++i) { - // XXX: (possible BUG): shouldn't the "<=" be "<" - // TODO: investigate - SvdB - if (GetPositionalObject (i) == PosObj) SetPositionalObject (i, NULL); }