diff --git a/source/common/audio/sound/s_soundinternal.h b/source/common/audio/sound/s_soundinternal.h index 2184c65c6..13ca33e7a 100644 --- a/source/common/audio/sound/s_soundinternal.h +++ b/source/common/audio/sound/s_soundinternal.h @@ -249,9 +249,6 @@ public: blockNewSounds = on; } - virtual int SoundSourceIndex(FSoundChan* chan) { return 0; } - virtual void SetSource(FSoundChan* chan, int index) {} - virtual void StopChannel(FSoundChan* chan); sfxinfo_t* LoadSound(sfxinfo_t* sfx); const sfxinfo_t* GetSfx(unsigned snd) diff --git a/source/core/raze_sound.cpp b/source/core/raze_sound.cpp index a306f8520..22bc3c876 100644 --- a/source/core/raze_sound.cpp +++ b/source/core/raze_sound.cpp @@ -44,6 +44,7 @@ #include "cmdlib.h" #include "gamecontrol.h" #include "build.h" +#include "coreactor.h" extern ReverbContainer* ForcedEnvironment; static int LastReverb; @@ -181,18 +182,25 @@ static FSerializer& Serialize(FSerializer& arc, const char* key, FSoundChan& cha ("userdata", chan.UserData) .Array("point", chan.Point, 3); - int SourceIndex = 0; - if (arc.isWriting()) + assert(dynamic_cast(soundEngine)); + + auto eng = static_cast(soundEngine); + // Let's handle actor sources here becaue they are the same for all games. + if (eng->SourceIsActor(&chan)) { - if (chan.SourceType == SOURCE_Actor) SourceIndex = int((spritetype*)(chan.Source) - sprite); - else SourceIndex = soundEngine->SoundSourceIndex(&chan); + DCoreActor* SourceIndex = nullptr; + if (arc.isWriting()) SourceIndex = const_cast(reinterpret_cast(chan.Source)); + arc("Source", SourceIndex); + if (arc.isReading()) chan.Source = SourceIndex; } - arc("Source", SourceIndex); - if (arc.isReading()) + else { - if (chan.SourceType == SOURCE_Actor) chan.Source = &sprite[SourceIndex]; - else soundEngine->SetSource(&chan, SourceIndex); + int SourceIndex = 0; + if (arc.isWriting()) SourceIndex = eng->SoundSourceIndex(&chan); + arc("Source", SourceIndex); + if (arc.isReading()) eng->SetSource(&chan, SourceIndex); } + arc.EndObject(); } return arc; diff --git a/source/core/raze_sound.h b/source/core/raze_sound.h index 8d43ea145..5de9c2cff 100644 --- a/source/core/raze_sound.h +++ b/source/core/raze_sound.h @@ -38,3 +38,11 @@ inline void FX_SetReverbDelay(int delay) int S_LookupSound(const char* fn); class FSerializer; void S_SerializeSounds(FSerializer& arc); + +class RazeSoundEngine : public SoundEngine +{ +public: + virtual bool SourceIsActor(FSoundChan* chan) { return chan->SourceType == SOURCE_Actor; } + virtual int SoundSourceIndex(FSoundChan* chan) { return 0; } + virtual void SetSource(FSoundChan* chan, int index) {} +}; \ No newline at end of file diff --git a/source/games/blood/src/actor.cpp b/source/games/blood/src/actor.cpp index dc64b7d74..cd3726215 100644 --- a/source/games/blood/src/actor.cpp +++ b/source/games/blood/src/actor.cpp @@ -3746,7 +3746,7 @@ static int actDamageThing(DBloodActor* source, DBloodActor* actor, int damage, D case kThingZombieHead: if (damageType == 3 && pSourcePlayer && PlayClock > pSourcePlayer->laughCount && Chance(0x4000)) { - sfxPlay3DSound(pSourcePlayer->pSprite, gPlayerGibThingComments[Random(10)], 0, 2); + sfxPlay3DSound(pSourcePlayer->actor, gPlayerGibThingComments[Random(10)], 0, 2); pSourcePlayer->laughCount = PlayClock + 3600; } break; @@ -3914,7 +3914,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) if (missileActor->hasX()) { actPostSprite(missileActor, kStatDecoration); - if (pMissile->ang == 1024) sfxPlay3DSound(pMissile, 307, -1, 0); + if (pMissile->ang == 1024) sfxPlay3DSound(missileActor, 307, -1, 0); pMissile->type = kSpriteDecoration; seqSpawn(9, missileActor, -1); } @@ -3952,7 +3952,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) break; case kMissileArcGargoyle: - sfxKill3DSound(pMissile, -1, -1); + sfxKill3DSound(missileActor, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 306, pMissile->sector()); GibSprite(missileActor, GIBTYPE_6, NULL, NULL); @@ -3966,7 +3966,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) case kMissileLifeLeechAltNormal: case kMissileLifeLeechAltSmall: - sfxKill3DSound(pMissile, -1, -1); + sfxKill3DSound(missileActor, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 306, pMissile->sector()); if (hitCode == 3 && pSpriteHit && (pThingInfo || pDudeInfo)) @@ -3992,12 +3992,12 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) break; case kMissileFlareAlt: - sfxKill3DSound(pMissile, -1, -1); + sfxKill3DSound(missileActor, -1, -1); actExplodeSprite(missileActor); break; case kMissileFlareRegular: - sfxKill3DSound(pMissile, -1, -1); + sfxKill3DSound(missileActor, -1, -1); if ((hitCode == 3 && pSpriteHit) && (pThingInfo || pDudeInfo)) { if ((pThingInfo && pThingInfo->dmgControl[kDamageBurn] != 0) || (pDudeInfo && pDudeInfo->damageVal[kDamageBurn] != 0)) @@ -4080,7 +4080,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) break; case kMissileEctoSkull: - sfxKill3DSound(pMissile, -1, -1); + sfxKill3DSound(missileActor, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 522, pMissile->sector()); actPostSprite(missileActor, kStatDebris); seqSpawn(20, missileActor, -1); @@ -4113,7 +4113,7 @@ static void actImpactMissile(DBloodActor* missileActor, int hitCode) break; case kMissileTeslaRegular: - sfxKill3DSound(pMissile, -1, -1); + sfxKill3DSound(missileActor, -1, -1); sfxPlay3DSound(pMissile->x, pMissile->y, pMissile->z, 518, pMissile->sector()); GibSprite(missileActor, (hitCode == 2) ? GIBTYPE_23 : GIBTYPE_22, NULL, NULL); evKillActor(missileActor); @@ -5457,7 +5457,7 @@ void actExplodeSprite(DBloodActor* actor) //auto Owner = actor->GetOwner(); if (pSprite->statnum == kStatExplosion) return; - sfxKill3DSound(pSprite, -1, -1); + sfxKill3DSound(actor, -1, -1); evKillActor(actor); int nType = kExplosionStandard; @@ -6590,19 +6590,19 @@ void actBuildMissile(DBloodActor* spawned, DBloodActor* actor) pMissile->cstat |= 16; break; case kMissileTeslaRegular: - sfxPlay3DSound(pMissile, 251, 0, 0); + sfxPlay3DSound(spawned, 251, 0, 0); break; case kMissileEctoSkull: seqSpawn(2, spawned, -1); - sfxPlay3DSound(pMissile, 493, 0, 0); + sfxPlay3DSound(spawned, 493, 0, 0); break; case kMissileFireballNapalm: seqSpawn(61, spawned, nNapalmClient); - sfxPlay3DSound(pMissile, 441, 0, 0); + sfxPlay3DSound(spawned, 441, 0, 0); break; case kMissileFireball: seqSpawn(22, spawned, nFireballClient); - sfxPlay3DSound(pMissile, 441, 0, 0); + sfxPlay3DSound(spawned, 441, 0, 0); break; case kMissileFlameHound: seqSpawn(27, spawned, -1); @@ -6612,7 +6612,7 @@ void actBuildMissile(DBloodActor* spawned, DBloodActor* actor) break; case kMissileFireballCerberus: seqSpawn(61, spawned, dword_2192E0); - sfxPlay3DSound(pMissile, 441, 0, 0); + sfxPlay3DSound(spawned, 441, 0, 0); break; case kMissileFireballTchernobog: seqSpawn(23, spawned, dword_2192D8); @@ -6630,17 +6630,17 @@ void actBuildMissile(DBloodActor* spawned, DBloodActor* actor) case kMissileFlareAlt: evPostActor(spawned, 30, kCallbackFXFlareBurst); evPostActor(spawned, 0, kCallbackFXFlareSpark); - sfxPlay3DSound(pMissile, 422, 0, 0); + sfxPlay3DSound(spawned, 422, 0, 0); break; case kMissileFlareRegular: evPostActor(spawned, 0, kCallbackFXFlareSpark); - sfxPlay3DSound(pMissile, 422, 0, 0); + sfxPlay3DSound(spawned, 422, 0, 0); break; case kMissileLifeLeechAltSmall: evPostActor(spawned, 0, kCallbackFXArcSpark); break; case kMissileArcGargoyle: - sfxPlay3DSound(pMissile, 252, 0, 0); + sfxPlay3DSound(spawned, 252, 0, 0); break; } } diff --git a/source/games/blood/src/aiunicult.cpp b/source/games/blood/src/aiunicult.cpp index f76b5584e..460288bf1 100644 --- a/source/games/blood/src/aiunicult.cpp +++ b/source/games/blood/src/aiunicult.cpp @@ -1453,7 +1453,7 @@ void removeLeech(DBloodActor* actLeech, bool delSprite) pEffect->yrepeat = repeat; } - sfxPlay3DSoundCP(pLeech, 490, -1, 0,60000); + sfxPlay3DSoundCP(actLeech, 490, -1, 0,60000); if (actLeech->GetOwner()) actLeech->GetOwner()->genDudeExtra.pLifeLeech = nullptr; diff --git a/source/games/blood/src/aizomba.cpp b/source/games/blood/src/aizomba.cpp index c01d5f02d..86a23ed77 100644 --- a/source/games/blood/src/aizomba.cpp +++ b/source/games/blood/src/aizomba.cpp @@ -74,7 +74,7 @@ void HackSeqCallback(int, DBloodActor* actor) int dz = height - height2; int dx = bcos(nAngle); int dy = bsin(nAngle); - sfxPlay3DSound(pSprite, 1101, 1, 0); + sfxPlay3DSound(actor, 1101, 1, 0); actFireVector(actor, 0, 0, dx, dy, dz, kVectorAxe); } @@ -197,7 +197,7 @@ static void zombaThinkPonder(DBloodActor* actor) { if (abs(nDeltaAngle) < 85) { - sfxPlay3DSound(pSprite, 1101, 1, 0); + sfxPlay3DSound(actor, 1101, 1, 0); aiNewState(actor, &zombieAHack); } return; @@ -277,7 +277,7 @@ static void entryEStand(DBloodActor* actor) { auto pXSprite = &actor->x(); auto pSprite = &actor->s(); - sfxPlay3DSound(pSprite, 1100, -1, 0); + sfxPlay3DSound(actor, 1100, -1, 0); pSprite->ang = getangle(pXSprite->targetX - pSprite->x, pXSprite->targetY - pSprite->y); } diff --git a/source/games/blood/src/aizombf.cpp b/source/games/blood/src/aizombf.cpp index 289996b44..7fdffb99b 100644 --- a/source/games/blood/src/aizombf.cpp +++ b/source/games/blood/src/aizombf.cpp @@ -74,7 +74,7 @@ void PukeSeqCallback(int, DBloodActor* actor) int nAngle = getangle(tx, ty); int dx = bcos(nAngle); int dy = bsin(nAngle); - sfxPlay3DSound(pSprite, 1203, 1, 0); + sfxPlay3DSound(actor, 1203, 1, 0); actFireMissile(actor, 0, -(height - height2), dx, dy, 0, kMissilePukeGreen); } diff --git a/source/games/blood/src/bloodactor.h b/source/games/blood/src/bloodactor.h index 168b24b9c..37fdfe868 100644 --- a/source/games/blood/src/bloodactor.h +++ b/source/games/blood/src/bloodactor.h @@ -185,19 +185,6 @@ inline void GetActorExtents(DBloodActor* actor, int* top, int* bottom) GetSpriteExtents(&actor->s(), top, bottom); } -inline void sfxPlay3DSound(DBloodActor* pSprite, int soundId, int a3 = -1, int a4 = 0) -{ - sfxPlay3DSound(&pSprite->s(), soundId, a3, a4); -} -inline void sfxPlay3DSoundCP(DBloodActor* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0) -{ - sfxPlay3DSoundCP(&pSprite->s(), soundId, a3, a4, pitch, volume); -} -inline void sfxKill3DSound(DBloodActor* pSprite, int a2 = -1, int a3 = -1) -{ - sfxKill3DSound(&pSprite->s(), a2, a3); -} - inline void ChangeActorStat(DBloodActor* actor, int stat) { ChangeSpriteStat(actor->GetSpriteIndex(), stat); diff --git a/source/games/blood/src/callback.cpp b/source/games/blood/src/callback.cpp index 3c3935de3..036a62173 100644 --- a/source/games/blood/src/callback.cpp +++ b/source/games/blood/src/callback.cpp @@ -287,7 +287,7 @@ void Respawn(DBloodActor* actor, sectortype*) // 9 } gFX.fxSpawnActor(FX_29, pSprite->sector(), pSprite->x, pSprite->y, pSprite->z, 0); - sfxPlay3DSound(pSprite, 350, -1, 0); + sfxPlay3DSound(actor, 350, -1, 0); break; } } @@ -402,7 +402,7 @@ void fxBloodBits(DBloodActor* actor, sectortype*) // 14 if (pSprite->ang == 1024) { int nChannel = 28 + (actor->GetIndex() & 2); // this is a little stupid... - sfxPlay3DSound(pSprite, 385, nChannel, 1); + sfxPlay3DSound(actor, 385, nChannel, 1); } if (Chance(0x5000)) { @@ -459,11 +459,11 @@ void fxBouncingSleeve(DBloodActor* actor, sectortype*) // 16 // tommy sleeve if (pSprite->type >= 37 && pSprite->type <= 39) { Random(3); - sfxPlay3DSound(pSprite, 608 + Random(2), nChannel, 1); + sfxPlay3DSound(actor, 608 + Random(2), nChannel, 1); // sawed-off sleeve } else { - sfxPlay3DSound(pSprite, sawedOffSleeveSnd[Random(2)], nChannel, 1); + sfxPlay3DSound(actor, sawedOffSleeveSnd[Random(2)], nChannel, 1); } } @@ -475,7 +475,7 @@ void sleeveStopBouncing(DBloodActor* actor) auto pSprite = &actor->s(); actor->xvel = actor->yvel = actor->zvel = 0; if (actor->hasX()) seqKill(actor); - sfxKill3DSound(pSprite, -1, -1); + sfxKill3DSound(actor, -1, -1); switch (pSprite->type) { case 37: @@ -559,7 +559,7 @@ void fxPodBloodSplat(DBloodActor* actor, sectortype*) // 19 { int nChannel = 28 + (actor->GetIndex() & 2); assert(nChannel < 32); - sfxPlay3DSound(pSprite, 385, nChannel, 1); + sfxPlay3DSound(actor, 385, nChannel, 1); } DBloodActor *pFX = NULL; if (pSprite->type == 53 || pSprite->type == kThingPodGreenBall) @@ -596,17 +596,18 @@ void LeechStateTimer(DBloodActor* actor, sectortype*) // 20 } } -void sub_76A08(DBloodActor *actor, spritetype *pSprite2, PLAYER *pPlayer) // ??? +void sub_76A08(DBloodActor *actor, DBloodActor *actor2, PLAYER *pPlayer) // ??? { int top, bottom; auto pSprite = &actor->s(); + auto pSprite2 = &actor2->s(); GetSpriteExtents(pSprite, &top, &bottom); pSprite->x = pSprite2->x; pSprite->y = pSprite2->y; pSprite->z = pSprite2->sector()->floorz-(bottom-pSprite->z); pSprite->ang = pSprite2->ang; ChangeActorSect(actor, pSprite2->sector()); - sfxPlay3DSound(pSprite2, 201, -1, 0); + sfxPlay3DSound(actor2, 201, -1, 0); actor->xvel = actor->yvel = actor->zvel = 0; viewBackupSpriteLoc(actor); if (pPlayer) @@ -678,7 +679,7 @@ void DropVoodooCb(DBloodActor* actor, sectortype*) // unused { int nDmg = actDamageSprite(actor, actor2, kDamageSpirit, pXSprite->data1<<4); pXSprite->data1 = ClipLow(pXSprite->data1-nDmg, 0); - sub_76A08(actor2, pSprite, pPlayer2); + sub_76A08(actor2, actor, pPlayer2); evPostActor(actor, 0, kCallbackRemove); return; } @@ -719,7 +720,7 @@ void DropVoodooCb(DBloodActor* actor, sectortype*) // unused } if (vd && (Chance(vd) || nextactor == nullptr)) { - sub_76A08(actor2, pSprite, NULL); + sub_76A08(actor2, actor, NULL); evPostActor(actor, 0, kCallbackRemove); return; } diff --git a/source/games/blood/src/nnexts.cpp b/source/games/blood/src/nnexts.cpp index 7fc18d955..677444d7d 100644 --- a/source/games/blood/src/nnexts.cpp +++ b/source/games/blood/src/nnexts.cpp @@ -1789,7 +1789,7 @@ void debrisMove(int listIndex) case kMarkerUpWater: case kMarkerUpGoo: int pitch = (150000 - (actor->spriteMass.mass << 9)) + Random3(8192); - sfxPlay3DSoundCP(pSprite, 720, -1, 0, pitch, 75 - Random(40)); + sfxPlay3DSoundCP(actor, 720, -1, 0, pitch, 75 - Random(40)); if (!spriteIsUnderwater(actor)) { evKillActor(actor, kCallbackEnemeyBubble); @@ -3111,7 +3111,7 @@ void useTeleportTarget(DBloodActor* sourceactor, DBloodActor* actor) viewBackupSpriteLoc(actor); if (pXSource->data4 > 0) - sfxPlay3DSound(pSource, pXSource->data4, -1, 0); + sfxPlay3DSound(sourceactor, pXSource->data4, -1, 0); if (pPlayer) { @@ -5770,12 +5770,12 @@ bool modernTypeOperateSprite(DBloodActor* actor, const EVENT& event) { case kCmdSpriteProximity: if (pXSprite->state) break; - sfxPlay3DSound(pSprite, 452, 0, 0); + sfxPlay3DSound(actor, 452, 0, 0); evPostActor(actor, 30, kCmdOff); pXSprite->state = 1; [[fallthrough]]; case kCmdOn: - sfxPlay3DSound(pSprite, 451, 0, 0); + sfxPlay3DSound(actor, 451, 0, 0); pXSprite->Proximity = 1; break; default: @@ -8309,18 +8309,17 @@ DBloodActor* aiPatrolSearchTargets(DBloodActor* actor) sectortype* searchsect = nullptr; if (chan->SourceType == SOURCE_Actor) { - auto emitter = (spritetype*)chan->Source; - if (emitter < sprite || emitter >= sprite + MAXSPRITES || emitter->statnum == kStatFree) return false; // not a valid source. - sndx = emitter->x; - sndy = emitter->y; + auto emitterActor = (DBloodActor*)chan->Source; + if (emitterActor == nullptr) return false; // not a valid source. + sndx = emitterActor->s().x; + sndy = emitterActor->s().y; // sound attached to the sprite - auto emitterActor = &bloodActors[emitter - sprite]; - if (pSpr != emitter && emitterActor->GetOwner() != actor) + if (pPlayer->actor != emitterActor && emitterActor->GetOwner() != actor) { - if (!emitter->insector()) return false; - searchsect = emitter->sector(); + if (!emitterActor->s().insector()) return false; + searchsect = emitterActor->s().sector(); } } else if (chan->SourceType == SOURCE_Unattached) diff --git a/source/games/blood/src/player.cpp b/source/games/blood/src/player.cpp index 8ec425c11..ef0b47072 100644 --- a/source/games/blood/src/player.cpp +++ b/source/games/blood/src/player.cpp @@ -299,7 +299,7 @@ bool powerupActivate(PLAYER *pPlayer, int nPowerUp) WeaponRaise(pPlayer); break; } - sfxPlay3DSound(pPlayer->pSprite, 776, -1, 0); + sfxPlay3DSound(pPlayer->actor, 776, -1, 0); return 1; } @@ -1109,7 +1109,7 @@ bool PickupAmmo(PLAYER* pPlayer, DBloodActor* ammoactor) pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType]+pAmmoItemData->count, gAmmoInfo[nAmmoType].max); if (pAmmoItemData->weaponType) pPlayer->hasWeapon[pAmmoItemData->weaponType] = 1; - sfxPlay3DSound(pPlayer->pSprite, 782, -1, 0); + sfxPlay3DSound(pPlayer->actor, 782, -1, 0); return 1; } @@ -1137,7 +1137,7 @@ bool PickupWeapon(PLAYER *pPlayer, DBloodActor* weaponactor) pPlayer->weaponState = 0; pPlayer->nextWeapon = nNewWeapon; } - sfxPlay3DSound(pPlayer->pSprite, 777, -1, 0); + sfxPlay3DSound(pPlayer->actor, 777, -1, 0); return 1; } @@ -1149,7 +1149,7 @@ bool PickupWeapon(PLAYER *pPlayer, DBloodActor* weaponactor) else pPlayer->ammoCount[nAmmoType] = ClipHigh(pPlayer->ammoCount[nAmmoType]+pWeaponItemData->count, gAmmoInfo[nAmmoType].max); - sfxPlay3DSound(pPlayer->pSprite, 777, -1, 0); + sfxPlay3DSound(pPlayer->actor, 777, -1, 0); return 1; } @@ -1488,7 +1488,7 @@ void ProcessInput(PLAYER *pPlayer) #ifdef NOONE_EXTENSIONS if ((packItemActive(pPlayer, 4) && pPosture->pwupJumpZ != 0) || pPosture->normalJumpZ != 0) #endif - sfxPlay3DSound(pSprite, 700, 0, 0); + sfxPlay3DSound(actor, 700, 0, 0); if (packItemActive(pPlayer, 4)) actor->zvel = pPosture->pwupJumpZ; //-0x175555; else actor->zvel = pPosture->normalJumpZ; //-0xbaaaa; @@ -1951,7 +1951,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage { case kDamageSpirit: nDeathSeqID = 18; - sfxPlay3DSound(pSprite, 716, 0, 0); + sfxPlay3DSound(pPlayer->actor, 716, 0, 0); break; case kDamageExplode: GibSprite(pActor, GIBTYPE_7, NULL, NULL); @@ -1995,10 +1995,10 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage nSound = pDamageInfo->Kills[Random(3)]; if (nDamageType == kDamageDrown && pXSprite->medium == kMediumWater && !pPlayer->hand) nSound = 714; - sfxPlay3DSound(pSprite, nSound, 0, 6); + sfxPlay3DSound(pPlayer->actor, nSound, 0, 6); return nDamage; } - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); if (gGameOptions.nGameType == 3 && pPlayer->hasFlag) { if (pPlayer->hasFlag&1) flagDropped(pPlayer, kItemFlagA); if (pPlayer->hasFlag&2) flagDropped(pPlayer, kItemFlagB); @@ -2013,14 +2013,14 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage switch (nDamageType) { case kDamageExplode: - sfxPlay3DSound(pSprite, 717, 0, 0); + sfxPlay3DSound(pPlayer->actor, 717, 0, 0); GibSprite(pActor, GIBTYPE_7, NULL, NULL); GibSprite(pActor, GIBTYPE_15, NULL, NULL); pPlayer->pSprite->cstat |= 32768; nDeathSeqID = 2; break; case kDamageBurn: - sfxPlay3DSound(pSprite, 718, 0, 0); + sfxPlay3DSound(pPlayer->actor, 718, 0, 0); nDeathSeqID = 3; break; case kDamageDrown: @@ -2030,7 +2030,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage if (nHealth < -20 && gGameOptions.nGameType >= 2 && Chance(0x4000)) { DAMAGEINFO *pDamageInfo = &damageInfo[nDamageType]; - sfxPlay3DSound(pSprite, pDamageInfo->at10[0], 0, 2); + sfxPlay3DSound(pPlayer->actor, pDamageInfo->at10[0], 0, 2); nDeathSeqID = 16; nKneelingPlayer = nPlayerKneelClient; powerupActivate(pPlayer, kPwUpDeliriumShroom); @@ -2039,7 +2039,7 @@ int playerDamageSprite(DBloodActor* source, PLAYER *pPlayer, DAMAGE_TYPE nDamage } else { - sfxPlay3DSound(pSprite, 716, 0, 0); + sfxPlay3DSound(pPlayer->actor, 716, 0, 0); nDeathSeqID = 1; } break; @@ -2149,7 +2149,7 @@ void playerLandingSound(PLAYER *pPlayer) return; int nSurf = tileGetSurfType(pHit->florhit); if (nSurf) - sfxPlay3DSound(pSprite, surfaceSound[nSurf], -1, 0); + sfxPlay3DSound(pPlayer->actor, surfaceSound[nSurf], -1, 0); } } @@ -2160,7 +2160,7 @@ void PlayerSurvive(int, DBloodActor* actor) actHealDude(actor, 1, 2); if (gGameOptions.nGameType > 0 && numplayers > 1) { - sfxPlay3DSound(pSprite, 3009, 0, 6); + sfxPlay3DSound(actor, 3009, 0, 6); if (IsPlayerSprite(pSprite)) { PLAYER *pPlayer = &gPlayer[pSprite->type-kDudePlayer1]; diff --git a/source/games/blood/src/seq.cpp b/source/games/blood/src/seq.cpp index 13a8b9985..5e04f62ae 100644 --- a/source/games/blood/src/seq.cpp +++ b/source/games/blood/src/seq.cpp @@ -380,7 +380,7 @@ void SEQINST::Update() { auto udata = soundEngine->GetUserData(snd); int relVol = udata ? udata[2] : 255; - sfxPlay3DSoundCP(pSprite, sndId, -1, 0, 0, (surfSfxMove[surf][2] != relVol) ? relVol : surfSfxMove[surf][3]); + sfxPlay3DSoundCP(actor, sndId, -1, 0, 0, (surfSfxMove[surf][2] != relVol) ? relVol : surfSfxMove[surf][3]); } } break; diff --git a/source/games/blood/src/sfx.cpp b/source/games/blood/src/sfx.cpp index 381f3a626..078454b1a 100644 --- a/source/games/blood/src/sfx.cpp +++ b/source/games/blood/src/sfx.cpp @@ -29,7 +29,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. BEGIN_BLD_NS -class BloodSoundEngine : public SoundEngine +class BloodSoundEngine : public RazeSoundEngine { // client specific parts of the sound engine go in this class. void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan *channel) override; @@ -45,9 +45,9 @@ public: void StopChannel(FSoundChan* chan) override { - if (chan && chan->SysChannel != NULL && !(chan->ChanFlags & CHANF_EVICTED) && chan->SourceType == SOURCE_Actor) + if (chan && chan->SysChannel != nullptr && !(chan->ChanFlags & CHANF_EVICTED) && chan->SourceType == SOURCE_Actor) { - chan->Source = NULL; + chan->Source = nullptr; chan->SourceType = SOURCE_Unattached; } SoundEngine::StopChannel(chan); @@ -88,13 +88,12 @@ void BloodSoundEngine::CalcPosVel(int type, const void* source, const float pt[3 } else if (type == SOURCE_Actor) { - auto sprt = (spritetype*)source; - assert(sprt != nullptr); - auto actor = &bloodActors[sprt - sprite]; + assert(source != nullptr); + auto actor = (DBloodActor*)source; // Engine expects velocity in units per second, not units per tic. if (vel) *vel = { actor->xvel * (30 / 65536.f), actor->zvel * (-30 / 65536.f), actor->yvel * (-30 / 65536.f) }; - *pos = GetSoundPos(&sprt->pos); + *pos = GetSoundPos(&actor->s().pos); } else if (type == SOURCE_Ambient) { @@ -169,13 +168,13 @@ void sfxPlay3DSound(int x, int y, int z, int soundId, sectortype* pSector) if (chan) chan->UserData = sectnum(pSector); } -void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int playchannel, int playflags, int pitch, int volume) +void sfxPlay3DSoundCP(DBloodActor* pActor, int soundId, int playchannel, int playflags, int pitch, int volume) { - if (!SoundEnabled() || soundId < 0 || !pSprite) return; + if (!SoundEnabled() || soundId < 0 || !pActor) return; auto sid = soundEngine->FindSoundByResID(soundId); if (sid == 0) return; - auto svec = GetSoundPos(&pSprite->pos); + auto svec = GetSoundPos(&pActor->s().pos); float attenuation; sid = getSfx(sid, attenuation, pitch, volume); @@ -187,7 +186,7 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int playchannel, int pla if (soundEngine->EnumerateChannels([=](FSoundChan* chan) -> int { if (chan->SourceType != SOURCE_Actor) return false; // other source types are not our business. - if (chan->EntChannel == playchannel && (chan->Source == pSprite || (playflags & FX_GlobalChannel) != 0)) + if (chan->EntChannel == playchannel && (chan->Source == pActor || (playflags & FX_GlobalChannel) != 0)) { if ((playflags & FX_ChannelMatch) != 0 && chan->EntChannel == playchannel) return true; @@ -209,25 +208,25 @@ void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int playchannel, int pla flags &= ~CHANF_OVERLAP; } - soundEngine->StartSound(SOURCE_Actor, pSprite, &svec, playchannel, flags, sid, volume * (0.8f / 80.f), attenuation, nullptr, pitch / 65536.f); + soundEngine->StartSound(SOURCE_Actor, pActor, &svec, playchannel, flags, sid, volume * (0.8f / 80.f), attenuation, nullptr, pitch / 65536.f); } -void sfxPlay3DSound(spritetype* pSprite, int soundId, int a3, int a4) +void sfxPlay3DSound(DBloodActor* pActor, int soundId, int a3, int a4) { - sfxPlay3DSoundCP(pSprite, soundId, a3, a4, -1); + sfxPlay3DSoundCP(pActor, soundId, a3, a4, -1); } -void sfxKill3DSound(spritetype *pSprite, int a2, int a3) +void sfxKill3DSound(DBloodActor *pActor, int a2, int a3) { - if (!pSprite) + if (!pActor) return; if (a2 >= 0) a2++; auto sid = soundEngine->FindSoundByResID(a3); soundEngine->EnumerateChannels([=](FSoundChan* channel) { - if (channel->SourceType == SOURCE_Actor && channel->Source == pSprite && (a2 < 0 || a2 == channel->EntChannel) && (a3 < 0 || sid == channel->OrgID)) + if (channel->SourceType == SOURCE_Actor && channel->Source == pActor && (a2 < 0 || a2 == channel->EntChannel) && (a3 < 0 || sid == channel->OrgID)) { soundEngine->StopChannel(channel); } diff --git a/source/games/blood/src/sound.h b/source/games/blood/src/sound.h index d00bc97be..a09a6e877 100644 --- a/source/games/blood/src/sound.h +++ b/source/games/blood/src/sound.h @@ -51,9 +51,9 @@ void sndTerm(void); void sndInit(void); void sfxPlay3DSound(int x, int y, int z, int soundId, sectortype* pSector); -void sfxPlay3DSound(spritetype *pSprite, int soundId, int a3 = -1, int a4 = 0); -void sfxPlay3DSoundCP(spritetype* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0); -void sfxKill3DSound(spritetype *pSprite, int a2 = -1, int a3 = -1); +void sfxPlay3DSound(DBloodActor *pSprite, int soundId, int a3 = -1, int a4 = 0); +void sfxPlay3DSoundCP(DBloodActor* pSprite, int soundId, int a3 = -1, int a4 = 0, int pitch = 0, int volume = 0); +void sfxKill3DSound(DBloodActor *pSprite, int a2 = -1, int a3 = -1); void sfxKillAllSounds(void); void sfxSetReverb(bool toggle); void sfxSetReverb2(bool toggle); diff --git a/source/games/blood/src/triggers.cpp b/source/games/blood/src/triggers.cpp index 8748d03db..fb129bf49 100644 --- a/source/games/blood/src/triggers.cpp +++ b/source/games/blood/src/triggers.cpp @@ -361,12 +361,12 @@ void OperateSprite(DBloodActor* actor, EVENT event) case kCmdOff: if (!SetSpriteState(actor, 0)) break; seqSpawn(40, actor, -1); - sfxKill3DSound(pSprite, 0, -1); + sfxKill3DSound(actor, 0, -1); break; case kCmdOn: if (!SetSpriteState(actor, 1)) break; seqSpawn(38, actor, -1); - sfxPlay3DSound(pSprite, 441, 0, 0); + sfxPlay3DSound(actor, 441, 0, 0); break; } break; @@ -389,16 +389,16 @@ void OperateSprite(DBloodActor* actor, EVENT event) switch (event.cmd) { case kCmdOff: if (!SetSpriteState(actor, 0)) break; - sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); + sfxPlay3DSound(actor, pXSprite->data2, 0, 0); break; case kCmdOn: if (!SetSpriteState(actor, 1)) break; - sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); + sfxPlay3DSound(actor, pXSprite->data1, 0, 0); break; default: if (!SetSpriteState(actor, pXSprite->state ^ 1)) break; - if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); - else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); + if (pXSprite->state) sfxPlay3DSound(actor, pXSprite->data1, 0, 0); + else sfxPlay3DSound(actor, pXSprite->data2, 0, 0); break; } break; @@ -406,16 +406,16 @@ void OperateSprite(DBloodActor* actor, EVENT event) switch (event.cmd) { case kCmdOff: if (!SetSpriteState(actor, 0)) break; - sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); + sfxPlay3DSound(actor, pXSprite->data2, 0, 0); break; case kCmdOn: if (!SetSpriteState(actor, 1)) break; - sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); + sfxPlay3DSound(actor, pXSprite->data1, 0, 0); break; default: if (!SetSpriteState(actor, pXSprite->restState ^ 1)) break; - if (pXSprite->state) sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); - else sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); + if (pXSprite->state) sfxPlay3DSound(actor, pXSprite->data1, 0, 0); + else sfxPlay3DSound(actor, pXSprite->data2, 0, 0); break; } break; @@ -433,7 +433,7 @@ void OperateSprite(DBloodActor* actor, EVENT event) break; } - sfxPlay3DSound(pSprite, pXSprite->data4, -1, 0); + sfxPlay3DSound(actor, pXSprite->data4, -1, 0); if (pXSprite->command == kCmdLink && pXSprite->txID > 0) evSendActor(actor, pXSprite->txID, kCmdLink); @@ -505,7 +505,7 @@ void OperateSprite(DBloodActor* actor, EVENT event) if (pSprite->statnum != kStatRespawn) { if (event.cmd != kCmdOn) actExplodeSprite(actor); else { - sfxPlay3DSound(pSprite, 454, 0, 0); + sfxPlay3DSound(actor, 454, 0, 0); evPostActor(actor, 18, kCmdOff); } } @@ -515,12 +515,12 @@ void OperateSprite(DBloodActor* actor, EVENT event) switch (event.cmd) { case kCmdSpriteProximity: if (pXSprite->state) break; - sfxPlay3DSound(pSprite, 452, 0, 0); + sfxPlay3DSound(actor, 452, 0, 0); evPostActor(actor, 30, kCmdOff); pXSprite->state = 1; [[fallthrough]]; case kCmdOn: - sfxPlay3DSound(pSprite, 451, 0, 0); + sfxPlay3DSound(actor, 451, 0, 0); pXSprite->Proximity = 1; break; default: @@ -712,12 +712,12 @@ void SectorStartSound(sectortype* pSector, int nState) if (nState) { if (pXSprite->data3) - sfxPlay3DSound(pSprite, pXSprite->data3, 0, 0); + sfxPlay3DSound(actor, pXSprite->data3, 0, 0); } else { if (pXSprite->data1) - sfxPlay3DSound(pSprite, pXSprite->data1, 0, 0); + sfxPlay3DSound(actor, pXSprite->data1, 0, 0); } } } @@ -735,12 +735,12 @@ void SectorEndSound(sectortype* pSector, int nState) if (nState) { if (pXSprite->data2) - sfxPlay3DSound(pSprite, pXSprite->data2, 0, 0); + sfxPlay3DSound(actor, pXSprite->data2, 0, 0); } else { if (pXSprite->data4) - sfxPlay3DSound(pSprite, pXSprite->data4, 0, 0); + sfxPlay3DSound(actor, pXSprite->data4, 0, 0); } } } @@ -1393,9 +1393,9 @@ void OperateTeleport(sectortype* pSector) { assert(pSector); auto pXSector = &pSector->xs(); - auto nDest = pXSector->marker0; - assert(nDest != nullptr); - spritetype *pDest = &nDest->s(); + auto destactor = pXSector->marker0; + assert(destactor != nullptr); + spritetype *pDest = &destactor->s(); assert(pDest->statnum == kStatMarker); assert(pDest->type == kMarkerWarpDest); assert(pDest->insector()); @@ -1422,7 +1422,7 @@ void OperateTeleport(sectortype* pSector) pSprite->z += pDest->sector()->floorz - pSector->floorz; pSprite->ang = pDest->ang; ChangeActorSect(actor, pDest->sector()); - sfxPlay3DSound(pDest, 201, -1, 0); + sfxPlay3DSound(destactor, 201, -1, 0); actor->xvel = actor->yvel = actor->zvel = 0; actor->interpolated = false; viewBackupSpriteLoc(actor); @@ -2177,7 +2177,7 @@ void ActivateGenerator(DBloodActor* actor) break; } case kGenSound: - sfxPlay3DSound(pSprite, pXSprite->data2, -1, 0); + sfxPlay3DSound(actor, pXSprite->data2, -1, 0); break; case kGenMissileFireball: switch (pXSprite->data2) { @@ -2230,7 +2230,7 @@ void MGunFireSeqCallback(int, DBloodActor* actor) int dy = bsin(pSprite->ang)+Random2(1000); int dz = Random2(1000); actFireVector(actor, 0, 0, dx, dy, dz, kVectorBullet); - sfxPlay3DSound(pSprite, 359, -1, 0); + sfxPlay3DSound(actor, 359, -1, 0); } } diff --git a/source/games/blood/src/weapon.cpp b/source/games/blood/src/weapon.cpp index 64841a503..840d8f002 100644 --- a/source/games/blood/src/weapon.cpp +++ b/source/games/blood/src/weapon.cpp @@ -666,7 +666,7 @@ void WeaponLower(PLAYER *pPlayer) StartQAV(pPlayer, kQAVFORKDOWN); break; case kWeapSpraycan: - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); switch (prevState) { case 1: @@ -886,7 +886,7 @@ void WeaponUpdateState(PLAYER *pPlayer) pPlayer->weaponState = 1; StartQAV(pPlayer, kQAVCANDOWN); } - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); break; } break; @@ -965,7 +965,7 @@ void WeaponUpdateState(PLAYER *pPlayer) case 1: if (CheckAmmo(pPlayer, 2, 1)) { - sfxPlay3DSound(pPlayer->pSprite, 410, 3, 2); + sfxPlay3DSound(pPlayer->actor, 410, 3, 2); StartQAV(pPlayer, kQAVSHOTL1, nClientEjectShell); if (gInfiniteAmmo || pPlayer->ammoCount[2] > 1) pPlayer->weaponState = 3; @@ -1073,16 +1073,16 @@ void FireSpray(int, PLAYER *pPlayer) playerFireMissile(pPlayer, 0, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileFlameSpray); UseAmmo(pPlayer, 6, 4); if (CheckAmmo(pPlayer, 6, 1)) - sfxPlay3DSound(pPlayer->pSprite, 441, 1, 2); + sfxPlay3DSound(pPlayer->actor, 441, 1, 2); else - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); } void ThrowCan(int, PLAYER *pPlayer) { - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; - sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); + sfxPlay3DSound(pPlayer->actor, 455, 1, 0); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedSpray, nSpeed); if (spawned) { @@ -1096,7 +1096,7 @@ void ThrowCan(int, PLAYER *pPlayer) void DropCan(int, PLAYER *pPlayer) { - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); if (spawned) { @@ -1107,7 +1107,7 @@ void DropCan(int, PLAYER *pPlayer) void ExplodeCan(int, PLAYER *pPlayer) { - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedSpray, 0); if (spawned) { @@ -1121,9 +1121,9 @@ void ExplodeCan(int, PLAYER *pPlayer) void ThrowBundle(int, PLAYER *pPlayer) { - sfxKill3DSound(pPlayer->pSprite, 16, -1); + sfxKill3DSound(pPlayer->actor, 16, -1); int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; - sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); + sfxPlay3DSound(pPlayer->actor, 455, 1, 0); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedTNTBundle, nSpeed); if (spawned) { @@ -1138,7 +1138,7 @@ void ThrowBundle(int, PLAYER *pPlayer) void DropBundle(int, PLAYER *pPlayer) { - sfxKill3DSound(pPlayer->pSprite, 16, -1); + sfxKill3DSound(pPlayer->actor, 16, -1); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); if (spawned) { @@ -1149,7 +1149,7 @@ void DropBundle(int, PLAYER *pPlayer) void ExplodeBundle(int, PLAYER *pPlayer) { - sfxKill3DSound(pPlayer->pSprite, 16, -1); + sfxKill3DSound(pPlayer->actor, 16, -1); auto spawned = playerFireThing(pPlayer, 0, 0, kThingArmedTNTBundle, 0); if (spawned) { @@ -1164,7 +1164,7 @@ void ExplodeBundle(int, PLAYER *pPlayer) void ThrowProx(int, PLAYER *pPlayer) { int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; - sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); + sfxPlay3DSound(pPlayer->actor, 455, 1, 0); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedProxBomb, nSpeed); if (spawned) { @@ -1187,7 +1187,7 @@ void DropProx(int, PLAYER *pPlayer) void ThrowRemote(int, PLAYER *pPlayer) { int nSpeed = MulScale(pPlayer->throwPower, 0x177777, 16)+0x66666; - sfxPlay3DSound(pPlayer->pSprite, 455, 1, 0); + sfxPlay3DSound(pPlayer->actor, 455, 1, 0); auto spawned = playerFireThing(pPlayer, 0, -9460, kThingArmedRemoteBomb, nSpeed); if (spawned) { @@ -1220,13 +1220,13 @@ void FireShotgun(int nTrigger, PLAYER *pPlayer) assert(nTrigger > 0 && nTrigger <= kMaxShotgunBarrels); if (nTrigger == 1) { - sfxPlay3DSound(pPlayer->pSprite, 411, 2, 0); + sfxPlay3DSound(pPlayer->actor, 411, 2, 0); pPlayer->tiltEffect = 30; pPlayer->visibility = 20; } else { - sfxPlay3DSound(pPlayer->pSprite, 412, 2, 0); + sfxPlay3DSound(pPlayer->actor, 412, 2, 0); pPlayer->tiltEffect = 50; pPlayer->visibility = 40; } @@ -1265,7 +1265,7 @@ void FireTommy(int nTrigger, PLAYER *pPlayer) { auto actor = pPlayer->actor; Aim *aim = &pPlayer->aim; - sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0); + sfxPlay3DSound(pPlayer->actor, 431, -1, 0); switch (nTrigger) { case 1: @@ -1308,7 +1308,7 @@ void FireSpread(int nTrigger, PLAYER *pPlayer) int angle = (getangle(aim->dx, aim->dy)+((112*(nTrigger-1))/14-56))&2047; int dx = bcos(angle); int dy = bsin(angle); - sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0); + sfxPlay3DSound(pPlayer->actor, 431, -1, 0); int r1, r2, r3; r1 = Random3(300); r2 = Random3(600); @@ -1330,7 +1330,7 @@ void AltFireSpread(int nTrigger, PLAYER *pPlayer) int angle = (getangle(aim->dx, aim->dy)+((112*(nTrigger-1))/14-56))&2047; int dx = bcos(angle); int dy = bsin(angle); - sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0); + sfxPlay3DSound(pPlayer->actor, 431, -1, 0); int r1, r2, r3; r1 = Random3(300); r2 = Random3(600); @@ -1360,7 +1360,7 @@ void AltFireSpread2(int nTrigger, PLAYER *pPlayer) int angle = (getangle(aim->dx, aim->dy)+((112*(nTrigger-1))/14-56))&2047; int dx = bcos(angle); int dy = bsin(angle); - sfxPlay3DSound(pPlayer->pSprite, 431, -1, 0); + sfxPlay3DSound(pPlayer->actor, 431, -1, 0); if (powerupCheck(pPlayer, kPwUpTwoGuns) && checkAmmo2(pPlayer, 3, 2)) { int r1, r2, r3; @@ -1419,7 +1419,7 @@ void FireFlare(int nTrigger, PLAYER *pPlayer) } playerFireMissile(pPlayer, offset, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileFlareRegular); UseAmmo(pPlayer, 1, 1); - sfxPlay3DSound(pSprite, 420, 2, 0); + sfxPlay3DSound(pPlayer->actor, 420, 2, 0); pPlayer->visibility = 30; pPlayer->flashEffect = 1; } @@ -1439,7 +1439,7 @@ void AltFireFlare(int nTrigger, PLAYER *pPlayer) } playerFireMissile(pPlayer, offset, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileFlareAlt); UseAmmo(pPlayer, 1, 8); - sfxPlay3DSound(pSprite, 420, 2, 0); + sfxPlay3DSound(pPlayer->actor, 420, 2, 0); pPlayer->visibility = 45; pPlayer->flashEffect = 1; } @@ -1463,7 +1463,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer) { case 0: { - sfxPlay3DSound(pSprite, 460, 2, 0); + sfxPlay3DSound(actor, 460, 2, 0); fxSpawnBlood(targetactor, 17<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 17<<4); UseAmmo(pPlayer, 9, nDamage/4); @@ -1471,7 +1471,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer) } case 1: { - sfxPlay3DSound(pSprite, 460, 2, 0); + sfxPlay3DSound(actor, 460, 2, 0); fxSpawnBlood(targetactor, 17<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 9<<4); if (IsPlayerSprite(pTarget)) @@ -1481,7 +1481,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer) } case 3: { - sfxPlay3DSound(pSprite, 463, 2, 0); + sfxPlay3DSound(actor, 463, 2, 0); fxSpawnBlood(targetactor, 17<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 49<<4); UseAmmo(pPlayer, 9, nDamage/4); @@ -1489,7 +1489,7 @@ void FireVoodoo(int nTrigger, PLAYER *pPlayer) } case 2: { - sfxPlay3DSound(pSprite, 460, 2, 0); + sfxPlay3DSound(actor, 460, 2, 0); fxSpawnBlood(targetactor, 17<<4); int nDamage = actDamageSprite(actor, targetactor, kDamageSpirit, 11<<4); if (IsPlayerSprite(pTarget)) @@ -1585,7 +1585,7 @@ void AltFireVoodoo(int nTrigger, PLAYER *pPlayer) void DropVoodoo(int , PLAYER *pPlayer) { - sfxPlay3DSound(pPlayer->pSprite, 455, 2, 0); + sfxPlay3DSound(pPlayer->actor, 455, 2, 0); auto spawned = playerFireThing(pPlayer, 0, -4730, kThingVoodooHead, 0xccccc); if (spawned) { @@ -1636,7 +1636,7 @@ void FireTesla(int nTrigger, PLAYER *pPlayer) } playerFireMissile(pPlayer, pMissile->offset, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, pMissile->id); UseAmmo(pPlayer, 7, pMissile->ammouse); - sfxPlay3DSound(pSprite, pMissile->sound, 1, 0); + sfxPlay3DSound(pPlayer->actor, pMissile->sound, 1, 0); pPlayer->visibility = pMissile->light; pPlayer->flashEffect = pMissile->flash; } @@ -1647,7 +1647,7 @@ void AltFireTesla(int , PLAYER *pPlayer) spritetype *pSprite = pPlayer->pSprite; playerFireMissile(pPlayer, 0, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileTeslaAlt); UseAmmo(pPlayer, pPlayer->weaponAmmo, 35); - sfxPlay3DSound(pSprite, 471, 2, 0); + sfxPlay3DSound(pPlayer->actor, 471, 2, 0); pPlayer->visibility = 40; pPlayer->flashEffect = 1; } @@ -1666,7 +1666,7 @@ void FireNapalm(int nTrigger, PLAYER *pPlayer) break; } playerFireMissile(pPlayer, offset, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileFireballNapalm); - sfxPlay3DSound(pSprite, 480, 2, 0); + sfxPlay3DSound(pPlayer->actor, 480, 2, 0); UseAmmo(pPlayer, 4, 1); pPlayer->flashEffect = 1; } @@ -1676,7 +1676,7 @@ void FireNapalm2(int , PLAYER *pPlayer) spritetype *pSprite = pPlayer->pSprite; playerFireMissile(pPlayer, -120, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileFireballNapalm); playerFireMissile(pPlayer, 120, pPlayer->aim.dx, pPlayer->aim.dy, pPlayer->aim.dz, kMissileFireballNapalm); - sfxPlay3DSound(pSprite, 480, 2, 0); + sfxPlay3DSound(pPlayer->actor, 480, 2, 0); UseAmmo(pPlayer, 4, 2); pPlayer->flashEffect = 1; } @@ -1723,7 +1723,7 @@ void FireLifeLeech(int nTrigger, PLAYER *pPlayer) void AltFireLifeLeech(int , PLAYER *pPlayer) { auto actor = pPlayer->actor; - sfxPlay3DSound(pPlayer->pSprite, 455, 2, 0); + sfxPlay3DSound(pPlayer->actor, 455, 2, 0); auto missile = playerFireThing(pPlayer, 0, -4730, kThingDroppedLifeLeech, 0x19999); if (missile) { @@ -2048,7 +2048,7 @@ void WeaponProcess(PLAYER *pPlayer) { if (pPlayer->pXSprite->health == 0) { pPlayer->qavLoop = 0; - sfxKill3DSound(pPlayer->pSprite, 1, -1); + sfxKill3DSound(pPlayer->actor, 1, -1); } if (pPlayer->isUnderwater && BannedUnderwater(pPlayer->curWeapon)) { @@ -2135,7 +2135,7 @@ void WeaponProcess(PLAYER *pPlayer) { { if (pPlayer->nextWeapon) { - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); pPlayer->weaponState = 0; pPlayer->newWeapon = pPlayer->nextWeapon; pPlayer->nextWeapon = kWeapNone; @@ -2221,7 +2221,7 @@ void WeaponProcess(PLAYER *pPlayer) { { if (pPlayer->nextWeapon) { - sfxKill3DSound(pPlayer->pSprite, -1, 441); + sfxKill3DSound(pPlayer->actor, -1, 441); pPlayer->newWeapon = pPlayer->nextWeapon; pPlayer->nextWeapon = kWeapNone; } @@ -2489,7 +2489,7 @@ void WeaponProcess(PLAYER *pPlayer) { StartQAV(pPlayer, kQAVNAPFIRE, nClientFireNapalm); return; case kWeapLifeLeech: - sfxPlay3DSound(pPlayer->pSprite, 494, 2, 0); + sfxPlay3DSound(pPlayer->actor, 494, 2, 0); StartQAV(pPlayer, kQAVSTAFIRE4, nClientFireLifeLeech); return; case kWeapBeast: @@ -2586,7 +2586,7 @@ void WeaponProcess(PLAYER *pPlayer) { StartQAV(pPlayer, kQAVTOMSPRED, nClientAltFireSpread2); return; case kWeapVoodooDoll: - sfxPlay3DSound(pPlayer->pSprite, 461, 2, 0); + sfxPlay3DSound(pPlayer->actor, 461, 2, 0); StartQAV(pPlayer, kQAVVDSPEL1, nClientAltFireVoodoo); return; #if 0 @@ -2640,7 +2640,7 @@ void WeaponProcess(PLAYER *pPlayer) { case kWeapLifeLeech: if (gGameOptions.nGameType <= 1 && !checkAmmo2(pPlayer, 8, 1) && pPlayer->pXSprite->health < (25 << 4)) { - sfxPlay3DSound(pPlayer->pSprite, 494, 2, 0); + sfxPlay3DSound(pPlayer->actor, 494, 2, 0); StartQAV(pPlayer, kQAVSTAFIRE4, nClientFireLifeLeech); } else diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index fed2b204b..221dda5f9 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -92,7 +92,7 @@ void MuteSounds() }); } -class DukeSoundEngine : public SoundEngine +class DukeSoundEngine : public RazeSoundEngine { // client specific parts of the sound engine go in this class. void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan* chan) override; diff --git a/source/games/exhumed/src/sound.cpp b/source/games/exhumed/src/sound.cpp index ecd6e293c..ae790fba7 100644 --- a/source/games/exhumed/src/sound.cpp +++ b/source/games/exhumed/src/sound.cpp @@ -134,7 +134,7 @@ int nLocalChan = 0; // //========================================================================== -class EXSoundEngine : public SoundEngine +class EXSoundEngine : public RazeSoundEngine { // client specific parts of the sound engine go in this class. void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan* chan) override; diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 0acc96e1c..5fe774d21 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -416,7 +416,7 @@ static void UpdateAmbients() // //========================================================================== -class SWSoundEngine : public SoundEngine +class SWSoundEngine : public RazeSoundEngine { // client specific parts of the sound engine go in this class. void CalcPosVel(int type, const void* source, const float pt[3], int channum, int chanflags, FSoundID chanSound, FVector3* pos, FVector3* vel, FSoundChan* chan) override; @@ -430,10 +430,14 @@ public: S_Rolloff.MaxDistance = 1187; } + bool SourceIsActor(FSoundChan* chan) override + { + return chan->SourceType == SOURCE_Actor || chan->SourceType == SOURCE_Unattached; + } + int SoundSourceIndex(FSoundChan* chan) override { if (chan->SourceType == SOURCE_Player) return int(PLAYERp(chan->Source) - Player); - if (chan->SourceType == SOURCE_Unattached && chan->Source) return int(SPRITEp(chan->Source) - sprite); return 0; } @@ -444,10 +448,6 @@ public: if (index < 0 || index >= MAX_SW_PLAYERS_REG) index = 0; chan->Source = &Player[index]; } - else if (chan->SourceType == SOURCE_Unattached && index >= 0) - { - chan->Source = &sprite[index]; - } else chan->Source = nullptr; }