Fix storage destruction/deletion bug (#24882)

This commit is contained in:
Leon Friedrich
2024-02-02 19:54:48 -05:00
committed by GitHub
parent 84c5057bb5
commit 3ffa15ce34
2 changed files with 94 additions and 0 deletions

View File

@@ -198,6 +198,9 @@ public abstract class SharedEntityStorageSystem : EntitySystem
if (!ResolveStorage(uid, ref component))
return;
if (component.Open)
return;
var beforeev = new StorageBeforeOpenEvent();
RaiseLocalEvent(uid, ref beforeev);
component.Open = true;
@@ -216,6 +219,16 @@ public abstract class SharedEntityStorageSystem : EntitySystem
if (!ResolveStorage(uid, ref component))
return;
if (!component.Open)
return;
// Prevent the container from closing if it is queued for deletion. This is so that the container-emptying
// behaviour of DestructionEventArgs is respected. This exists because malicious players were using
// destructible boxes to delete entities by having two players simultaneously destroy and close the box in
// the same tick.
if (EntityManager.IsQueuedForDeletion(uid))
return;
component.Open = false;
Dirty(uid, component);