From 29c4c77e555ea6b3a7b64719a4228db68e9da4b0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 21 Nov 2022 09:25:46 +0100 Subject: [PATCH] - fixed bad StopSound implementation. --- source/games/duke/src/vmexports.cpp | 7 ++++--- wadsrc/static/zscript/games/duke/actors/soundcontroller.zs | 7 ++++--- wadsrc/static/zscript/games/duke/dukeactor.zs | 4 ++-- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/source/games/duke/src/vmexports.cpp b/source/games/duke/src/vmexports.cpp index 77cd914c2..4ce1b4691 100644 --- a/source/games/duke/src/vmexports.cpp +++ b/source/games/duke/src/vmexports.cpp @@ -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) diff --git a/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs b/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs index b3f7fa6fd..ca62f5ba8 100644 --- a/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs +++ b/wadsrc/static/zscript/games/duke/actors/soundcontroller.zs @@ -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)); diff --git a/wadsrc/static/zscript/games/duke/dukeactor.zs b/wadsrc/static/zscript/games/duke/dukeactor.zs index fe06a3e48..8f9db2a03 100644 --- a/wadsrc/static/zscript/games/duke/dukeactor.zs +++ b/wadsrc/static/zscript/games/duke/dukeactor.zs @@ -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);