From 5f8c99c3a1bf62dda88b2a28298665a97c00ebee Mon Sep 17 00:00:00 2001 From: hendricks266 Date: Sun, 25 Jun 2017 11:24:27 +0000 Subject: [PATCH] Let animsound value -1 stop all sounds. git-svn-id: https://svn.eduke32.com/eduke32@6284 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/anim.cpp | 17 +++++++++++++++-- source/duke3d/src/anim.h | 3 ++- source/duke3d/src/game.cpp | 2 +- 3 files changed, 18 insertions(+), 4 deletions(-) diff --git a/source/duke3d/src/anim.cpp b/source/duke3d/src/anim.cpp index aca3c1a2d..7ffb9a77d 100644 --- a/source/duke3d/src/anim.cpp +++ b/source/duke3d/src/anim.cpp @@ -36,6 +36,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #include "animsounds.h" +// animsound_t.sound +EDUKE32_STATIC_ASSERT(INT16_MAX >= MAXSOUNDS); + hashtable_t h_dukeanim = { 8, NULL }; dukeanim_t * g_animPtr; @@ -196,7 +199,12 @@ int32_t Anim_Play(const char *fn) 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++; } @@ -335,7 +343,12 @@ int32_t Anim_Play(const char *fn) 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++; } diff --git a/source/duke3d/src/anim.h b/source/duke3d/src/anim.h index 5270debe8..bcdd3e19e 100644 --- a/source/duke3d/src/anim.h +++ b/source/duke3d/src/anim.h @@ -24,7 +24,8 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. #define anim_h_ typedef struct { - uint16_t frame, sound; + uint16_t frame; + int16_t sound; } animsound_t; typedef struct diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 14ea5b4ee..3c04c4edd 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -5120,7 +5120,7 @@ static void parsedefinitions_game_animsounds(scriptfile *pScript, char * blockEn 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, scriptfile_getlinum(pScript, pScript->ltextptr));