- Blood: Don't let Caleb's voice overlap if spamming the use key on a locked door.

* Fixes #113.
This commit is contained in:
Mitchell Richters 2020-11-07 15:13:45 +11:00
parent 4ef0d20e0e
commit 01c494e29d
3 changed files with 34 additions and 4 deletions

View file

@ -1493,14 +1493,20 @@ void ProcessInput(PLAYER *pPlayer)
if (pXSector->locked && pPlayer == gMe)
{
viewSetMessage(GStrings("TXTB_LOCKED"));
sndStartSample(3062, 255, 2, 0);
auto snd = 3062;
if (sndCheckPlaying(snd))
sndStopSample(snd);
sndStartSample(snd, 255, 2, 0);
}
if (!key || pPlayer->hasKey[key])
trTriggerSector(a2, pXSector, kCmdSpritePush);
else if (pPlayer == gMe)
{
viewSetMessage(GStrings("TXTB_KEY"));
sndStartSample(3063, 255, 2, 0);
auto snd = 3063;
if (sndCheckPlaying(snd))
sndStopSample(snd);
sndStartSample(snd, 255, 2, 0);
}
}
break;
@ -1511,14 +1517,20 @@ void ProcessInput(PLAYER *pPlayer)
if (pXWall->locked && pPlayer == gMe)
{
viewSetMessage(GStrings("TXTB_LOCKED"));
sndStartSample(3062, 255, 2, 0);
auto snd = 3062;
if (sndCheckPlaying(snd))
sndStopSample(snd);
sndStartSample(snd, 255, 2, 0);
}
if (!key || pPlayer->hasKey[key])
trTriggerWall(a2, pXWall, kCmdWallPush);
else if (pPlayer == gMe)
{
viewSetMessage(GStrings("TXTB_KEY"));
sndStartSample(3063, 255, 2, 0);
auto snd = 3063;
if (sndCheckPlaying(snd))
sndStopSample(snd);
sndStartSample(snd, 255, 2, 0);
}
break;
}

View file

@ -144,6 +144,22 @@ void SoundCallback(intptr_t val)
pChannel->TotalKills = 0;
}
bool sndCheckPlaying(unsigned int nSound)
{
auto snd = soundEngine->FindSoundByResID(nSound);
return snd > 0 ? soundEngine->GetSoundPlayingInfo(SOURCE_Any, nullptr, snd) : false;
}
void sndStopSample(unsigned int nSound)
{
auto snd = soundEngine->FindSoundByResID(nSound);
if (snd > 0)
{
soundEngine->StopSoundID(snd);
}
}
void sndStartSample(const char *pzSound, int nVolume, int nChannel)
{
if (!SoundEnabled())

View file

@ -45,6 +45,8 @@ struct SFX
};
int sndGetRate(int format);
bool sndCheckPlaying(unsigned int nSound);
void sndStopSample(unsigned int nSound);
void sndStartSample(const char *pzSound, int nVolume, int nChannel = -1);
void sndStartSample(unsigned int nSound, int nVolume, int nChannel = -1, bool bLoop = false, EChanFlags soundflags = CHANF_NONE);
void sndStartWavID(unsigned int nSound, int nVolume, int nChannel = -1);