also displaying the more specific 'no cpu' error message for servers

This commit is contained in:
Florian Nücke 2014-02-23 17:27:57 +01:00
parent 3ecf471ed0
commit 83e43f32fc
2 changed files with 10 additions and 0 deletions

View File

@ -2,6 +2,7 @@ package li.cil.oc.server.component
import li.cil.oc.Items
import li.cil.oc.api.driver
import li.cil.oc.api.driver.Slot
import li.cil.oc.api.network.{Message, Node}
import li.cil.oc.common.inventory.ComponentInventory
import li.cil.oc.common.inventory.ServerInventory
@ -61,6 +62,14 @@ class Server(val rack: tileentity.Rack, val number: Int) extends Machine.Owner {
case _ => 0
}))
def hasCPU = inventory.items.exists {
case Some(stack) => Registry.itemDriverFor(stack) match {
case Some(driver) => driver.slot(stack) == Slot.Processor
case _ => false
}
case _ => false
}
override def world = rack.world
override def markAsChanged() = rack.markAsChanged()

View File

@ -104,6 +104,7 @@ class Machine(val owner: Machine.Owner) extends ManagedComponent with Context wi
else if (componentCount > owner.maxComponents) {
crash(Settings.namespace + (owner match {
case t: tileentity.Case if !t.hasCPU => "gui.Error.NoCPU"
case s: server.component.Server if !s.hasCPU => "gui.Error.NoCPU"
case _ => "gui.Error.ComponentOverflow"
}))
false