diff --git a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs index 6f7a60829b..ea487b3766 100644 --- a/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/InventoryComponent.cs @@ -234,7 +234,7 @@ namespace Content.Server.GameObjects var activehand = hands.GetActiveHand; if (activehand != null && activehand.Owner.TryGetComponent(out ClothingComponent clothing)) { - hands.Drop(hands.ActiveIndex, null); + hands.Drop(hands.ActiveIndex); if (!Equip(msg.Inventoryslot, clothing)) { hands.PutInHand(clothing); diff --git a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs index cae0adc626..f0b29bdb7e 100644 --- a/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs +++ b/Content.Server/GameObjects/Components/GUI/ServerHandsComponent.cs @@ -233,7 +233,6 @@ namespace Content.Server.GameObjects return true; } - public bool Drop(IEntity entity) { if (entity == null) @@ -252,6 +251,16 @@ namespace Content.Server.GameObjects public bool Drop(string slot, BaseContainer targetContainer) { + if (slot == null) + { + throw new ArgumentNullException(nameof(slot)); + } + + if (targetContainer == null) + { + throw new ArgumentNullException(nameof(targetContainer)); + } + if (!CanDrop(slot)) { return false; diff --git a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs index b49eecc305..520a9cc48f 100644 --- a/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs +++ b/Content.Server/GameObjects/Components/Items/Storage/ServerStorageComponent.cs @@ -127,20 +127,17 @@ namespace Content.Server.GameObjects { _ensureInitialCalculated(); Logger.DebugS("Storage", "Storage (UID {0}) attacked by user (UID {1}) with entity (UID {2}).", Owner.Uid, user.Uid, attackwith.Uid); - var hands = user.GetComponent(); + + if (!user.TryGetComponent(out HandsComponent hands)) + return false; + //Check that we can drop the item from our hands first otherwise we obviously cant put it inside - if (hands.Drop(hands.ActiveIndex, null)) + if (hands.Drop(hands.ActiveIndex)) { - var inserted = Insert(attackwith); - if (inserted) + if (Insert(attackwith)) { return true; } - else - { - //Return the object to the hand since its too big or something like that - hands.PutInHand(attackwith.GetComponent()); - } } return false; } diff --git a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs index 567b9b448d..4e0e72232b 100644 --- a/Content.Server/GameObjects/EntitySystems/HandsSystem.cs +++ b/Content.Server/GameObjects/EntitySystems/HandsSystem.cs @@ -154,7 +154,7 @@ namespace Content.Server.GameObjects.EntitySystems // pop off an item, or throw the single item in hand. if (!throwEnt.TryGetComponent(out StackComponent stackComp) || stackComp.Count < 2) { - handsComp.Drop(handsComp.ActiveIndex, null); + handsComp.Drop(handsComp.ActiveIndex); } else {