Extra-graceful entity deletions. (#3405)

This commit is contained in:
Vera Aguilera Puerto
2022-10-29 18:10:19 +02:00
committed by GitHub
parent 601feb7cc0
commit 467d391ec8
4 changed files with 98 additions and 20 deletions

View File

@@ -459,7 +459,14 @@ namespace Robust.Shared.GameObjects
{
foreach (var comp in InSafeOrder(_entCompIndex[uid]))
{
RemoveComponentImmediate(comp, uid, true);
try
{
RemoveComponentImmediate(comp, uid, true);
}
catch (Exception e)
{
Logger.Error($"Caught exception while trying to remove component from entity '{ToPrettyString(uid)}'");
}
}
// DisposeComponents means the entity is getting deleted.
@@ -507,7 +514,8 @@ namespace Robust.Shared.GameObjects
private void RemoveComponentImmediate(Component component, EntityUid uid, bool terminating)
{
if (component == null) throw new ArgumentNullException(nameof(component));
if (component == null)
throw new ArgumentNullException(nameof(component));
if (component.Owner != uid)
throw new InvalidOperationException("Component is not owned by entity.");