From 9f30ecc1b74564fd948c31db369e416b0427b40b Mon Sep 17 00:00:00 2001 From: Regalis Date: Sun, 1 May 2016 18:56:42 +0300 Subject: [PATCH] Fix for InvalidCastException when trying to send a ApplyStatusEffect network event --- Subsurface/Source/Items/CharacterInventory.cs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/Subsurface/Source/Items/CharacterInventory.cs b/Subsurface/Source/Items/CharacterInventory.cs index 4c93b5c3f..816a015db 100644 --- a/Subsurface/Source/Items/CharacterInventory.cs +++ b/Subsurface/Source/Items/CharacterInventory.cs @@ -95,7 +95,7 @@ namespace Barotrauma if (Items[slotIndex] == null) return false; //save the ID in a variable in case the statuseffect causes the item to be dropped/destroyed - int itemID = Items[slotIndex].ID; + ushort itemID = Items[slotIndex].ID; Items[slotIndex].ApplyStatusEffects(ActionType.OnUse, 1.0f, character); new NetworkEvent(NetworkEventType.ApplyStatusEffect, character.ID, true, itemID); @@ -132,6 +132,11 @@ namespace Barotrauma return false; } + public override bool CanBePut(Item item, int i) + { + return base.CanBePut(item, i) && item.AllowedSlots.Contains(limbSlots[i]); + } + /// /// If there is room, puts the item in the inventory and returns true, otherwise returns false ///