Fix admin verb PVS issue (#21406)

This commit is contained in:
Leon Friedrich
2023-11-05 02:58:26 +11:00
committed by GitHub
parent 40afc2719b
commit 6a8023cf8b
6 changed files with 59 additions and 31 deletions

View File

@@ -24,16 +24,17 @@ namespace Content.Shared.Verbs
if (user == null)
return;
var target = GetEntity(args.Target);
if (!TryGetEntity(args.Target, out var target))
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(target) || Deleted(user))
if (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(target, user.Value, args.RequestedVerb.GetType());
var verbs = GetLocalVerbs(target.Value, user.Value, args.RequestedVerb.GetType());
// Note that GetLocalVerbs might waste time checking & preparing unrelated verbs even though we know
// precisely which one we want to run. However, MOST entities will only have 1 or 2 verbs of a given type.
@@ -41,7 +42,7 @@ namespace Content.Shared.Verbs
// Find the requested verb.
if (verbs.TryGetValue(args.RequestedVerb, out var verb))
ExecuteVerb(verb, user.Value, target);
ExecuteVerb(verb, user.Value, target.Value);
}
/// <summary>