diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 3b98568f6..ae25da23e 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -759,6 +759,23 @@ opencomputers { threads: 4 } + switch { + # This is the size of a queue of a not upgraded switch. + # Increasing it allows to send more messages in a single burst + defaultMaxQueueSize: 20 + + # This is the amount of additional queue spaces per half upgrade tier + # For tier 1 this is multiplied with 1, for 1.5 its muliplied with 2 and so on + queueSizeUpgrade: 5 + + # The delay a Switch has by default (in ticks). WARNING: A too + # low value can cause lag lag on the server. + defaultRelayDelay: 5 + + # The amount of ticks the delay is *reduced* by per level + relayDelayUpgrade: 1 + } + # Other settings that you might find useful to tweak. misc { # The maximum width of multi-block screens, in blocks. diff --git a/src/main/resources/assets/opencomputers/lang/de_DE.lang b/src/main/resources/assets/opencomputers/lang/de_DE.lang index de16510d4..a1713c10a 100644 --- a/src/main/resources/assets/opencomputers/lang/de_DE.lang +++ b/src/main/resources/assets/opencomputers/lang/de_DE.lang @@ -155,7 +155,7 @@ oc:container.Disassembler=Recycler oc:container.DiskDrive=Diskettenlaufwerk oc:container.Rack=Serverschrank oc:container.Server=Server -oc:container.Router=Switch +oc:container.Switch=Switch # Keybinds key.materialCosts=Materialkosten anzeigen diff --git a/src/main/resources/assets/opencomputers/lang/en_US.lang b/src/main/resources/assets/opencomputers/lang/en_US.lang index 0c532c6e3..70fb5cc65 100644 --- a/src/main/resources/assets/opencomputers/lang/en_US.lang +++ b/src/main/resources/assets/opencomputers/lang/en_US.lang @@ -154,7 +154,7 @@ oc:container.Case=Computer oc:container.Disassembler=Disassembler oc:container.DiskDrive=Disk Drive oc:container.Rack=Server Rack -oc:container.Router=Switch +oc:container.Switch=Switch oc:container.Server=Server # Keybinds diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index c673cd4ce..043701e5f 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -197,6 +197,13 @@ class Settings(config: Config) { val maxConnections = config.getInt("internet.maxTcpConnections") max 0 val internetThreads = config.getInt("internet.threads") max 1 + // ----------------------------------------------------------------------- // + // switch + val switchDefaultMaxQueueSize = config.getInt("switch.defaultMaxQueueSize") max 1 + val switchQueueSizeUpgrade = config.getInt("switch.queueSizeUpgrade") max 0 + val switchRelayDelayUpgrade = config.getInt("switch.relayDelayUpgrade") max 0 + val switchDefaultRelayDelay = config.getInt("switch.defaultRelayDelay") max switchRelayDelayUpgrade * 3 + // ----------------------------------------------------------------------- // // misc val maxScreenWidth = config.getInt("misc.maxScreenWidth") max 1 diff --git a/src/main/scala/li/cil/oc/common/GuiType.scala b/src/main/scala/li/cil/oc/common/GuiType.scala index 33f009d37..ed3f94b7b 100644 --- a/src/main/scala/li/cil/oc/common/GuiType.scala +++ b/src/main/scala/li/cil/oc/common/GuiType.scala @@ -13,7 +13,7 @@ object GuiType extends Enumeration { Server, Tablet, Terminal, - Router + Switch = Value } diff --git a/src/main/scala/li/cil/oc/common/block/Switch.scala b/src/main/scala/li/cil/oc/common/block/Switch.scala index 57c65af85..f3abc4045 100644 --- a/src/main/scala/li/cil/oc/common/block/Switch.scala +++ b/src/main/scala/li/cil/oc/common/block/Switch.scala @@ -47,10 +47,10 @@ class Switch(val parent: SimpleDelegator) extends SimpleDelegate { override def rightClick(world: World, x: Int, y: Int, z: Int, player: EntityPlayer, side: ForgeDirection, hitX: Float, hitY: Float, hitZ: Float) = { world.getBlockTileEntity(x, y, z) match { - case drive: tileentity.Router => + case switch: tileentity.Router => if (!player.isSneaking) { if (!world.isRemote) { - player.openGui(OpenComputers, GuiType.Router.id, world, x, y, z) + player.openGui(OpenComputers, GuiType.Switch.id, world, x, y, z) } true } diff --git a/src/main/scala/li/cil/oc/common/tileentity/Router.scala b/src/main/scala/li/cil/oc/common/tileentity/Router.scala index 095b3aec9..86e0c2e71 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Router.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Router.scala @@ -163,12 +163,13 @@ class Router extends traits.Hub with traits.NotAnalyzable with IPeripheral with super.onItemAdded(slot, stack) slot match { case 1 => - maxQueueSize = 20 + (Items.multi.subItem(stack) match { - case Some(ram: item.Memory) => (ram.tier + 1) * 5 - case _ => (Driver.driverFor(stack).tier(stack) + 1) * 10 + maxQueueSize = queueDefaultSize + (Items.multi.subItem(stack) match { + case Some(ram: item.Memory) => (ram.tier + 1) * queueUpgradeSize + case _ => (Driver.driverFor(stack).tier(stack) + 1) * (queueUpgradeSize * 2) }) case 0 => - relayDelay = 5 - Driver.driverFor(stack).tier(stack) + relayDelay = relayDefaultDelay - + (Driver.driverFor(stack).tier(stack) * relayUpgradeDelay) } } @@ -176,8 +177,8 @@ class Router extends traits.Hub with traits.NotAnalyzable with IPeripheral with override protected def onItemRemoved(slot: Int, stack: ItemStack) { super.onItemRemoved(slot, stack) slot match { - case 0 => relayDelay = 5 - case 1 => maxQueueSize = 20 + case 0 => relayDelay = Settings.get.switchDefaultRelayDelay + case 1 => maxQueueSize = Settings.get.switchDefaultMaxQueueSize } } diff --git a/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala b/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala index 1760ae06c..e5bd41a22 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/traits/Hub.scala @@ -19,11 +19,16 @@ trait Hub extends traits.Environment with SidedEnvironment { protected val queue = mutable.Queue.empty[(ForgeDirection, Packet)] - protected var maxQueueSize = 20 + protected val queueDefaultSize = Settings.get.switchDefaultMaxQueueSize + protected val queueUpgradeSize = Settings.get.switchQueueSizeUpgrade + protected val relayDefaultDelay = Settings.get.switchDefaultRelayDelay + protected val relayUpgradeDelay = Settings.get.switchRelayDelayUpgrade + + protected var maxQueueSize = Settings.get.switchDefaultMaxQueueSize protected var relayCooldown = -1 - protected var relayDelay = 5 + protected var relayDelay = Settings.get.switchDefaultRelayDelay // ----------------------------------------------------------------------- //