- Exhumed: clean up PlayFXAtXYZ interface and its global variable abuse

This commit is contained in:
Christoph Oelckers 2022-08-20 17:52:06 +02:00
parent de18371e06
commit 163146250d
8 changed files with 18 additions and 30 deletions

View file

@ -208,7 +208,7 @@ void DoRedAlert(int nVal)
{
if (nVal)
{
PlayFXAtXYZ(StaticSound[kSoundAlarm], ac->int_pos().X, ac->int_pos().Y, ac->int_pos().Z);
PlayFXAtXYZ(StaticSound[kSoundAlarm], ac->spr.pos);
AddFlash(ac->sector(), ac->spr.pos, 192);
}
}

View file

@ -272,7 +272,7 @@ void AIFish::Damage(RunListEvent* ev)
BuildFishLimb(pActor, i);
}
PlayFXAtXYZ(StaticSound[kSound40], pActor->int_pos().X, pActor->int_pos().Y, pActor->int_pos().Z);
PlayFXAtXYZ(StaticSound[kSound40], pActor->spr.pos);
DestroyFish(pActor);
}
else

View file

@ -606,9 +606,7 @@ int CheckSectorSprites(sectortype* pSector, int nVal)
if (pActor->spr.statnum == 100 && PlayerList[GetPlayerFromActor(pActor)].nHealth <= 0)
{
PlayFXAtXYZ(StaticSound[kSoundJonFDie],
pActor->int_pos().X,
pActor->int_pos().Y,
pActor->int_pos().Z,
pActor->spr.pos,
CHANF_NONE, 0x4000);
}
}
@ -836,7 +834,7 @@ void AIElev::Tick(RunListEvent* ev)
SetQuake(pElevSpr, 30);
}
PlayFXAtXYZ(StaticSound[kSound26], pElevSpr->int_pos().X, pElevSpr->int_pos().Y, pElevSpr->int_pos().Z);
PlayFXAtXYZ(StaticSound[kSound26], pElevSpr->spr.pos);
}
if (var_18 & 0x4)

View file

@ -983,7 +983,7 @@ void AIPlayer::Tick(RunListEvent* ev)
pPlayerActor->spr.yvel = 0;
StopActorSound(pPlayerActor);
PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerActor->int_pos().X, pPlayerActor->int_pos().Y, pPlayerActor->int_pos().Z, CHANF_NONE, 1); // CHECKME
PlayFXAtXYZ(StaticSound[kSoundJonFDie], pPlayerActor->spr.pos, CHANF_NONE, 1); // CHECKME
}
else
{

View file

@ -685,7 +685,7 @@ void BuildQueenHead(int nQueen)
auto pActor2 = insertActor(pSector, 121);
pActor2->spr.pos.XY() = pActor->spr.pos();
pActor2->spr.pos.XY() = pActor->spr.pos.XY();
pActor2->spr.pos.Z = pSector->floorz;
pActor2->spr.clipdist = 70;
pActor2->spr.xrepeat = 80;
@ -1368,9 +1368,7 @@ void AIQueen::Tick(RunListEvent* ev)
PlayFXAtXYZ(
StaticSound[kSound40],
pActor->int_pos().X,
pActor->int_pos().Y,
pActor->int_pos().Z);
pActor->spr.pos);
BuildQueenHead(nQueen);

View file

@ -549,9 +549,7 @@ void GameInterface::UpdateSounds()
//
//==========================================================================
int soundx, soundy, soundz;
void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags, int sprflags)
void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags, int sprflags, const DVector3* soundpos)
{
if (!SoundEnabled()) return;
if ((nSound&0x1ff) >= kMaxSounds || !soundEngine->isValidSoundId((nSound & 0x1ff)+1))
@ -565,10 +563,9 @@ void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags,
{
fullvol = (sprflags & 0x2000) != 0;
hiprio = (sprflags & 0x4000) != 0;
soundx = pActor->int_pos().X;
soundy = pActor->int_pos().Y;
soundz = pActor->int_pos().Z;
soundpos = &pActor->spr.pos;
}
if (!soundpos) return;
int nVolume = 255;
@ -588,8 +585,7 @@ void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags,
GetSpriteSoundPitch(&nVolume, &nPitch);
vec3_t v = { soundx, soundy, soundz };
FVector3 vv = GetSoundPos(v);
FVector3 vv = GetSoundPos(*soundpos);
// Check if this sound is allowed to play or if it must stop some other sound.
if (!forcePlay)
@ -652,12 +648,9 @@ void PlayFX2(int nSound, DExhumedActor* pActor, int sectf, EChanFlags chanflags,
//
//==========================================================================
void PlayFXAtXYZ(int ax, int x, int y, int z, EChanFlags chanflags, int sectf)
void PlayFXAtXYZ(int ax, const DVector3& pos, EChanFlags chanflags, int sectf)
{
soundx = x;
soundy = y;
soundz = z;
PlayFX2(ax, nullptr, sectf, chanflags);
PlayFX2(ax, nullptr, sectf, chanflags, 0, &pos);
}
//==========================================================================

View file

@ -130,9 +130,9 @@ int LoadSound(const char* sound);
void BendAmbientSound();
void CheckAmbience(sectortype* pSector);
void PlayFX2(int nSound, DExhumedActor* nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0);
void PlayFX2(int nSound, DExhumedActor* nSprite, int sectf = 0, EChanFlags chanflags = CHANF_NONE, int sprflags = 0, const DVector3* soundpos = nullptr);
void PlayFXAtXYZ(int nSound, int x, int y, int z, EChanFlags chanflags = CHANF_NONE, int sectf = 0);
void PlayFXAtXYZ(int nSound, const DVector3& pos, EChanFlags chanflags = CHANF_NONE, int sectf = 0);
inline void D3PlayFX(int nSound, DExhumedActor* actor, int flags = 0)
{
PlayFX2(nSound, actor, 0, CHANF_NONE, flags);

View file

@ -290,7 +290,7 @@ void AISWStepOn::TouchFloor(RunListEvent* ev)
if (var_14 != sRunChannels[nChannel].c)
{
auto pWall = pSector->firstWall();
PlayFXAtXYZ(StaticSound[nSwitchSound], pWall->wall_int_pos().X, pWall->wall_int_pos().Y, pSector->int_floorz());
PlayFXAtXYZ(StaticSound[nSwitchSound], DVector3(pWall->pos, pSector->floorz));
assert(sRunChannels[nChannel].c < 8);
@ -442,8 +442,7 @@ void AISWPressSector::Use(RunListEvent* ev)
{
if (SwitchData[nSwitch].nKeyMask)
{
auto& pos = PlayerList[nPlayer].pActor->int_pos();
PlayFXAtXYZ(StaticSound[nSwitchSound], pos.X, pos.Y, 0, CHANF_LISTENERZ);
PlayFXAtXYZ(StaticSound[nSwitchSound], PlayerList[nPlayer].pActor->spr.pos, CHANF_LISTENERZ);
StatusMessage(300, GStrings("TXT_EX_NEEDKEY"));
}
@ -510,7 +509,7 @@ void AISWPressWall::Use(RunListEvent* ev)
auto pWall = SwitchData[nSwitch].pWall;
auto pSector = SwitchData[nSwitch].pSector;
PlayFXAtXYZ(StaticSound[nSwitchSound], pWall->wall_int_pos().X, pWall->wall_int_pos().Y, 0, CHANF_LISTENERZ);
PlayFXAtXYZ(StaticSound[nSwitchSound], DVector3(pWall->pos, 0), CHANF_LISTENERZ);
}
END_PS_NS