Inventory.TryPutItem doesn't put an item in the inventory (or create a NetEntityEvent) if the item is already in it

This commit is contained in:
Regalis
2017-01-10 20:50:31 +02:00
parent df59f0d089
commit 3041138f03
3 changed files with 12 additions and 3 deletions
+10 -1
View File
@@ -143,7 +143,16 @@ namespace Barotrauma
/// </summary>
public override bool TryPutItem(Item item, List<InvSlotType> allowedSlots = null, bool createNetworkEvent = true)
{
if (allowedSlots == null || ! allowedSlots.Any()) return false;
if (allowedSlots == null || !allowedSlots.Any()) return false;
for (int i = 0; i < capacity; i++)
{
//already in the inventory and in a suitable slot
if (Items[i] == item && allowedSlots.Any(a => a.HasFlag(limbSlots[i])))
{
return true;
}
}
//try to place the item in LimBlot.Any slot if that's allowed
if (allowedSlots.Contains(InvSlotType.Any))
+1 -1
View File
@@ -568,7 +568,7 @@ namespace Barotrauma
else
{
var item = Entity.FindEntityByID(newItemIDs[i]) as Item;
if (item == null) continue;
if (item == null || item == Items[i]) continue;
if (GameMain.Server != null)
{
@@ -76,7 +76,7 @@ namespace Barotrauma.Networking
{
long msgPosition = msg.Position;
DebugConsole.NewMessage("received msg "+thisEventID, Microsoft.Xna.Framework.Color.Green);
DebugConsole.NewMessage("received msg "+thisEventID+ " ("+entity.ToString()+")", Microsoft.Xna.Framework.Color.Green);
lastReceivedID++;
try
{