- added a direct native variant for A_PlaySound because this function is relatively easy to test.

This commit is contained in:
Christoph Oelckers 2018-11-25 18:40:26 +01:00
parent 61b91f9814
commit 176da5de68
4 changed files with 31 additions and 27 deletions

View file

@ -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)
{
PARAM_SELF_PROLOGUE(AActor);

View file

@ -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

View file

@ -371,6 +371,7 @@ sfxinfo_t *S_LoadSound(sfxinfo_t *sfx, FSoundLoadBuffer *pBuffer = nullptr);
unsigned int S_GetMSLength(FSoundID sound);
void S_ParseMusInfo();
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.
// Modelled after Hexen's noise cheat.

View file

@ -1253,3 +1253,15 @@ DEFINE_ACTION_FUNCTION_NATIVE(_Secplane, PointToDist, PointToDist)
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;
}