From 06ac4f88b9f47e60e655da62ddf5988b826ae265 Mon Sep 17 00:00:00 2001 From: terminx Date: Sat, 15 Dec 2018 01:39:25 +0000 Subject: [PATCH] This fixes S_CheckSoundPlaying() and makes CON_IFSOUND work correctly in scripts that run during menus. These changes together fix the exchange between Duke and Lani at the end of episode 3 of Duke3D. git-svn-id: https://svn.eduke32.com/eduke32@7279 1a8010ca-5511-0410-912e-c29ae57300e0 --- source/duke3d/src/actors.cpp | 6 +++--- source/duke3d/src/game.cpp | 1 + source/duke3d/src/gameexec.cpp | 10 +++++----- source/duke3d/src/net.cpp | 3 +-- source/duke3d/src/screens.cpp | 2 +- source/duke3d/src/sounds.cpp | 6 +++--- source/duke3d/src/sounds.h | 2 +- 7 files changed, 15 insertions(+), 15 deletions(-) diff --git a/source/duke3d/src/actors.cpp b/source/duke3d/src/actors.cpp index 2b584ae83..40a66f641 100644 --- a/source/duke3d/src/actors.cpp +++ b/source/duke3d/src/actors.cpp @@ -3090,7 +3090,7 @@ ACTOR_STATIC void G_MoveWeapons(void) case COOLEXPLOSION1__STATIC: { if (pSprite->picnum == COOLEXPLOSION1) - if (!S_CheckSoundPlaying(spriteNum, WIERDSHOT_FLY)) + if (!S_CheckSoundPlaying(WIERDSHOT_FLY)) A_PlaySound(WIERDSHOT_FLY, spriteNum); int spriteXvel = pSprite->xvel; @@ -5227,7 +5227,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5 } else */ - if (!S_CheckSoundPlaying(spriteNum,ITEM_SPLASH)) + if (!S_CheckSoundPlaying(ITEM_SPLASH)) A_PlaySound(ITEM_SPLASH,spriteNum); } if (pData[0] == 3) @@ -6020,7 +6020,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3 { if ((pSector->floorstat&1) == 0 && (pSector->ceilingstat&1) == 0) { - if (!S_CheckSoundPlaying(spriteNum,actor[spriteNum].lastv.x)) + if (!S_CheckSoundPlaying(actor[spriteNum].lastv.x)) A_PlaySound(actor[spriteNum].lastv.x,spriteNum); } else if (ud.monsters_off == 0 && pSector->floorpal == 0 && (pSector->floorstat&1) && rnd(8)) diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index 9ed0d6e3f..21c769393 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -6725,6 +6725,7 @@ MAIN_LOOP_RESTART: else #endif { + S_Cleanup(); MUSIC_Update(); G_HandleLocalKeys(); } diff --git a/source/duke3d/src/gameexec.cpp b/source/duke3d/src/gameexec.cpp index fe38d2db6..76cabb631 100644 --- a/source/duke3d/src/gameexec.cpp +++ b/source/duke3d/src/gameexec.cpp @@ -3143,7 +3143,7 @@ badindex: CON_ERRPRINTF("invalid sound %d\n", vm.pUSprite->yvel); continue; } - if (!S_CheckSoundPlaying(vm.spriteNum, vm.pSprite->yvel)) + if (!S_CheckSoundPlaying(vm.pSprite->yvel)) A_PlaySound(vm.pSprite->yvel, vm.spriteNum); continue; @@ -3206,7 +3206,7 @@ badindex: CON_ERRPRINTF("invalid sound %d\n", (int32_t)*insptr); continue; } - VM_CONDITIONAL(S_CheckSoundPlaying(vm.spriteNum, *insptr)); + VM_CONDITIONAL(S_CheckSoundPlaying(*insptr)); // VM_DoConditional(SoundOwner[*insptr][0].ow == vm.spriteNum); continue; @@ -4229,7 +4229,7 @@ badindex: switch (tw) { case CON_SOUNDONCE: - if (!S_CheckSoundPlaying(vm.spriteNum, soundNum)) + if (!S_CheckSoundPlaying(soundNum)) { fallthrough__; case CON_SOUND: A_PlaySound((int16_t)soundNum, vm.spriteNum); @@ -4237,10 +4237,10 @@ badindex: continue; case CON_GLOBALSOUND: A_PlaySound((int16_t)soundNum, g_player[screenpeek].ps->i); continue; case CON_STOPSOUND: - if (S_CheckSoundPlaying(vm.spriteNum, soundNum)) + if (S_CheckSoundPlaying(soundNum)) S_StopSound((int16_t)soundNum); continue; - case CON_SCREENSOUND: A_PlaySound(soundNum, -1); continue; + case CON_SCREENSOUND: S_PlaySound(soundNum); continue; } } continue; diff --git a/source/duke3d/src/net.cpp b/source/duke3d/src/net.cpp index 5b78390ab..558658384 100644 --- a/source/duke3d/src/net.cpp +++ b/source/duke3d/src/net.cpp @@ -555,7 +555,6 @@ static void Net_DeleteAllScratchPadSprites() Net_InitScratchPadSpriteList(); } - static void Net_Error_Disconnect(const char* message) { OSD_Printf("Net_Error_Disconnect: %s\n", message); @@ -4769,7 +4768,7 @@ void Net_GetPackets(void) { timerUpdate(); MUSIC_Update(); - S_Update(); + S_Cleanup(); G_HandleSpecialKeys(); diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 3e52a0090..14f97b38a 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -64,7 +64,7 @@ static int32_t G_PlaySoundWhileNoInput(int32_t soundnum) { S_PlaySound(soundnum); I_ClearAllInput(); - while (S_CheckSoundPlaying(-1, soundnum)) + while (S_CheckSoundPlaying(soundnum)) { G_HandleAsync(); if (I_CheckAllInput()) diff --git a/source/duke3d/src/sounds.cpp b/source/duke3d/src/sounds.cpp index c21c3ebb7..b3c46e3d0 100644 --- a/source/duke3d/src/sounds.cpp +++ b/source/duke3d/src/sounds.cpp @@ -970,8 +970,8 @@ bool A_CheckAnySoundPlaying(int spriteNum) return 0; } -bool S_CheckSoundPlaying(int spriteNum, int soundNum) +bool S_CheckSoundPlaying(int soundNum) { - if (EDUKE32_PREDICT_FALSE((unsigned)soundNum > (unsigned)g_highestSoundIdx)) return 0; - return (spriteNum == -1) ? (g_soundlocks[soundNum] > 200) : (g_sounds[soundNum].num != 0); + if (EDUKE32_PREDICT_FALSE((unsigned)soundNum > (unsigned)g_highestSoundIdx)) return false; + return (g_sounds[soundNum].num != 0); } diff --git a/source/duke3d/src/sounds.h b/source/duke3d/src/sounds.h index 6bd39f62e..94bc3b45d 100644 --- a/source/duke3d/src/sounds.h +++ b/source/duke3d/src/sounds.h @@ -67,7 +67,7 @@ bool A_CheckSoundPlaying(int spriteNum,int soundNum); int A_PlaySound(int soundNum, int spriteNum); void S_Callback(uint32_t num); bool A_CheckAnySoundPlaying(int spriteNum); -bool S_CheckSoundPlaying(int spriteNum,int soundNum); +bool S_CheckSoundPlaying(int soundNum); void S_Cleanup(void); void S_ClearSoundLocks(void); int32_t S_LoadSound(uint32_t num);