mirror of
https://github.com/ZDoom/gzdoom-gles.git
synced 2024-11-24 21:21:04 +00:00
- cleaned up the parameters of A_StartSound.
There were two booleans that could be merged into the flag word. This also fixes a bug with CHAN_NOSTOP not working for local sounds because it checked the wrong sound source for the playing sound.
This commit is contained in:
parent
651dfbc49f
commit
b7e1a35e6f
9 changed files with 32 additions and 40 deletions
|
@ -5911,14 +5911,9 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound)
|
|||
if (sid != 0)
|
||||
{
|
||||
// What a mess. I think it's a given that this was used with sound flags so it will forever be restricted to the original 8 channels.
|
||||
if (!looping)
|
||||
{
|
||||
S_PlaySound(spot, chan&7, EChanFlags::FromInt(chan&~7), sid, vol, atten, !!local);
|
||||
}
|
||||
else if (!S_IsActorPlayingSomething(spot, chan & 7, sid))
|
||||
{
|
||||
S_PlaySound(spot, chan&7, EChanFlags::FromInt(chan & ~7)|CHANF_LOOP, sid, vol, atten, !!local);
|
||||
}
|
||||
if (local) chan |= CHANF_LOCAL;
|
||||
if (looping) chan |= CHANF_LOOP | CHANF_NOSTOP;
|
||||
S_PlaySound(spot, chan&7, EChanFlags::FromInt(chan&~7), sid, vol, atten);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -181,11 +181,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StartSound, A_StartSound)
|
|||
PARAM_INT(channel);
|
||||
PARAM_INT(flags);
|
||||
PARAM_FLOAT(volume);
|
||||
PARAM_BOOL(looping);
|
||||
PARAM_FLOAT(attenuation);
|
||||
PARAM_BOOL(local);
|
||||
PARAM_FLOAT(pitch);
|
||||
A_StartSound(self, soundid, channel, flags, volume, looping, attenuation, local, pitch);
|
||||
A_StartSound(self, soundid, channel, flags, volume, attenuation, pitch);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -27,6 +27,7 @@ enum EChanFlag
|
|||
CHANF_VIRTUAL = 2048, // internal: Channel is currently virtual
|
||||
CHANF_NOSTOP = 4096, // only for A_PlaySound. Does not start if channel is playing something.
|
||||
CHANF_OVERLAP = 8192, // [MK] Does not stop any sounds in the channel and instead plays over them.
|
||||
CHANF_LOCAL = 16384, // only plays locally for the calling actor
|
||||
};
|
||||
|
||||
typedef TFlags<EChanFlag> EChanFlags;
|
||||
|
|
|
@ -443,50 +443,45 @@ void S_Sound (const sector_t *sec, int channel, EChanFlags flags, FSoundID sfxid
|
|||
//
|
||||
//==========================================================================
|
||||
|
||||
void S_PlaySoundPitch(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local, float pitch)
|
||||
void S_PlaySoundPitch(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, float pitch)
|
||||
{
|
||||
if (a == nullptr || a->Sector->Flags & SECF_SILENT || a->Level != primaryLevel)
|
||||
return;
|
||||
|
||||
if (!local)
|
||||
if (!(flags & CHANF_LOCAL))
|
||||
{
|
||||
S_SoundPitchActor(a, chan, flags, sid, vol, atten, pitch);
|
||||
if (!(flags & (CHANF_NOSTOP) || !S_IsActorPlayingSomething(a, chan, sid)))
|
||||
{
|
||||
S_SoundPitchActor(a, chan, flags, sid, vol, atten, pitch);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (a->CheckLocalView())
|
||||
{
|
||||
S_SoundPitch(chan, flags, sid, vol, ATTN_NONE, pitch);
|
||||
if (!(flags & (CHANF_NOSTOP) || !soundEngine->IsSourcePlayingSomething(SOURCE_None, nullptr, chan, sid)))
|
||||
{
|
||||
S_SoundPitch(chan, flags, sid, vol, ATTN_NONE, pitch);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local)
|
||||
void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten)
|
||||
{
|
||||
S_PlaySoundPitch(a, chan, flags, sid, vol, atten, local, 0.f);
|
||||
S_PlaySoundPitch(a, chan, flags, sid, vol, atten, 0.f);
|
||||
}
|
||||
|
||||
void A_StartSound(AActor *self, int soundid, int channel, int flags, double volume, int looping, double attenuation, int local, double pitch)
|
||||
void A_StartSound(AActor *self, int soundid, int channel, int flags, double volume, double attenuation, double pitch)
|
||||
{
|
||||
if (!looping)
|
||||
{
|
||||
if (!(flags & CHANF_NOSTOP) || !S_IsActorPlayingSomething(self, channel, soundid))
|
||||
{
|
||||
S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags), soundid, (float)volume, (float)attenuation, local, (float)pitch);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (!S_IsActorPlayingSomething(self, channel, soundid))
|
||||
{
|
||||
S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags) | CHANF_LOOP, soundid, (float)volume, (float)attenuation, local, (float)pitch);
|
||||
}
|
||||
}
|
||||
S_PlaySoundPitch(self, channel, EChanFlags::FromInt(flags), soundid, (float)volume, (float)attenuation, (float)pitch);
|
||||
}
|
||||
|
||||
void A_PlaySound(AActor* self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch)
|
||||
{
|
||||
A_StartSound(self, soundid, channel & 7, channel & ~7, volume, looping, attenuation, local, pitch);
|
||||
if (looping) channel |= CHANF_LOOP | CHANF_NOSTOP;
|
||||
if (local) channel |= CHANF_LOCAL;
|
||||
A_StartSound(self, soundid, channel & 7, channel & ~7, volume, attenuation, pitch);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -29,8 +29,7 @@ void S_Sound(FLevelLocals *Level, const DVector3 &pos, int channel, EChanFlags f
|
|||
void S_SoundPitchActor (AActor *ent, int channel, EChanFlags flags, FSoundID sfxid, float volume, float attenuation, float pitch);
|
||||
|
||||
// [Nash] Used by ACS and DECORATE
|
||||
void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local);
|
||||
void S_PlaySoundPitch(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten, bool local, float pitch);
|
||||
void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol, float atten);
|
||||
|
||||
// Stops a sound emanating from one of an emitter's channels.
|
||||
void S_StopSound (AActor *ent, int channel);
|
||||
|
@ -57,7 +56,7 @@ void S_ChangeActorSoundPitch(AActor *actor, int channel, double pitch);
|
|||
void S_SerializeSounds(FSerializer &arc);
|
||||
|
||||
void A_PlaySound(AActor *self, int soundid, int channel, double volume, int looping, double attenuation, int local, double pitch);
|
||||
void A_StartSound(AActor* self, int soundid, int flags, int channel, double volume, int looping, double attenuation, int local, double pitch);
|
||||
void A_StartSound(AActor* self, int soundid, int channel, int flags, double volume, double attenuation, double pitch);
|
||||
static void S_SetListener(AActor *listenactor);
|
||||
void S_SoundReset();
|
||||
void S_ResumeSound(bool state);
|
||||
|
|
|
@ -1054,8 +1054,8 @@ class Actor : Thinker native
|
|||
|
||||
deprecated("2.3") native void A_BulletAttack();
|
||||
native void A_WolfAttack(int flags = 0, sound whattoplay = "weapons/pistol", double snipe = 1.0, int maxdamage = 64, int blocksize = 128, int pointblank = 2, int longrange = 4, double runspeed = 160.0, class<Actor> pufftype = "BulletPuff");
|
||||
/*deprecated("4.3")*/ native clearscope void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0);
|
||||
native clearscope void A_StartSound(sound whattoplay, int slot, int flags = 0, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0);
|
||||
deprecated("4.3") native clearscope void A_PlaySound(sound whattoplay = "weapons/pistol", int slot = CHAN_BODY, double volume = 1.0, bool looping = false, double attenuation = ATTN_NORM, bool local = false, double pitch = 0.0);
|
||||
native clearscope void A_StartSound(sound whattoplay, int slot, int flags = 0, double volume = 1.0, double attenuation = ATTN_NORM, double pitch = 0.0);
|
||||
native void A_SoundVolume(int slot, double volume);
|
||||
native void A_SoundPitch(int slot, double pitch);
|
||||
deprecated("2.3") void A_PlayWeaponSound(sound whattoplay) { A_StartSound(whattoplay, CHAN_WEAPON); }
|
||||
|
|
|
@ -124,7 +124,7 @@ class Lightning : Actor
|
|||
if ((!thing.player && !thing.bBoss) || !(Level.maptime & 1))
|
||||
{
|
||||
thing.DamageMobj(self, target, 3, 'Electric');
|
||||
A_StartSound(AttackSound, CHAN_WEAPON, CHANF_NOSTOP, 1, false);
|
||||
A_StartSound(AttackSound, CHAN_WEAPON, CHANF_NOSTOP, 1);
|
||||
if (thing.bIsMonster && random[LightningHit]() < 64)
|
||||
{
|
||||
thing.Howl ();
|
||||
|
|
|
@ -1074,7 +1074,7 @@ class Inventory : Actor
|
|||
chan = CHAN_ITEM;
|
||||
flags = CHANF_MAYBE_LOCAL;
|
||||
}
|
||||
toucher.A_StartSound(PickupSound, chan, flags, 1, false, atten);
|
||||
toucher.A_StartSound(PickupSound, chan, flags, 1, atten);
|
||||
}
|
||||
|
||||
//===========================================================================
|
||||
|
|
|
@ -430,6 +430,10 @@ enum ESoundFlags
|
|||
CHANF_LOOP = 256,
|
||||
CHANF_NOSTOP = 4096,
|
||||
CHANF_OVERLAP = 8192,
|
||||
CHANF_LOCAL = 16384,
|
||||
|
||||
|
||||
CHANF_LOOPING = CHANF_LOOP | CHANF_NOSTOP, // convenience value for replicating the old 'looping' boolean.
|
||||
|
||||
};
|
||||
|
||||
|
|
Loading…
Reference in a new issue