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

@@ -170,28 +170,27 @@ namespace Content.Client.Verbs
/// </summary>
public SortedSet<Verb> GetVerbs(EntityUid target, EntityUid user, Type type, bool force = false)
{
return GetVerbs(target, user, new List<Type>() { type }, force);
return GetVerbs(GetNetEntity(target), user, new List<Type>() { type }, force);
}
/// <summary>
/// Ask the server to send back a list of server-side verbs, and for now return an incomplete list of verbs
/// (only those defined locally).
/// </summary>
public SortedSet<Verb> GetVerbs(EntityUid target, EntityUid user, List<Type> verbTypes,
public SortedSet<Verb> GetVerbs(NetEntity target, EntityUid user, List<Type> verbTypes,
bool force = false)
{
if (!IsClientSide(target))
{
RaiseNetworkEvent(new RequestServerVerbsEvent(GetNetEntity(target), verbTypes, adminRequest: force));
}
if (!target.IsClientSide())
RaiseNetworkEvent(new RequestServerVerbsEvent(target, verbTypes, adminRequest: force));
// Some admin menu interactions will try get verbs for entities that have not yet been sent to the player.
if (!Exists(target))
if (!TryGetEntity(target, out var local))
return new();
return GetLocalVerbs(target, user, verbTypes, force);
return GetLocalVerbs(local.Value, user, verbTypes, force);
}
/// <summary>
/// Execute actions associated with the given verb.
/// </summary>
@@ -200,8 +199,18 @@ namespace Content.Client.Verbs
/// </remarks>
public void ExecuteVerb(EntityUid target, Verb verb)
{
var user = _playerManager.LocalPlayer?.ControlledEntity;
if (user == null)
ExecuteVerb(GetNetEntity(target), verb);
}
/// <summary>
/// Execute actions associated with the given verb.
/// </summary>
/// <remarks>
/// Unless this is a client-exclusive verb, this will also tell the server to run the same verb.
/// </remarks>
public void ExecuteVerb(NetEntity target, Verb verb)
{
if ( _playerManager.LocalEntity is not {} user)
return;
// is this verb actually valid?
@@ -209,16 +218,16 @@ namespace Content.Client.Verbs
{
// maybe send an informative pop-up message.
if (!string.IsNullOrWhiteSpace(verb.Message))
_popupSystem.PopupEntity(verb.Message, user.Value);
_popupSystem.PopupEntity(verb.Message, user);
return;
}
if (verb.ClientExclusive || IsClientSide(target))
if (verb.ClientExclusive || target.IsClientSide())
// is this a client exclusive (gui) verb?
ExecuteVerb(verb, user.Value, target);
ExecuteVerb(verb, user, GetEntity(target));
else
EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(GetNetEntity(target), verb));
EntityManager.RaisePredictiveEvent(new ExecuteVerbEvent(target, verb));
}
private void HandleVerbResponse(VerbsResponseEvent msg)