mirror of
https://github.com/ZDoom/gzdoom.git
synced 2024-11-11 07:12:02 +00:00
- added a direct native variant for A_PlaySound because this function is relatively easy to test.
This commit is contained in:
parent
61b91f9814
commit
176da5de68
4 changed files with 31 additions and 27 deletions
|
@ -958,33 +958,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_CopyFriendliness)
|
||||||
//
|
//
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_PlaySound)
|
|
||||||
{
|
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
|
||||||
PARAM_SOUND (soundid);
|
|
||||||
PARAM_INT (channel);
|
|
||||||
PARAM_FLOAT (volume);
|
|
||||||
PARAM_BOOL (looping);
|
|
||||||
PARAM_FLOAT (attenuation);
|
|
||||||
PARAM_BOOL (local);
|
|
||||||
|
|
||||||
if (!looping)
|
|
||||||
{
|
|
||||||
if (!(channel & CHAN_NOSTOP) || !S_IsActorPlayingSomething(self, channel & 7, soundid))
|
|
||||||
{
|
|
||||||
S_PlaySound(self, channel, soundid, (float)volume, (float)attenuation, local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
if (!S_IsActorPlayingSomething (self, channel&7, soundid))
|
|
||||||
{
|
|
||||||
S_PlaySound(self, channel | CHAN_LOOP, soundid, (float)volume, (float)attenuation, local);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
DEFINE_ACTION_FUNCTION(AActor, A_StopSound)
|
DEFINE_ACTION_FUNCTION(AActor, A_StopSound)
|
||||||
{
|
{
|
||||||
PARAM_SELF_PROLOGUE(AActor);
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
|
|
|
@ -1443,6 +1443,24 @@ void S_PlaySound(AActor *a, int chan, FSoundID sid, float vol, float atten, bool
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void A_PlaySound(AActor *self, int soundid, int channel, double volume, int looping, double attenuation, int local)
|
||||||
|
{
|
||||||
|
if (!looping)
|
||||||
|
{
|
||||||
|
if (!(channel & CHAN_NOSTOP) || !S_IsActorPlayingSomething(self, channel & 7, soundid))
|
||||||
|
{
|
||||||
|
S_PlaySound(self, channel, soundid, (float)volume, (float)attenuation, local);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (!S_IsActorPlayingSomething(self, channel & 7, soundid))
|
||||||
|
{
|
||||||
|
S_PlaySound(self, channel | CHAN_LOOP, soundid, (float)volume, (float)attenuation, local);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
//==========================================================================
|
//==========================================================================
|
||||||
//
|
//
|
||||||
// S_LoadSound
|
// S_LoadSound
|
||||||
|
|
|
@ -371,6 +371,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer = nullptr);
|
||||||
unsigned int S_GetMSLength(FSoundID sound);
|
unsigned int S_GetMSLength(FSoundID sound);
|
||||||
void S_ParseMusInfo();
|
void S_ParseMusInfo();
|
||||||
bool S_ParseTimeTag(const char *tag, bool *as_samples, unsigned int *time);
|
bool S_ParseTimeTag(const char *tag, bool *as_samples, unsigned int *time);
|
||||||
|
void A_PlaySound(AActor *self, int soundid, int channel, double volume, int looping, double attenuation, int local);
|
||||||
|
|
||||||
// [RH] Prints sound debug info to the screen.
|
// [RH] Prints sound debug info to the screen.
|
||||||
// Modelled after Hexen's noise cheat.
|
// Modelled after Hexen's noise cheat.
|
||||||
|
|
|
@ -1253,3 +1253,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Secplane, PointToDist, PointToDist)
|
||||||
ACTION_RETURN_FLOAT(self->PointToDist(DVector2(x, y), z));
|
ACTION_RETURN_FLOAT(self->PointToDist(DVector2(x, y), z));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
DEFINE_ACTION_FUNCTION_NATIVE(AActor, A_PlaySound, A_PlaySound)
|
||||||
|
{
|
||||||
|
PARAM_SELF_PROLOGUE(AActor);
|
||||||
|
PARAM_SOUND(soundid);
|
||||||
|
PARAM_INT(channel);
|
||||||
|
PARAM_FLOAT(volume);
|
||||||
|
PARAM_BOOL(looping);
|
||||||
|
PARAM_FLOAT(attenuation);
|
||||||
|
PARAM_BOOL(local);
|
||||||
|
A_PlaySound(self, soundid, channel, volume, looping, attenuation, local);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue