Fixed stack overflow when trying to store jumpsuits in themselves
This commit is contained in:
@@ -47,8 +47,21 @@ namespace Barotrauma
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Returns true if the item owns any of the parent inventories
|
||||||
|
public virtual bool ItemOwnsSelf(Item item)
|
||||||
|
{
|
||||||
|
if (Owner == null) return false;
|
||||||
|
if (!(Owner is Item)) return false;
|
||||||
|
Item ownerItem = Owner as Item;
|
||||||
|
if (ownerItem == item) return true;
|
||||||
|
if (ownerItem.ParentInventory == null) return false;
|
||||||
|
return ownerItem.ParentInventory.ItemOwnsSelf(item);
|
||||||
|
}
|
||||||
|
|
||||||
public virtual int FindAllowedSlot(Item item)
|
public virtual int FindAllowedSlot(Item item)
|
||||||
{
|
{
|
||||||
|
if (ItemOwnsSelf(item)) return -1;
|
||||||
|
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
//item is already in the inventory!
|
//item is already in the inventory!
|
||||||
@@ -65,6 +78,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public virtual bool CanBePut(Item item, int i)
|
public virtual bool CanBePut(Item item, int i)
|
||||||
{
|
{
|
||||||
|
if (ItemOwnsSelf(item)) return false;
|
||||||
if (i < 0 || i >= Items.Length) return false;
|
if (i < 0 || i >= Items.Length) return false;
|
||||||
return (Items[i] == null);
|
return (Items[i] == null);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -16,6 +16,8 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override int FindAllowedSlot(Item item)
|
public override int FindAllowedSlot(Item item)
|
||||||
{
|
{
|
||||||
|
if (ItemOwnsSelf(item)) return -1;
|
||||||
|
|
||||||
for (int i = 0; i < capacity; i++)
|
for (int i = 0; i < capacity; i++)
|
||||||
{
|
{
|
||||||
//item is already in the inventory!
|
//item is already in the inventory!
|
||||||
@@ -34,6 +36,7 @@ namespace Barotrauma
|
|||||||
|
|
||||||
public override bool CanBePut(Item item, int i)
|
public override bool CanBePut(Item item, int i)
|
||||||
{
|
{
|
||||||
|
if (ItemOwnsSelf(item)) return false;
|
||||||
if (i < 0 || i >= Items.Length) return false;
|
if (i < 0 || i >= Items.Length) return false;
|
||||||
return (item!=null && Items[i]==null && container.CanBeContained(item));
|
return (item!=null && Items[i]==null && container.CanBeContained(item));
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user