mirror of
https://github.com/DrBeef/Raze.git
synced 2025-02-20 18:52:43 +00:00
- sound API
This commit is contained in:
parent
97b4116f28
commit
07ad50d97c
7 changed files with 25 additions and 41 deletions
|
@ -207,9 +207,9 @@ void InitPlayerInventory(short nPlayer)
|
|||
PlayerList[nPlayer].nPlayerColor = pixels[tileWidth(nPlayer + kTile3571) * tileHeight(nPlayer + kTile3571) / 2];
|
||||
}
|
||||
|
||||
short GetPlayerFromSprite(short nSprite)
|
||||
short GetPlayerFromActor(DExhumedActor* pActor)
|
||||
{
|
||||
auto pSprite = &sprite[nSprite];
|
||||
auto pSprite = &pActor->s();
|
||||
return RunData[pSprite->owner].nObjIndex;
|
||||
}
|
||||
|
||||
|
|
|
@ -128,11 +128,7 @@ extern DExhumedActor* nNetStartSprite[kMaxPlayers];
|
|||
extern short nNetStartSprites;
|
||||
extern short nCurStartSprite;
|
||||
|
||||
short GetPlayerFromSprite(short nSprite);
|
||||
short GetPlayerFromActor(DExhumedActor* actor)
|
||||
{
|
||||
return GetPlayerFromSprite(actor->GetSpriteIndex());
|
||||
}
|
||||
short GetPlayerFromActor(DExhumedActor* actor);
|
||||
void SetPlayerMummified(int nPlayer, int bIsMummified);
|
||||
int AddAmmo(int nPlayer, int nWeapon, int nAmmoAmount);
|
||||
void ShootStaff(int nPlayer);
|
||||
|
|
|
@ -437,7 +437,7 @@ int seq_GetFrameSound(int val, int edx)
|
|||
return FrameSound[SeqBase[val] + edx];
|
||||
}
|
||||
|
||||
void seq_MoveSequence(short nSprite, short nSeq, short bx)
|
||||
void seq_MoveSequence(DExhumedActor* actor, short nSeq, short bx)
|
||||
{
|
||||
assert(nSeq >= 0); // TEMP
|
||||
|
||||
|
@ -446,8 +446,8 @@ void seq_MoveSequence(short nSprite, short nSeq, short bx)
|
|||
return;
|
||||
}
|
||||
|
||||
if (nSprite > -1) {
|
||||
D3PlayFX(nSound, nSprite);
|
||||
if (actor) {
|
||||
D3PlayFX(nSound, actor);
|
||||
}
|
||||
else {
|
||||
PlayLocalSound(nSound, 0);
|
||||
|
|
|
@ -133,11 +133,7 @@ extern short FrameBase[];
|
|||
|
||||
void seq_LoadSequences();
|
||||
int seq_GetFrameSound(int val, int edx);
|
||||
void seq_MoveSequence(short nSprite, short nSeq, short bx);
|
||||
inline void seq_MoveSequence(DExhumedActor* actor, short nSeq, short bx)
|
||||
{
|
||||
seq_MoveSequence(actor->GetSpriteIndex(), nSeq, bx);
|
||||
}
|
||||
void seq_MoveSequence(DExhumedActor* actor, short nSeq, short bx);
|
||||
|
||||
int seq_GetSeqPicnum2(short nSeq, short nFrame);
|
||||
int seq_GetSeqPicnum(short nSeq, short edx, short ebx);
|
||||
|
|
|
@ -557,23 +557,23 @@ void GameInterface::UpdateSounds()
|
|||
int soundx, soundy, soundz;
|
||||
short soundsect;
|
||||
|
||||
void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanflags, int sprflags)
|
||||
void PlayFX2(unsigned short nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags, int sprflags)
|
||||
{
|
||||
if (!SoundEnabled()) return;
|
||||
if ((nSound&0x1ff) >= kMaxSounds || !soundEngine->isValidSoundId((nSound & 0x1ff)+1))
|
||||
{
|
||||
Printf("PlayFX2: Invalid sound nSound == %i, nSprite == %i\n", nSound, nSprite);
|
||||
Printf("PlayFX2: Invalid sound nSound == %i\n", nSound);
|
||||
return;
|
||||
}
|
||||
|
||||
bool fullvol = false, hiprio = false;
|
||||
if (nSprite >= 0)
|
||||
if (pActor)
|
||||
{
|
||||
fullvol = (sprflags & 0x2000) != 0;
|
||||
hiprio = (sprflags & 0x4000) != 0;
|
||||
soundx = sprite[nSprite].x;
|
||||
soundy = sprite[nSprite].y;
|
||||
soundz = sprite[nSprite].z;
|
||||
soundx = pActor->s().x;
|
||||
soundy = pActor->s().y;
|
||||
soundz = pActor->s().z;
|
||||
}
|
||||
|
||||
int nVolume = 255;
|
||||
|
@ -584,7 +584,7 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanfla
|
|||
|
||||
int prio = 0;
|
||||
if (forcePlay || midprio) prio = 1000;
|
||||
else if (nSprite != -1 && hiprio) prio = 2000;
|
||||
else if (pActor != nullptr && hiprio) prio = 2000;
|
||||
|
||||
short v10 = (nSound&0xe00)>>9;
|
||||
nSound &= 0x1ff;
|
||||
|
@ -602,16 +602,16 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanfla
|
|||
{
|
||||
bool res = soundEngine->EnumerateChannels([=](FSoundChan* chan)
|
||||
{
|
||||
if (chan->SourceType == SOURCE_Actor && nSprite != -1)
|
||||
if (chan->SourceType == SOURCE_Actor && pActor != nullptr)
|
||||
{
|
||||
if (prio >= chan->UserData)
|
||||
{
|
||||
if (chan->SoundID == nSound + 1)
|
||||
{
|
||||
if (!allowMultiple && &sprite[nSprite] == chan->Source)
|
||||
if (!allowMultiple && &pActor->s() == chan->Source)
|
||||
return 1;
|
||||
}
|
||||
else if (&sprite[nSprite] == chan->Source)
|
||||
else if (&pActor->s() == chan->Source)
|
||||
{
|
||||
soundEngine->StopChannel(chan);
|
||||
return -1;
|
||||
|
@ -619,7 +619,7 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanfla
|
|||
}
|
||||
|
||||
}
|
||||
else if (chan->SourceType == SOURCE_Unattached && nSprite == -1)
|
||||
else if (chan->SourceType == SOURCE_Unattached && pActor != nullptr)
|
||||
{
|
||||
if (chan->SoundID == nSound + 1)
|
||||
{
|
||||
|
@ -633,9 +633,9 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanfla
|
|||
if (res) return;
|
||||
}
|
||||
FSoundChan* chan = nullptr;
|
||||
if (nSprite >= 0)
|
||||
if (pActor != nullptr)
|
||||
{
|
||||
chan = soundEngine->StartSound(SOURCE_Actor, &sprite[nSprite], nullptr, CHAN_BODY, chanflags| CHANF_OVERLAP, nSound+1, nVolume / 255.f,fullvol? 0.5f : ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f);
|
||||
chan = soundEngine->StartSound(SOURCE_Actor, &pActor->s(), nullptr, CHAN_BODY, chanflags| CHANF_OVERLAP, nSound+1, nVolume / 255.f,fullvol? 0.5f : ATTN_NORM, nullptr, (11025 + nPitch) / 11025.f);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -648,7 +648,7 @@ void PlayFX2(unsigned short nSound, short nSprite, int sectf, EChanFlags chanfla
|
|||
}
|
||||
|
||||
// Nuke: added nSprite >= 0 check
|
||||
if (nSprite != PlayerList[nLocalPlayer].Actor()->GetSpriteIndex() && nSprite >= 0 && (sprite[nSprite].cstat&257))
|
||||
if (pActor != PlayerList[nLocalPlayer].Actor() && pActor != nullptr && (pActor->s().cstat&257))
|
||||
nCreepyTimer = kCreepyCount;
|
||||
}
|
||||
|
||||
|
@ -664,7 +664,7 @@ void PlayFXAtXYZ(unsigned short ax, int x, int y, int z, int nSector, EChanFlags
|
|||
soundy = y;
|
||||
soundz = z;
|
||||
soundsect = nSector;
|
||||
PlayFX2(ax, -1, sectf, chanflags);
|
||||
PlayFX2(ax, nullptr, sectf, chanflags);
|
||||
}
|
||||
|
||||
//==========================================================================
|
||||
|
|
|
@ -131,20 +131,12 @@ int LoadSound(const char* sound);
|
|||
void BendAmbientSound();
|
||||
void CheckAmbience(short nSector);
|
||||
|
||||
void PlayFX2(unsigned short nSound, short nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0);
|
||||
inline void PlayFX2(unsigned short nSound, DExhumedActor* actor, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0)
|
||||
{
|
||||
PlayFX2(nSound, actor->GetSpriteIndex(), sectf, chanflags, sprflags);
|
||||
}
|
||||
void PlayFX2(unsigned short nSound, DExhumedActor* nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0);
|
||||
|
||||
void PlayFXAtXYZ(unsigned short nSound, int x, int y, int z, int nSector, EChanFlags chanflags = CHANF_NONE, int sectf = 0);
|
||||
inline void D3PlayFX(unsigned short nSound, short nSprite, short flags = 0)
|
||||
{
|
||||
PlayFX2(nSound, nSprite, 0, CHANF_NONE, flags);
|
||||
}
|
||||
inline void D3PlayFX(unsigned short nSound, DExhumedActor* actor, short flags = 0)
|
||||
{
|
||||
PlayFX2(nSound, actor->GetSpriteIndex(), 0, CHANF_NONE, flags);
|
||||
PlayFX2(nSound, actor, 0, CHANF_NONE, flags);
|
||||
}
|
||||
|
||||
void StopActorSound(DExhumedActor* actor);
|
||||
|
|
|
@ -102,7 +102,7 @@ DEFINE_ACTION_FUNCTION(_Exhumed, MoveStatusSequence)
|
|||
PARAM_PROLOGUE;
|
||||
PARAM_INT(s1);
|
||||
PARAM_INT(s2);
|
||||
seq_MoveSequence(-1, nStatusSeqOffset + s1, s2);
|
||||
seq_MoveSequence(nullptr, nStatusSeqOffset + s1, s2);
|
||||
ACTION_RETURN_INT(SeqSize[nStatusSeqOffset + s1]);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue