]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fixes round restart audio clipping (#24044)
authorHannah Giovanna Dawson <karakkaraz@gmail.com>
Sat, 20 Jan 2024 03:40:00 +0000 (03:40 +0000)
committerGitHub <noreply@github.com>
Sat, 20 Jan 2024 03:40:00 +0000 (14:40 +1100)
* Fix round end audio clipping

* weh

---------

Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
Content.Client/Audio/BackgroundAudioSystem.cs
Content.Client/GameTicking/Managers/ClientGameTicker.cs
Content.Server/GameTicking/GameTicker.RoundFlow.cs
Content.Shared/GameTicking/SharedGameTicker.cs

index 09ac1efcd6580bc4cb962e886b0d599959a2cc90..27b2dcb1b73095987bf42bd36c9f0b7243444605 100644 (file)
@@ -1,6 +1,7 @@
 using Content.Client.GameTicking.Managers;
 using Content.Client.Lobby;
 using Content.Shared.CCVar;
+using Content.Shared.GameTicking;
 using JetBrains.Annotations;
 using Robust.Client;
 using Robust.Client.State;
@@ -39,6 +40,8 @@ public sealed class BackgroundAudioSystem : EntitySystem
         _client.PlayerLeaveServer += OnLeave;
 
         _gameTicker.LobbySongUpdated += LobbySongUpdated;
+
+        SubscribeNetworkEvent<RoundRestartCleanupEvent>(PlayRestartSound);
     }
 
     public override void Shutdown()
@@ -129,4 +132,22 @@ public sealed class BackgroundAudioSystem : EntitySystem
     {
         LobbyStream = _audio.Stop(LobbyStream);
     }
+
+    private void PlayRestartSound(RoundRestartCleanupEvent ev)
+    {
+        if (!_configManager.GetCVar(CCVars.LobbyMusicEnabled))
+            return;
+
+        var file = _gameTicker.RestartSound;
+        if (string.IsNullOrEmpty(file))
+        {
+            return;
+        }
+
+        var volume = _lobbyParams.WithVolume(_lobbyParams.Volume +
+                                             SharedAudioSystem.GainToVolume(
+                                                 _configManager.GetCVar(CCVars.LobbyMusicVolume)));
+
+        _audio.PlayGlobal(file, Filter.Local(), false, volume);
+    }
 }
index a62ebab1b7bda5d81bf217dc4b727ffb11c106f5..a33a7a8e72272f2923dd3b54d0f43fdbdaec3ea2 100644 (file)
@@ -35,6 +35,7 @@ namespace Content.Client.GameTicking.Managers
         [ViewVariables] public bool AreWeReady { get; private set; }
         [ViewVariables] public bool IsGameStarted { get; private set; }
         [ViewVariables] public string? LobbySong { get; private set; }
+        [ViewVariables] public string? RestartSound { get; private set; }
         [ViewVariables] public string? LobbyBackground { get; private set; }
         [ViewVariables] public bool DisallowedLateJoin { get; private set; }
         [ViewVariables] public string? ServerInfoBlob { get; private set; }
@@ -151,6 +152,7 @@ namespace Content.Client.GameTicking.Managers
         {
             // Force an update in the event of this song being the same as the last.
             SetLobbySong(message.LobbySong, true);
+            RestartSound = message.RestartSound;
 
             // Don't open duplicate windows (mainly for replays).
             if (_window?.RoundId == message.RoundId)
index 081cf533cd3ec260a93ecf0c763bbbb66788cf7a..c3e33f90eec0c00cddb863013328166201b5d1ff 100644 (file)
@@ -385,9 +385,10 @@ namespace Content.Server.GameTicking
 
             // This ordering mechanism isn't great (no ordering of minds) but functions
             var listOfPlayerInfoFinal = listOfPlayerInfo.OrderBy(pi => pi.PlayerOOCName).ToArray();
+            var sound = _audio.GetSound(new SoundCollectionSpecifier("RoundEnd"));
 
             RaiseNetworkEvent(new RoundEndMessageEvent(gamemodeTitle, roundEndText, roundDuration, RoundId,
-                listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong));
+                listOfPlayerInfoFinal.Length, listOfPlayerInfoFinal, LobbySong, sound));
         }
 
         private async void SendRoundEndDiscordMessage()
index dac33fe5a764cbc55761ce4cea22b84517153314..7778588f97cfa4ff1733483b09ffef6e2440614b 100644 (file)
@@ -166,6 +166,10 @@ namespace Content.Shared.GameTicking
         public int PlayerCount { get; }
         public RoundEndPlayerInfo[] AllPlayersEndInfo { get; }
         public string? LobbySong;
+
+        /// <summary>
+        /// Sound gets networked due to how entity lifecycle works between client / server and to avoid clipping.
+        /// </summary>
         public string? RestartSound;
 
         public RoundEndMessageEvent(
@@ -175,7 +179,8 @@ namespace Content.Shared.GameTicking
             int roundId,
             int playerCount,
             RoundEndPlayerInfo[] allPlayersEndInfo,
-            string? lobbySong)
+            string? lobbySong,
+            string? restartSound)
         {
             GamemodeTitle = gamemodeTitle;
             RoundEndText = roundEndText;
@@ -184,6 +189,7 @@ namespace Content.Shared.GameTicking
             PlayerCount = playerCount;
             AllPlayersEndInfo = allPlayersEndInfo;
             LobbySong = lobbySong;
+            RestartSound = restartSound;
         }
     }