Skip to content

Commit

Permalink
Add deletion checks to verb execution (#9507)
Browse files Browse the repository at this point in the history
  • Loading branch information
ElectroJr authored Jul 7, 2022
1 parent d5628fd commit 731e9cb
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion Content.Shared/Verbs/SharedVerbSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,11 @@ private void HandleExecuteVerb(ExecuteVerbEvent args, EntitySessionEventArgs eve
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());
Expand Down Expand Up @@ -58,8 +63,10 @@ public SortedSet<Verb> GetLocalVerbs(EntityUid target, EntityUid user, List<Type
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
Expand Down

0 comments on commit 731e9cb

Please sign in to comment.