From 731e9cbd9f5b31606df061e20f8f8033d4b6af92 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Thu, 7 Jul 2022 15:35:01 +1200 Subject: [PATCH] Add deletion checks to verb execution (#9507) --- Content.Shared/Verbs/SharedVerbSystem.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Verbs/SharedVerbSystem.cs b/Content.Shared/Verbs/SharedVerbSystem.cs index 8b47fb72be..3e470a00a2 100644 --- a/Content.Shared/Verbs/SharedVerbSystem.cs +++ b/Content.Shared/Verbs/SharedVerbSystem.cs @@ -24,6 +24,11 @@ namespace Content.Shared.Verbs if (user == null) return; + // It is possible that client-side prediction can cause this event to be raised after the target entity has + // been deleted. So we need to check that the entity still exists. + if (Deleted(args.Target) || Deleted(user)) + return; + // Get the list of verbs. This effectively also checks that the requested verb is in fact a valid verb that // the user can perform. var verbs = GetLocalVerbs(args.Target, user.Value, args.RequestedVerb.GetType()); @@ -58,8 +63,10 @@ namespace Content.Shared.Verbs bool canAccess = false; if (force || target == user) canAccess = true; - else if (EntityManager.EntityExists(target) && _interactionSystem.InRangeUnobstructed(user, target)) + else if (_interactionSystem.InRangeUnobstructed(user, target)) { + // Note that being in a container does not count as an obstruction for InRangeUnobstructed + // Therefore, we need extra checks to ensure the item is actually accessible: if (ContainerSystem.IsInSameOrParentContainer(user, target)) canAccess = true; else