]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix AudioSystem nullability checks for engine PR (#32233)
authorLeon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Wed, 18 Sep 2024 01:43:30 +0000 (13:43 +1200)
committerGitHub <noreply@github.com>
Wed, 18 Sep 2024 01:43:30 +0000 (11:43 +1000)
Content.Client/Audio/AmbientSoundSystem.cs
Content.Client/Audio/ClientGlobalSoundSystem.cs
Content.Client/Audio/ContentAudioSystem.AmbientMusic.cs
Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs
Content.Client/Traits/ParacusiaSystem.cs
Content.Client/Weather/WeatherSystem.cs
Content.Server/Kitchen/EntitySystems/MicrowaveSystem.cs
Content.Server/Kitchen/EntitySystems/ReagentGrinderSystem.cs
Content.Server/Mech/Equipment/EntitySystems/MechGrabberSystem.cs
Content.Server/Salvage/SalvageSystem.Runner.cs
Content.Server/Shuttles/Systems/ShuttleSystem.FasterThanLight.cs

index ca6336b91b857c5973c5de1658f02d90a5c3fa8c..b525747aa9cd61b016671dc9363e91209afb9d72 100644 (file)
@@ -306,6 +306,9 @@ public sealed class AmbientSoundSystem : SharedAmbientSoundSystem
                     .WithMaxDistance(comp.Range);
 
                 var stream = _audio.PlayEntity(comp.Sound, Filter.Local(), uid, false, audioParams);
+                if (stream == null)
+                    continue;
+
                 _playingSounds[sourceEntity] = (stream.Value.Entity, comp.Sound, key);
                 playingCount++;
 
index 7c77865f74156da1cb535858f99d6e9fd5371c09..50c3971d95addda6943793639959f9cb63407daf 100644 (file)
@@ -67,7 +67,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
         if(!_adminAudioEnabled) return;
 
         var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
-        _adminAudio.Add(stream.Value.Entity);
+        _adminAudio.Add(stream?.Entity);
     }
 
     private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
@@ -76,7 +76,7 @@ public sealed class ClientGlobalSoundSystem : SharedGlobalSoundSystem
         if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;
 
         var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
-        _eventAudio.Add(soundEvent.Type, stream.Value.Entity);
+        _eventAudio.Add(soundEvent.Type, stream?.Entity);
     }
 
     private void PlayGameSound(GameGlobalSoundEvent soundEvent)
index d60c978ccf5c5ee44d5d8d807e5238743b6bc3c8..bf7ab26cba25ba3eef75f87dca788b49f5f26b51 100644 (file)
@@ -213,9 +213,9 @@ public sealed partial class ContentAudioSystem
             false,
             AudioParams.Default.WithVolume(_musicProto.Sound.Params.Volume + _volumeSlider));
 
-        _ambientMusicStream = strim.Value.Entity;
+        _ambientMusicStream = strim?.Entity;
 
-        if (_musicProto.FadeIn)
+        if (_musicProto.FadeIn && strim != null)
         {
             FadeIn(_ambientMusicStream, strim.Value.Component, AmbientMusicFadeTime);
         }
index 92c5b7a419153ba568c77a5b95ff156dab46b067..9864dbcb2a91bfe28aac584a15a955e3156aecc6 100644 (file)
@@ -185,7 +185,7 @@ public sealed partial class ContentAudioSystem
             false,
             _lobbySoundtrackParams.WithVolume(_lobbySoundtrackParams.Volume + SharedAudioSystem.GainToVolume(_configManager.GetCVar(CCVars.LobbyMusicVolume)))
         );
-        if (playResult.Value.Entity == default)
+        if (playResult == null)
         {
             _sawmill.Warning(
                 $"Tried to play lobby soundtrack '{{Filename}}' using {nameof(SharedAudioSystem)}.{nameof(SharedAudioSystem.PlayGlobal)} but it returned default value of EntityUid!",
index 3789f24cb0d0cd3bf0def66426ee2b673e45e327..af4d8ef278fa62f65486db45be92ef0fd860b10b 100644 (file)
@@ -69,7 +69,7 @@ public sealed class ParacusiaSystem : SharedParacusiaSystem
         var newCoords = Transform(uid).Coordinates.Offset(randomOffset);
 
         // Play the sound
-        paracusia.Stream = _audio.PlayStatic(paracusia.Sounds, uid, newCoords).Value.Entity;
+        paracusia.Stream = _audio.PlayStatic(paracusia.Sounds, uid, newCoords)?.Entity;
     }
 
 }
index a0e8a44f40be63dcc56a209a6e2950df295ae060..975831392cb7b85796ad3f601b99104023d7be07 100644 (file)
@@ -47,10 +47,11 @@ public sealed class WeatherSystem : SharedWeatherSystem
         if (!Timing.IsFirstTimePredicted || weatherProto.Sound == null)
             return;
 
-        weather.Stream ??= _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true).Value.Entity;
+        weather.Stream ??= _audio.PlayGlobal(weatherProto.Sound, Filter.Local(), true)?.Entity;
+
+        if (!TryComp(weather.Stream, out AudioComponent? comp))
+            return;
 
-        var stream = weather.Stream.Value;
-        var comp = Comp<AudioComponent>(stream);
         var occlusion = 0f;
 
         // Work out tiles nearby to determine volume.
@@ -115,7 +116,7 @@ public sealed class WeatherSystem : SharedWeatherSystem
 
         var alpha = GetPercent(weather, uid);
         alpha *= SharedAudioSystem.VolumeToGain(weatherProto.Sound.Params.Volume);
-        _audio.SetGain(stream, alpha, comp);
+        _audio.SetGain(weather.Stream, alpha, comp);
         comp.Occlusion = occlusion;
     }
 
index 9f43f760185fbe2337f930c06bd3380b86e0beb0..1ac02ac88258a83ccd9949403d6b71c5c1adee98 100644 (file)
@@ -112,7 +112,7 @@ namespace Content.Server.Kitchen.EntitySystems
             SetAppearance(ent.Owner, MicrowaveVisualState.Cooking, microwaveComponent);
 
             microwaveComponent.PlayingStream =
-                _audio.PlayPvs(microwaveComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5)).Value.Entity;
+                _audio.PlayPvs(microwaveComponent.LoopingSound, ent, AudioParams.Default.WithLoop(true).WithMaxDistance(5))?.Entity;
         }
 
         private void OnCookStop(Entity<ActiveMicrowaveComponent> ent, ref ComponentShutdown args)
index 71536ddf8ebe9c2e5e63a812813a19be2431ee47..12c5a30a4b29ec62b8ee2e4dec42a373998b8d8e 100644 (file)
@@ -305,7 +305,7 @@ namespace Content.Server.Kitchen.EntitySystems
             active.Program = program;
 
             reagentGrinder.AudioStream = _audioSystem.PlayPvs(sound, uid,
-                AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier)).Value.Entity; //slightly higher pitched
+                AudioParams.Default.WithPitchScale(1 / reagentGrinder.WorkTimeMultiplier))?.Entity; //slightly higher pitched
             _userInterfaceSystem.ServerSendUiMessage(uid, ReagentGrinderUiKey.Key,
                 new ReagentGrinderWorkStartedMessage(program));
         }
index aa28a8063c0de14cc4cee3e669675c52fc5b172b..08120f5c296face68e4f72bf3c598521279f05ab 100644 (file)
@@ -155,7 +155,7 @@ public sealed class MechGrabberSystem : EntitySystem
             return;
 
         args.Handled = true;
-        component.AudioStream = _audio.PlayPvs(component.GrabSound, uid).Value.Entity;
+        component.AudioStream = _audio.PlayPvs(component.GrabSound, uid)?.Entity;
         var doAfterArgs = new DoAfterArgs(EntityManager, args.User, component.GrabDelay, new GrabberDoAfterEvent(), uid, target: target, used: uid)
         {
             BreakOnMove = true
index 23a575413ed57087bb52af7f3a26bef07886ac94..921d966709418f631e60628ea001a98aa905329f 100644 (file)
@@ -154,8 +154,8 @@ public sealed partial class SalvageSystem
             }
             else if (comp.Stream == null && remaining < audioLength)
             {
-                var audio = _audio.PlayPvs(comp.Sound, uid).Value;
-                comp.Stream = audio.Entity;
+                var audio = _audio.PlayPvs(comp.Sound, uid);
+                comp.Stream = audio?.Entity;
                 _audio.SetMapAudio(audio);
                 comp.Stage = ExpeditionStage.MusicCountdown;
                 Dirty(uid, comp);
index e544c1538d15b68e7530e6718457de6e73756ca9..ce6a914847f93db17e1f2d4ff4ec9ac78363ef2b 100644 (file)
@@ -397,7 +397,8 @@ public sealed partial class ShuttleSystem
                 new EntityCoordinates(fromMapUid.Value, _mapSystem.GetGridPosition(entity.Owner)), true, startupAudio.Params);
 
             _audio.SetPlaybackPosition(clippedAudio, entity.Comp1.StartupTime);
-            clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion;
+            if (clippedAudio != null)
+                clippedAudio.Value.Component.Flags |= AudioFlags.NoOcclusion;
         }
 
         // Offset the start by buffer range just to avoid overlap.