From faa314f790fbf00d01db8a4d9dc20171587efc46 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Mon, 2 Jun 2014 13:17:07 +0200 Subject: [PATCH] Fixed AIOOB in robot inventory size computation. --- src/main/scala/li/cil/oc/common/tileentity/Robot.scala | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala index e2c4d36ad..ff9d10905 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Robot.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Robot.scala @@ -44,7 +44,9 @@ class Robot(val isRemote: Boolean) extends traits.Computer with traits.PowerInfo // ----------------------------------------------------------------------- // - val actualInventorySize = 83 + val actualInventorySize = 86 + + def maxInventorySize = actualInventorySize - 1 - containerCount - componentCount var inventorySize = -1 @@ -524,7 +526,7 @@ class Robot(val isRemote: Boolean) extends traits.Computer with traits.PowerInfo override def hasRedstoneCard = (containerSlots ++ componentSlots).exists(slot => Option(getStackInSlot(slot)).fold(false)(driver.item.RedstoneCard.worksWith)) - private def computeInventorySize() = math.min(64, (containerSlots ++ componentSlots).foldLeft(0)((acc, slot) => acc + (Option(getStackInSlot(slot)) match { + private def computeInventorySize() = math.min(maxInventorySize, (containerSlots ++ componentSlots).foldLeft(0)((acc, slot) => acc + (Option(getStackInSlot(slot)) match { case Some(stack) => Option(Driver.driverFor(stack)) match { case Some(driver: api.driver.Inventory) => driver.inventoryCapacity(stack) case _ => 0