Let animsound value -1 stop all sounds.

git-svn-id: https://svn.eduke32.com/eduke32@6284 1a8010ca-5511-0410-912e-c29ae57300e0
This commit is contained in:
hendricks266 2017-06-25 11:24:27 +00:00
parent 018bc98ecb
commit 5f8c99c3a1
3 changed files with 18 additions and 4 deletions

View file

@ -36,6 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#include "animsounds.h" #include "animsounds.h"
// animsound_t.sound
EDUKE32_STATIC_ASSERT(INT16_MAX >= MAXSOUNDS);
hashtable_t h_dukeanim = { 8, NULL }; hashtable_t h_dukeanim = { 8, NULL };
dukeanim_t * g_animPtr; dukeanim_t * g_animPtr;
@ -196,7 +199,12 @@ int32_t Anim_Play(const char *fn)
framenum++; framenum++;
while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == framenum) while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == framenum)
{ {
S_PlaySound(anim->sounds[soundidx].sound); int16_t sound = anim->sounds[soundidx].sound;
if (sound == -1)
FX_StopAllSounds();
else
S_PlaySound(sound);
soundidx++; soundidx++;
} }
@ -335,7 +343,12 @@ int32_t Anim_Play(const char *fn)
while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == (uint16_t)i) while (soundidx < anim->numsounds && anim->sounds[soundidx].frame == (uint16_t)i)
{ {
S_PlaySound(anim->sounds[soundidx].sound); int16_t sound = anim->sounds[soundidx].sound;
if (sound == -1)
FX_StopAllSounds();
else
S_PlaySound(sound);
soundidx++; soundidx++;
} }

View file

@ -24,7 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
#define anim_h_ #define anim_h_
typedef struct { typedef struct {
uint16_t frame, sound; uint16_t frame;
int16_t sound;
} animsound_t; } animsound_t;
typedef struct typedef struct

View file

@ -5120,7 +5120,7 @@ static void parsedefinitions_game_animsounds(scriptfile *pScript, char * blockEn
lastFrameNum = frameNum; lastFrameNum = frameNum;
if ((unsigned)soundNum >= MAXSOUNDS) if ((unsigned)soundNum >= MAXSOUNDS && soundNum != -1)
{ {
initprintf("Error: sound number #%d invalid on line %s:%d\n", soundNum, pScript->filename, initprintf("Error: sound number #%d invalid on line %s:%d\n", soundNum, pScript->filename,
scriptfile_getlinum(pScript, pScript->ltextptr)); scriptfile_getlinum(pScript, pScript->ltextptr));