Fix various errors/exceptions (#22841)

* Fix entity storage localization

* Fix HumanoidAppearanceComponent resolve

* Fix null reference exceptions

* Fix duplicate key error

* Fix artifact error spam

* actually maybe this is what its meant to do

* Fix entities playing sounds on deletion
This commit is contained in:
Leon Friedrich
2023-12-22 02:26:08 -05:00
committed by GitHub
parent af753c13a5
commit 907b873145
9 changed files with 41 additions and 49 deletions

View File

@@ -77,7 +77,8 @@ public sealed class DefibrillatorSystem : EntitySystem
private void OnPowerCellSlotEmpty(EntityUid uid, DefibrillatorComponent component, ref PowerCellSlotEmptyEvent args) private void OnPowerCellSlotEmpty(EntityUid uid, DefibrillatorComponent component, ref PowerCellSlotEmptyEvent args)
{ {
TryDisable(uid, component); if (!TerminatingOrDeleted(uid))
TryDisable(uid, component);
} }
private void OnAfterInteract(EntityUid uid, DefibrillatorComponent component, AfterInteractEvent args) private void OnAfterInteract(EntityUid uid, DefibrillatorComponent component, AfterInteractEvent args)
@@ -139,6 +140,7 @@ public sealed class DefibrillatorSystem : EntitySystem
component.Enabled = false; component.Enabled = false;
_appearance.SetData(uid, ToggleVisuals.Toggled, false); _appearance.SetData(uid, ToggleVisuals.Toggled, false);
_audio.PlayPvs(component.PowerOffSound, uid); _audio.PlayPvs(component.PowerOffSound, uid);
return true; return true;
} }

View File

@@ -459,45 +459,24 @@ namespace Content.Server.Shuttles.Systems
if (dock.DockedWith == null) if (dock.DockedWith == null)
return; return;
if (TryComp<DoorBoltComponent>(dockUid, out var airlockA)) OnUndock(dockUid, dock.DockedWith.Value);
{ OnUndock(dock.DockedWith.Value, dockUid);
_bolts.SetBoltsWithAudio(dockUid, airlockA, false);
}
if (TryComp<DoorBoltComponent>(dock.DockedWith, out var airlockB))
{
_bolts.SetBoltsWithAudio(dock.DockedWith.Value, airlockB, false);
}
if (TryComp(dockUid, out DoorComponent? doorA))
{
if (_doorSystem.TryClose(dockUid, doorA))
{
doorA.ChangeAirtight = true;
}
}
if (TryComp(dock.DockedWith, out DoorComponent? doorB))
{
if (_doorSystem.TryClose(dock.DockedWith.Value, doorB))
{
doorB.ChangeAirtight = true;
}
}
if (LifeStage(dockUid) < EntityLifeStage.Terminating)
{
var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dockUid);
recentlyDocked.LastDocked = dock.DockedWith.Value;
}
if (TryComp(dock.DockedWith.Value, out MetaDataComponent? meta) && meta.EntityLifeStage < EntityLifeStage.Terminating)
{
var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dock.DockedWith.Value);
recentlyDocked.LastDocked = dock.DockedWith.Value;
}
Cleanup(dockUid, dock); Cleanup(dockUid, dock);
} }
private void OnUndock(EntityUid dockUid, EntityUid other)
{
if (TerminatingOrDeleted(dockUid))
return;
if (TryComp<DoorBoltComponent>(dockUid, out var airlock))
_bolts.SetBoltsWithAudio(dockUid, airlock, false);
if (TryComp(dockUid, out DoorComponent? door) && _doorSystem.TryClose(dockUid, door))
door.ChangeAirtight = true;
var recentlyDocked = EnsureComp<RecentlyDockedComponent>(dockUid);
recentlyDocked.LastDocked = other;
}
} }
} }

View File

@@ -8,6 +8,7 @@ using Robust.Server.GameObjects;
using Robust.Shared.Map; using Robust.Shared.Map;
using Robust.Shared.Map.Components; using Robust.Shared.Map.Components;
using Robust.Shared.Random; using Robust.Shared.Random;
using Robust.Shared.Utility;
namespace Content.Server.Worldgen.Systems.Debris; namespace Content.Server.Worldgen.Systems.Debris;
@@ -162,6 +163,12 @@ public sealed class DebrisFeaturePlacerSystem : BaseWorldSystem
var failures = 0; // Avoid severe log spam. var failures = 0; // Avoid severe log spam.
foreach (var point in points) foreach (var point in points)
{ {
if (component.OwnedDebris.TryGetValue(point, out var existing))
{
DebugTools.Assert(Exists(existing));
continue;
}
var pointDensity = _noiseIndex.Evaluate(uid, densityChannel, WorldGen.WorldToChunkCoords(point)); var pointDensity = _noiseIndex.Evaluate(uid, densityChannel, WorldGen.WorldToChunkCoords(point));
if (pointDensity == 0 && component.DensityClip || _random.Prob(component.RandomCancellationChance)) if (pointDensity == 0 && component.DensityClip || _random.Prob(component.RandomCancellationChance))
continue; continue;

View File

@@ -1,5 +1,4 @@
using Robust.Shared.Audio; using Robust.Shared.Serialization.TypeSerializers.Implementations;
using Robust.Shared.Serialization.TypeSerializers.Implementations;
namespace Content.Server.Xenoarchaeology.Equipment.Components; namespace Content.Server.Xenoarchaeology.Equipment.Components;
@@ -19,6 +18,6 @@ public sealed partial class ActiveArtifactAnalyzerComponent : Component
/// <summary> /// <summary>
/// What is being scanned? /// What is being scanned?
/// </summary> /// </summary>
[ViewVariables] [DataField]
public EntityUid Artifact; public EntityUid Artifact;
} }

View File

@@ -52,7 +52,7 @@ public sealed partial class ArtifactAnalyzerComponent : Component
public SoundSpecifier ScanFinishedSound = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg"); public SoundSpecifier ScanFinishedSound = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg");
#region Analysis Data #region Analysis Data
[ViewVariables] [DataField]
public EntityUid? LastAnalyzedArtifact; public EntityUid? LastAnalyzedArtifact;
[ViewVariables] [ViewVariables]

View File

@@ -195,7 +195,7 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
var canScan = false; var canScan = false;
var canPrint = false; var canPrint = false;
var points = 0; var points = 0;
if (component.AnalyzerEntity != null && TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer)) if (TryComp<ArtifactAnalyzerComponent>(component.AnalyzerEntity, out var analyzer))
{ {
artifact = analyzer.LastAnalyzedArtifact; artifact = analyzer.LastAnalyzedArtifact;
msg = GetArtifactScanMessage(analyzer); msg = GetArtifactScanMessage(analyzer);
@@ -438,9 +438,14 @@ public sealed class ArtifactAnalyzerSystem : EntitySystem
private void OnItemRemoved(EntityUid uid, ArtifactAnalyzerComponent component, ref ItemRemovedEvent args) private void OnItemRemoved(EntityUid uid, ArtifactAnalyzerComponent component, ref ItemRemovedEvent args)
{ {
// Scanners shouldn't give permanent remove vision to an artifact, and the scanned artifact doesn't have any
// component to track analyzers that have scanned it for removal if the artifact gets deleted.
// So we always clear this on removal.
component.LastAnalyzedArtifact = null;
// cancel the scan if the artifact moves off the analyzer // cancel the scan if the artifact moves off the analyzer
CancelScan(args.OtherEntity); CancelScan(args.OtherEntity);
if (component.Console != null && Exists(component.Console)) if (Exists(component.Console))
UpdateUserInterface(component.Console.Value); UpdateUserInterface(component.Console.Value);
} }

View File

@@ -67,13 +67,13 @@ public abstract class SharedHumanoidAppearanceSystem : EntitySystem
bool permanent = false, bool permanent = false,
HumanoidAppearanceComponent? humanoid = null) HumanoidAppearanceComponent? humanoid = null)
{ {
if (!Resolve(uid, ref humanoid)) if (!Resolve(uid, ref humanoid, false))
return; return;
var dirty = false; var dirty = false;
SetLayerVisibility(uid, humanoid, layer, visible, permanent, ref dirty); SetLayerVisibility(uid, humanoid, layer, visible, permanent, ref dirty);
if (dirty) if (dirty)
Dirty(humanoid); Dirty(uid, humanoid);
} }
/// <summary> /// <summary>

View File

@@ -787,7 +787,7 @@ public abstract class SharedStorageSystem : EntitySystem
if (!_sharedHandsSystem.CanDrop(player, toInsert.Value, hands)) if (!_sharedHandsSystem.CanDrop(player, toInsert.Value, hands))
{ {
_popupSystem.PopupClient(Loc.GetString("comp-storage-cant-drop"), uid, player); _popupSystem.PopupClient(Loc.GetString("comp-storage-cant-drop", ("entity", toInsert.Value)), uid, player);
return false; return false;
} }

View File

@@ -121,7 +121,7 @@ public abstract class SharedReflectSystem : EntitySystem
if (Resolve(projectile, ref projectileComp, false)) if (Resolve(projectile, ref projectileComp, false))
{ {
_adminLogger.Add(LogType.BulletHit, LogImpact.Medium, $"{ToPrettyString(user)} reflected {ToPrettyString(projectile)} from {ToPrettyString(projectileComp.Weapon!.Value)} shot by {projectileComp.Shooter!.Value}"); _adminLogger.Add(LogType.BulletHit, LogImpact.Medium, $"{ToPrettyString(user)} reflected {ToPrettyString(projectile)} from {ToPrettyString(projectileComp.Weapon)} shot by {projectileComp.Shooter}");
projectileComp.Shooter = user; projectileComp.Shooter = user;
projectileComp.Weapon = user; projectileComp.Weapon = user;