]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix grave digging sound indefinitely playing if dug by aghost. (#26420)
authornikthechampiongr <32041239+nikthechampiongr@users.noreply.github.com>
Sun, 31 Mar 2024 08:49:46 +0000 (08:49 +0000)
committerGitHub <noreply@github.com>
Sun, 31 Mar 2024 08:49:46 +0000 (19:49 +1100)
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 <comedian_vs_clown@hotmail.com>
Content.Shared/Burial/BurialSystem.cs

index e19ac2e9c67aaebc437a1c0a792fc9212679c435..ccf5f1a298f9555f86cbabbd5d0105fc2a64a4ce 100644 (file)
@@ -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);
     }