Added A_StopAllSounds.

This commit is contained in:
Major Cooke 2020-02-29 12:10:40 -06:00 committed by Christoph Oelckers
parent 3a2eaf2bfd
commit 55284d46bf
7 changed files with 47 additions and 1 deletions

View file

@ -142,6 +142,14 @@ DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopSound, NativeStopSound)
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_StopAllSounds, S_StopAllActorSounds)
{
PARAM_SELF_PROLOGUE(AActor);
S_StopAllActorSounds(self);
return 0;
}
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_SoundPitch, S_ChangeActorSoundPitch)
{
PARAM_SELF_PROLOGUE(AActor);

View file

@ -498,6 +498,18 @@ void S_StopSound (AActor *actor, int channel)
soundEngine->StopSound(SOURCE_Actor, actor, (compatflags & COMPATF_MAGICSILENCE) ? -1 : channel);
}
//==========================================================================
//
// S_StopAllActorSounds
//
// Stops all sounds on an actor.
//
//==========================================================================
void S_StopAllActorSounds(AActor *actor)
{
soundEngine->StopAllActorSounds(SOURCE_Actor, actor);
}
//==========================================================================
//

View file

@ -35,6 +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 (const sector_t *sec, int channel);
void S_StopSound (const FPolyObj *poly, int channel);
void S_StopAllActorSounds(AActor *actor);
// Moves all sounds from one mobj to another
void S_RelinkSound (AActor *from, AActor *to);

View file

@ -904,6 +904,29 @@ void SoundEngine::StopSound(int sourcetype, const void* actor, int channel, int
}
}
//==========================================================================
//
// S_StopAllActorSounds
//
// Stops all sounds on an actor.
//
//==========================================================================
void SoundEngine::StopAllActorSounds(int sourcetype, const void* actor)
{
FSoundChan* chan = Channels;
while (chan != nullptr)
{
FSoundChan* next = chan->NextChan;
if (chan->SourceType == sourcetype &&
chan->Source == actor)
{
StopChannel(chan);
}
chan = next;
}
}
//==========================================================================
//
// S_StopAllChannels

View file

@ -307,6 +307,7 @@ public:
void StopSoundID(int sound_id);
void StopSound(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 RelinkSound(int sourcetype, const void* from, const void* to, const FVector3* optpos);
void ChangeSoundVolume(int sourcetype, const void* source, int channel, double dvolume);

View file

@ -1060,6 +1060,7 @@ class Actor : Thinker native
native void A_SoundPitch(int slot, double pitch);
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_StopAllSounds();
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);
native clearscope bool IsActorPlayingSound(int channel, Sound snd = 0);

View file

@ -326,7 +326,7 @@ class Inventory : Actor
bIsMonster = false;
ChangeStatNum(STAT_INVENTORY);
// stop all sounds this item is playing.
for(int i = 1;i<=7;i++) A_StopSound(i);
A_StopAllSounds();
SetState (FindState("Held"));
}