mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-26 14:01:45 +00:00
Added A_StopSounds(int chanmin, int chanmax).
- If both channels are 0, completely silences the actor. - Adapted A_StopAllSounds to call A_StopSounds(0,0);
This commit is contained in:
parent
55284d46bf
commit
4cf7c6351d
6 changed files with 21 additions and 10 deletions
|
@ -142,11 +142,12 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopSound, NativeStopSound)
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopAllSounds, S_StopAllActorSounds)
|
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopSounds, S_StopActorSounds)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
|
PARAM_INT(chanmin);
|
||||||
S_StopAllActorSounds(self);
|
PARAM_INT(chanmax);
|
||||||
|
S_StopActorSounds(self, chanmin, chanmax);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -506,9 +506,9 @@ void S_StopSound (AActor *actor, int channel)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void S_StopAllActorSounds(AActor *actor)
|
void S_StopActorSounds(AActor *actor, int chanmin, int chanmax)
|
||||||
{
|
{
|
||||||
soundEngine->StopAllActorSounds(SOURCE_Actor, actor);
|
soundEngine->StopActorSounds(SOURCE_Actor, actor, chanmin, chanmax);
|
||||||
}
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
|
@ -35,7 +35,7 @@ void S_PlaySound(AActor *a, int chan, EChanFlags flags, FSoundID sid, float vol,
|
||||||
void S_StopSound (AActor *ent, int channel);
|
void S_StopSound (AActor *ent, int channel);
|
||||||
void S_StopSound (const sector_t *sec, int channel);
|
void S_StopSound (const sector_t *sec, int channel);
|
||||||
void S_StopSound (const FPolyObj *poly, int channel);
|
void S_StopSound (const FPolyObj *poly, int channel);
|
||||||
void S_StopAllActorSounds(AActor *actor);
|
void S_StopActorSounds(AActor *actor, int chanmin, int chanmax);
|
||||||
|
|
||||||
// Moves all sounds from one mobj to another
|
// Moves all sounds from one mobj to another
|
||||||
void S_RelinkSound (AActor *from, AActor *to);
|
void S_RelinkSound (AActor *from, AActor *to);
|
||||||
|
|
|
@ -912,14 +912,23 @@ void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, int
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
void SoundEngine::StopAllActorSounds(int sourcetype, const void* actor)
|
void SoundEngine::StopActorSounds(int sourcetype, const void* actor, int chanmin, int chanmax)
|
||||||
{
|
{
|
||||||
|
const bool all = (chanmin == 0 && chanmax == 0);
|
||||||
|
if (!all && chanmax > chanmin)
|
||||||
|
{
|
||||||
|
const int temp = chanmax;
|
||||||
|
chanmax = chanmin;
|
||||||
|
chanmin = temp;
|
||||||
|
}
|
||||||
|
|
||||||
FSoundChan* chan = Channels;
|
FSoundChan* chan = Channels;
|
||||||
while (chan != nullptr)
|
while (chan != nullptr)
|
||||||
{
|
{
|
||||||
FSoundChan* next = chan->NextChan;
|
FSoundChan* next = chan->NextChan;
|
||||||
if (chan->SourceType == sourcetype &&
|
if (chan->SourceType == sourcetype &&
|
||||||
chan->Source == actor)
|
chan->Source == actor &&
|
||||||
|
(all || (chan->EntChannel >= chanmin && chan->EntChannel <= chanmax)))
|
||||||
{
|
{
|
||||||
StopChannel(chan);
|
StopChannel(chan);
|
||||||
}
|
}
|
||||||
|
|
|
@ -307,7 +307,7 @@ public:
|
||||||
void StopSoundID(int sound_id);
|
void StopSoundID(int sound_id);
|
||||||
void StopSound(int channel, int sound_id = -1);
|
void StopSound(int channel, int sound_id = -1);
|
||||||
void StopSound(int sourcetype, const void* actor, int channel, int sound_id = -1);
|
void StopSound(int sourcetype, const void* actor, int channel, int sound_id = -1);
|
||||||
void StopAllActorSounds(int sourcetype, const void* actor);
|
void StopActorSounds(int sourcetype, const void* actor, int chanmin, int chanmax);
|
||||||
|
|
||||||
void RelinkSound(int sourcetype, const void* from, const void* to, const FVector3* optpos);
|
void RelinkSound(int sourcetype, const void* from, const void* to, const FVector3* optpos);
|
||||||
void ChangeSoundVolume(int sourcetype, const void* source, int channel, double dvolume);
|
void ChangeSoundVolume(int sourcetype, const void* source, int channel, double dvolume);
|
||||||
|
|
|
@ -1060,7 +1060,8 @@ class Actor : Thinker native
|
||||||
native void A_SoundPitch(int slot, double pitch);
|
native void A_SoundPitch(int slot, double pitch);
|
||||||
deprecated("2.3") void A_PlayWeaponSound(sound whattoplay) { A_StartSound(whattoplay, CHAN_WEAPON); }
|
deprecated("2.3") void A_PlayWeaponSound(sound whattoplay) { A_StartSound(whattoplay, CHAN_WEAPON); }
|
||||||
native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was...
|
native void A_StopSound(int slot = CHAN_VOICE); // Bad default but that's what is originally was...
|
||||||
native void A_StopAllSounds();
|
void A_StopAllSounds() { A_StopSounds(0,0); }
|
||||||
|
native void A_StopSounds(int chanmin, int chanmax);
|
||||||
deprecated("2.3") native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0);
|
deprecated("2.3") native void A_PlaySoundEx(sound whattoplay, name slot, bool looping = false, int attenuation = 0);
|
||||||
deprecated("2.3") native void A_StopSoundEx(name slot);
|
deprecated("2.3") native void A_StopSoundEx(name slot);
|
||||||
native clearscope bool IsActorPlayingSound(int channel, Sound snd = 0);
|
native clearscope bool IsActorPlayingSound(int channel, Sound snd = 0);
|
||||||
|
|
Loading…
Reference in a new issue