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 <comedian_vs_clown@hotmail.com>
(cherry picked from commit 8337493526)
This commit is contained in:
nikthechampiongr
2024-04-07 14:21:50 +02:00
committed by NullWanderer
parent 5e1671c292
commit 9f7680698d
+15 -3
View 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);
}