- fixed bad StopSound implementation.

This commit is contained in:
Christoph Oelckers 2022-11-21 09:25:46 +01:00
parent fd8ac602f0
commit 29c4c77e55
3 changed files with 10 additions and 8 deletions

View file

@ -233,9 +233,9 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, PlayActorSound, DukeActor_PlayActorSou
ACTION_RETURN_INT(DukeActor_PlayActorSound(self, snd, chan, flags));
}
int DukeActor_StopSound(DDukeActor* self, int snd, int chan)
void DukeActor_StopSound(DDukeActor* self, int snd, int flags)
{
return S_PlayActorSound(snd, self, chan);
S_StopSound(snd, self, flags);
}
DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, StopSound, DukeActor_StopSound)
@ -243,7 +243,8 @@ DEFINE_ACTION_FUNCTION_NATIVE(DDukeActor, StopSound, DukeActor_StopSound)
PARAM_SELF_PROLOGUE(DDukeActor);
PARAM_INT(snd);
PARAM_INT(chan);
ACTION_RETURN_INT(DukeActor_StopSound(self, snd, chan));
DukeActor_StopSound(self, snd, chan);
return 0;
}
DDukeActor* DukeActor_Spawn(DDukeActor* origin, int intname)

View file

@ -28,9 +28,10 @@ class DukeSoundController : DukeActor
self.temp_data[0] = 0;
}
let p = Duke.GetViewPlayer();
if (self.lotag >= 1000 && self.lotag < 2000)
{
double dist = (Duke.GetViewPlayer().actor.pos.XY - self.pos.XY).LengthSquared();
double dist = (p.actor.pos.XY - self.pos.XY).LengthSquared();
if (dist < maxdist * maxdist && self.temp_data[0] == 0)
{
Raze.SetReverb(self.lotag - 1100);
@ -51,7 +52,7 @@ class DukeSoundController : DukeActor
int flags = Duke.GetSoundFlags(self.lotag);
if (flags & Duke.SF_MSFX)
{
double distance = (Duke.GetViewPlayer().actor.pos - self.pos).Length();
double distance = (p.actor.pos - self.pos).Length();
if (distance < maxdist && self.temp_data[0] == 0)
{
@ -69,7 +70,7 @@ class DukeSoundController : DukeActor
if ((flags & (Duke.SF_GLOBAL | Duke.SF_DTAG)) == Duke.SF_GLOBAL)
{
if (self.temp_data[4] > 0) self.temp_data[4]--;
else
else if (sec == p.actor.sector)
{
Duke.PlaySound(self.lotag + uint(Duke.global_random()) % uint(self.hitag + 1));
self.temp_data[4] = 26 * 40 + (Duke.global_random() % (26 * 40));

View file

@ -156,8 +156,8 @@ class DukeActor : CoreActor native
native DukePlayer, double findplayer();
native int ifhitbyweapon();
native int domove(int clipmask);
native void PlayActorSound(int snd, int chan = CHAN_AUTO, int flags = 0);
native void StopSound(int snd, int chan = -1);
native int PlayActorSound(int snd, int chan = CHAN_AUTO, int flags = 0);
native void StopSound(int snd, int flags = 0);
native DukeActor spawn(Name type);
native DukeActor spawnsprite(int type); // for cases where the map has a picnum stored. Avoid when possible.
native DukeActor spawnweaponorammo(int type);