From: nikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com> Date: Sun, 31 Mar 2024 08:49:46 +0000 (+0000) Subject: Fix grave digging sound indefinitely playing if dug by aghost. (#26420) X-Git-Url: https://git.smokeofanarchy.ru/gitweb.cgi?a=commitdiff_plain;h=83374935262265679e554780bcd42017238f059a;p=space-station-14.git Fix grave digging sound indefinitely playing if dug by aghost. (#26420) Admins bypass doafters. As such, the code that runs on doafter completion is ran before the sound is actually created. This then leads to the sound never being stopped, and as such it would infinitely play. This commit gets around the issue by manually stopping the sound should the doafter fail to start. If we could be sure that the doafter would never fail, then we could just move the call to StartDigging above starting the doafter but this is currently not possible. Co-authored-by: metalgearsloth --- diff --git a/Content.Shared/Burial/BurialSystem.cs b/Content.Shared/Burial/BurialSystem.cs index e19ac2e9c6..ccf5f1a298 100644 --- a/Content.Shared/Burial/BurialSystem.cs +++ b/Content.Shared/Burial/BurialSystem.cs @@ -51,8 +51,15 @@ public sealed class BurialSystem : EntitySystem BreakOnHandChange = true }; + if (component.Stream == null) + component.Stream = _audioSystem.PlayPredicted(component.DigSound, uid, args.User)?.Entity; + if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs)) + { + _audioSystem.Stop(component.Stream); return; + } + StartDigging(uid, args.User, args.Used, component); } @@ -111,8 +118,6 @@ public sealed class BurialSystem : EntitySystem { _popupSystem.PopupClient(Loc.GetString("grave-start-digging-user", ("grave", uid), ("tool", used)), user, user); _popupSystem.PopupEntity(Loc.GetString("grave-start-digging-others", ("user", user), ("grave", uid), ("tool", used)), user, Filter.PvsExcept(user), true); - if (component.Stream == null) - component.Stream = _audioSystem.PlayPredicted(component.DigSound, uid, user)?.Entity; component.ActiveShovelDigging = true; Dirty(uid, component); } @@ -163,8 +168,15 @@ public sealed class BurialSystem : EntitySystem BreakOnDamage = false }; - if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs, out component.HandDiggingDoAfter)) + + if (component.Stream == null) + component.Stream = _audioSystem.PlayPredicted(component.DigSound, uid, args.Entity)?.Entity; + + if (!_doAfterSystem.TryStartDoAfter(doAfterEventArgs)) + { + _audioSystem.Stop(component.Stream); return; + } StartDigging(uid, args.Entity, null, component); }