Skip to content

Commit 985aeab

Browse files
authored
Try to fix SharedMouthStorageSystem (ss14Starlight#4789)
## Short description Asserts StorageComponent.Container isn't null. ## Why we need to add this <!-- What is the reason for adding these changes? Please post links to Discussions as well as Bug Reports here. Please describe how this will change the game balance. --> Seeing some hard-to-reproduce bugs in prod, this seems the most likely culprit. ## Media (Video/Screenshots) <!-- If your PR contains in-game changes you must provide screenshots/videos of the changes. --> N/a ## Checks <!-- check boxes for faster reviewing of your PR --> - [x] I do not require assistance to complete the PR. - [ ] Before posting/requesting review of a PR, I have verified that the changes work. - [x] I have added screenshots/videos of the changes, or this PR does not change in-game mechanics. - [x] I affirm that my changes are licensed under the [MIT License](https://github.com/ss14Starlight/space-station-14/blob/Starlight/LICENSE.TXT) and grant permission for use in this repository under its conditions. No guarantee this works so no CL
1 parent f955473 commit 985aeab

1 file changed

Lines changed: 8 additions & 6 deletions

File tree

Content.Shared/_Starlight/Storage/SharedMouthStorageSystem.cs

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,9 @@ public override void Initialize()
3232

3333
protected bool IsMouthBlocked(MouthStorageComponent component)
3434
{
35-
if (!TryComp<StorageComponent>(component.MouthId, out var storage))
35+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
36+
if (!TryComp<StorageComponent>(component.MouthId, out var storage) ||
37+
storage.Container == null)
3638
return false;
3739

3840
return storage.Container.ContainedEntities.Count > 0;
@@ -71,11 +73,11 @@ private void OnExamined(EntityUid uid, MouthStorageComponent component, Examined
7173
/// </summary>
7274
private void SpitOutMouth(EntityUid uid, MouthStorageComponent component)
7375
{
74-
if (component.MouthId == null)
75-
return;
76-
77-
if (!TryComp<StorageComponent>(component.MouthId.Value, out var storage)
78-
|| storage.Container.ContainedEntities.Count == 0)
76+
// ReSharper disable once ConditionIsAlwaysTrueOrFalseAccordingToNullableAPIContract
77+
if (component.MouthId == null ||
78+
!TryComp<StorageComponent>(component.MouthId.Value, out var storage) ||
79+
storage.Container == null ||
80+
storage.Container.ContainedEntities.Count == 0)
7981
return;
8082

8183
var dumpQueue = _container.EmptyContainer(storage.Container, true, Transform(uid).Coordinates);

0 commit comments

Comments
 (0)