]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Set input coords to invalid if mouse off-screen (#30164)
authormetalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
Sun, 21 Jul 2024 06:13:28 +0000 (16:13 +1000)
committerGitHub <noreply@github.com>
Sun, 21 Jul 2024 06:13:28 +0000 (02:13 -0400)
This may be a breaking change for some stuff, I only tested basic combat stuff + throwing.

This fixes the coordinates setting an off-screen position to the top-left pixel and blocks throw attempts as a result.

Content.Client/Gameplay/GameplayStateBase.cs
Content.Server/Hands/Systems/HandsSystem.cs

index 63cbfdb09c63bd8940b731312578c7723a601b01..0a695b2c01e883359123b8394aef209759a54644 100644 (file)
@@ -185,7 +185,7 @@ namespace Content.Client.Gameplay
 
             EntityCoordinates coordinates = default;
             EntityUid? entityToClick = null;
-            if (args.Viewport is IViewportControl vp)
+            if (args.Viewport is IViewportControl vp && kArgs.PointerLocation.IsValid)
             {
                 var mousePosWorld = vp.PixelToMap(kArgs.PointerLocation.Position);
                 entityToClick = GetClickedEntity(mousePosWorld);
@@ -194,6 +194,10 @@ namespace Content.Client.Gameplay
                     grid.MapToGrid(mousePosWorld) :
                     EntityCoordinates.FromMap(_mapManager, mousePosWorld);
             }
+            else
+            {
+                coordinates = EntityCoordinates.Invalid;
+            }
 
             var message = new ClientFullInputCmdMessage(_timing.CurTick, _timing.TickFraction, funcId)
             {
index e2bb991318ff2414ee4e7bf19b80699ffb895ee4..12c2a396dedcb8075f28b173949c899aaca52538 100644 (file)
@@ -170,7 +170,7 @@ namespace Content.Server.Hands.Systems
 
         private bool HandleThrowItem(ICommonSession? playerSession, EntityCoordinates coordinates, EntityUid entity)
         {
-            if (playerSession?.AttachedEntity is not {Valid: true} player || !Exists(player))
+            if (playerSession?.AttachedEntity is not {Valid: true} player || !Exists(player) || !coordinates.IsValid(EntityManager))
                 return false;
 
             return ThrowHeldItem(player, coordinates);