From 595ffb3237345408fcbf2436c5e95beb88c15578 Mon Sep 17 00:00:00 2001 From: "Markus W. Halvorsen" Date: Sat, 8 Feb 2020 15:32:21 +0100 Subject: [PATCH] Clamp out of range item drops (#631) --- Content.Server/GameObjects/EntitySystems/HandsSystem.cs | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs index 1612977b76..902511511f 100644 --- a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs @@ -1,4 +1,4 @@ -using System; +using System; using Content.Server.GameObjects.Components; using Content.Server.GameObjects.Components.Stack; using Content.Server.Interfaces.GameObjects; @@ -130,7 +130,11 @@ namespace Content.Server.GameObjects.EntitySystems } else { - handsComp.Drop(handsComp.ActiveIndex); + var entCoords = ent.Transform.GridPosition.Position; + var entToDesiredDropCoords = coords.Position - entCoords; + var clampedDropCoords = ((entToDesiredDropCoords.Normalized * InteractionSystem.InteractionRange) + entCoords); + + handsComp.Drop(handsComp.ActiveIndex, new GridCoordinates(clampedDropCoords, coords.GridID)); } return true;