- floatiified SW PlaySound

This commit is contained in:
Christoph Oelckers 2022-09-06 01:05:29 +02:00
parent 50668e45dd
commit 9486d39360
3 changed files with 15 additions and 24 deletions

View file

@ -1651,7 +1651,7 @@ enum
short SoundAngle(int x, int y); short SoundAngle(int x, int y);
//void PlaySound(int num, short angle, short vol); //void PlaySound(int num, short angle, short vol);
int _PlaySound(int num, DSWActor* sprite, PLAYER* player, const vec3_t *const pos, int flags, int channel, EChanFlags sndflags); int _PlaySound(int num, DSWActor* sprite, PLAYER* player, const DVector3 *const pos, int flags, int channel, EChanFlags sndflags);
void InitAmbient(int num, DSWActor* actor); void InitAmbient(int num, DSWActor* actor);
inline void PlaySound(int num, PLAYER* player, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) inline void PlaySound(int num, PLAYER* player, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE)
@ -1662,19 +1662,10 @@ inline void PlaySound(int num, int flags, int channel = 8, EChanFlags sndflags =
{ {
_PlaySound(num, nullptr, nullptr, nullptr, flags, channel, sndflags); _PlaySound(num, nullptr, nullptr, nullptr, flags, channel, sndflags);
} }
inline void PlaySound(int num, vec3_t *pos, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE) inline void PlaySound(int num, const DVector3 &pos, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE)
{
_PlaySound(num, nullptr, nullptr, pos, flags, channel, sndflags);
}
inline void PlaySound(int num, const vec3_t &pos, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE)
{ {
_PlaySound(num, nullptr, nullptr, &pos, flags, channel, sndflags); _PlaySound(num, nullptr, nullptr, &pos, flags, channel, sndflags);
} }
inline void PlaySound(int num, const DVector3& pos, int flags, int channel = 8, EChanFlags sndflags = CHANF_NONE)
{
vec3_t ppos = { int(pos.X * worldtoint), int(pos.Y * worldtoint), int(pos.Z * zworldtoint) };
_PlaySound(num, nullptr, nullptr, &ppos, flags, channel, sndflags);
}
int _PlayerSound(int num, PLAYER* pp); int _PlayerSound(int num, PLAYER* pp);
inline int PlayerSound(int num, int flags, PLAYER* pp) { return _PlayerSound(num, pp); } inline int PlayerSound(int num, int flags, PLAYER* pp) { return _PlayerSound(num, pp); }

View file

@ -625,13 +625,13 @@ void GameInterface::UpdateSounds(void)
// //
//========================================================================== //==========================================================================
int _PlaySound(int num, DSWActor* actor, PLAYER* pp, const vec3_t* const ppos, int flags, int channel, EChanFlags cflags) int _PlaySound(int num, DSWActor* actor, PLAYER* pp, const DVector3* const ppos, int flags, int channel, EChanFlags cflags)
{ {
if (Prediction || !SoundEnabled() || !soundEngine->isValidSoundId(num)) if (Prediction || !SoundEnabled() || !soundEngine->isValidSoundId(num))
return -1; return -1;
auto sps = actor; auto sps = actor;
auto pos = ppos ? *ppos : vec3_t(0, 0, 0); auto pos = ppos ? *ppos : DVector3(0, 0, 0);
auto vp = &voc[num]; auto vp = &voc[num];
int sourcetype = SOURCE_None; int sourcetype = SOURCE_None;
@ -643,13 +643,13 @@ int _PlaySound(int num, DSWActor* actor, PLAYER* pp, const vec3_t* const ppos, i
{ {
if (actor && !ppos) if (actor && !ppos)
{ {
pos = actor->int_pos(); pos = actor->spr.pos;
actor = nullptr; actor = nullptr;
sourcetype = SOURCE_Unattached; sourcetype = SOURCE_Unattached;
} }
else if (pp && !ppos) else if (pp && !ppos)
{ {
pos = pp->int_ppos(); pos = pp->pos;
pp = nullptr; pp = nullptr;
sourcetype = SOURCE_Unattached; sourcetype = SOURCE_Unattached;
} }

View file

@ -11647,7 +11647,7 @@ int InitSwordAttack(PLAYER* pp)
{ {
case ZILLA_RUN_R0: case ZILLA_RUN_R0:
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_SWORDCLANK, hit.int_hitpos(), v3df_none); PlaySound(DIGI_SWORDCLANK, hit.hitpos, v3df_none);
break; break;
case TRASHCAN: case TRASHCAN:
if (hitActor->user.WaitTics <= 0) if (hitActor->user.WaitTics <= 0)
@ -11656,7 +11656,7 @@ int InitSwordAttack(PLAYER* pp)
ChangeState(hitActor, s_TrashCanPain); ChangeState(hitActor, s_TrashCanPain);
} }
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_SWORDCLANK, hit.int_hitpos(), v3df_none); PlaySound(DIGI_SWORDCLANK, hit.hitpos, v3df_none);
PlaySound(DIGI_TRASHLID, hitActor, v3df_none); PlaySound(DIGI_TRASHLID, hitActor, v3df_none);
break; break;
case PACHINKO1: case PACHINKO1:
@ -11665,7 +11665,7 @@ int InitSwordAttack(PLAYER* pp)
case PACHINKO4: case PACHINKO4:
case 623: case 623:
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_SWORDCLANK, hit.int_hitpos(), v3df_none); PlaySound(DIGI_SWORDCLANK, hit.hitpos, v3df_none);
break; break;
} }
} }
@ -11710,7 +11710,7 @@ int InitSwordAttack(PLAYER* pp)
else else
{ {
SpawnSwordSparks(pp, hit.hitSector, hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_SWORDCLANK, hit.int_hitpos(), v3df_none); PlaySound(DIGI_SWORDCLANK, hit.hitpos, v3df_none);
} }
} }
} }
@ -11817,7 +11817,7 @@ int InitFistAttack(PLAYER* pp)
{ {
case ZILLA_RUN_R0: case ZILLA_RUN_R0:
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_ARMORHIT, hit.int_hitpos(), v3df_none); PlaySound(DIGI_ARMORHIT, hit.hitpos, v3df_none);
break; break;
case TRASHCAN: case TRASHCAN:
if (hitActor->user.WaitTics <= 0) if (hitActor->user.WaitTics <= 0)
@ -11826,7 +11826,7 @@ int InitFistAttack(PLAYER* pp)
ChangeState(hitActor, s_TrashCanPain); ChangeState(hitActor, s_TrashCanPain);
} }
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_ARMORHIT, hit.int_hitpos(), v3df_none); PlaySound(DIGI_ARMORHIT, hit.hitpos, v3df_none);
PlaySound(DIGI_TRASHLID, hitActor, v3df_none); PlaySound(DIGI_TRASHLID, hitActor, v3df_none);
break; break;
case PACHINKO1: case PACHINKO1:
@ -11835,7 +11835,7 @@ int InitFistAttack(PLAYER* pp)
case PACHINKO4: case PACHINKO4:
case 623: case 623:
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_ARMORHIT, hit.int_hitpos(), v3df_none); PlaySound(DIGI_ARMORHIT, hit.hitpos, v3df_none);
break; break;
} }
} }
@ -11863,7 +11863,7 @@ int InitFistAttack(PLAYER* pp)
case 5063: case 5063:
case 4947: case 4947:
SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, nullptr, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_ARMORHIT, hit.int_hitpos(), v3df_none); PlaySound(DIGI_ARMORHIT, hit.hitpos, v3df_none);
if (RandomRange(1000) > 700) if (RandomRange(1000) > 700)
PlayerUpdateHealth(pp,1); // Give some health PlayerUpdateHealth(pp,1); // Give some health
hitActor->spr.cstat |= (CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); hitActor->spr.cstat |= (CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN);
@ -11893,7 +11893,7 @@ int InitFistAttack(PLAYER* pp)
else else
{ {
SpawnSwordSparks(pp, hit.hitSector, hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang); SpawnSwordSparks(pp, hit.hitSector, hit.hitWall, hit.int_hitpos().X, hit.int_hitpos().Y, hit.int_hitpos().Z, daang);
PlaySound(DIGI_ARMORHIT, hit.int_hitpos(), v3df_none); PlaySound(DIGI_ARMORHIT, hit.hitpos, v3df_none);
if (PlayerTakeDamage(pp, nullptr)) if (PlayerTakeDamage(pp, nullptr))
{ {
PlayerUpdateHealth(pp, -(RandomRange(2<<8)>>8)); PlayerUpdateHealth(pp, -(RandomRange(2<<8)>>8));