Validate client input for pointing (#13115)
This commit is contained in:
@@ -98,9 +98,15 @@ namespace Content.Server.Pointing.EntitySystems
|
|||||||
|
|
||||||
public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUid pointed)
|
public bool TryPoint(ICommonSession? session, EntityCoordinates coords, EntityUid pointed)
|
||||||
{
|
{
|
||||||
var mapCoords = coords.ToMap(EntityManager);
|
if (session?.AttachedEntity is not { } player)
|
||||||
if ((session as IPlayerSession)?.ContentData()?.Mind?.CurrentEntity is not { } player)
|
|
||||||
{
|
{
|
||||||
|
Logger.Warning($"Player {session} attempted to point without any attached entity");
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!coords.IsValid(EntityManager))
|
||||||
|
{
|
||||||
|
Logger.Warning($"Player {ToPrettyString(player)} attempted to point at invalid coordinates: {coords}");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -134,6 +140,8 @@ namespace Content.Server.Pointing.EntitySystems
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
var mapCoords = coords.ToMap(EntityManager);
|
||||||
_rotateToFaceSystem.TryFaceCoordinates(player, mapCoords.Position);
|
_rotateToFaceSystem.TryFaceCoordinates(player, mapCoords.Position);
|
||||||
|
|
||||||
var arrow = EntityManager.SpawnEntity("PointingArrow", mapCoords);
|
var arrow = EntityManager.SpawnEntity("PointingArrow", mapCoords);
|
||||||
@@ -238,7 +246,10 @@ namespace Content.Server.Pointing.EntitySystems
|
|||||||
|
|
||||||
private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args)
|
private void OnPointAttempt(PointingAttemptEvent ev, EntitySessionEventArgs args)
|
||||||
{
|
{
|
||||||
TryPoint(args.SenderSession, Transform(ev.Target).Coordinates, ev.Target);
|
if (TryComp(ev.Target, out TransformComponent? xform))
|
||||||
|
TryPoint(args.SenderSession, xform.Coordinates, ev.Target);
|
||||||
|
else
|
||||||
|
Logger.Warning($"User {args.SenderSession} attempted to point at a non-existent entity uid: {ev.Target}");
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Shutdown()
|
public override void Shutdown()
|
||||||
|
|||||||
Reference in New Issue
Block a user