diff --git a/src/main/resources/application.conf b/src/main/resources/application.conf index 955811673..96278a388 100644 --- a/src/main/resources/application.conf +++ b/src/main/resources/application.conf @@ -951,7 +951,7 @@ opencomputers { # The amount of ticks the delay is *reduced* by per tier of the CPU # inserted into a switch. - relayDelayUpgrade: 1 + relayDelayUpgrade: 1.5 # This is the size of the queue of a not upgraded switch. Increasing it # avoids packets being dropped when many messages are sent in a single diff --git a/src/main/scala/li/cil/oc/Settings.scala b/src/main/scala/li/cil/oc/Settings.scala index 65c407689..ae7f7432f 100644 --- a/src/main/scala/li/cil/oc/Settings.scala +++ b/src/main/scala/li/cil/oc/Settings.scala @@ -286,7 +286,7 @@ class Settings(val config: Config) { val switchDefaultMaxQueueSize = config.getInt("switch.defaultMaxQueueSize") max 1 val switchQueueSizeUpgrade = config.getInt("switch.queueSizeUpgrade") max 0 val switchDefaultRelayDelay = config.getInt("switch.defaultRelayDelay") max 1 - val switchRelayDelayUpgrade = config.getInt("switch.relayDelayUpgrade") max 0 + val switchRelayDelayUpgrade = config.getDouble("switch.relayDelayUpgrade") max 0 val switchDefaultRelayAmount = config.getInt("switch.defaultRelayAmount") max 1 val switchRelayAmountUpgrade = config.getInt("switch.relayAmountUpgrade") max 0 @@ -493,6 +493,10 @@ object Settings { "power.value.IndustrialCraft2", "power.value.Mekanism", "power.value.RedstoneFlux" + ), + // Upgrading to version 1.5.20, changed relay delay default. + VersionRange.createFromVersionSpec("[0.0, 1.5.20)") -> Array( + "switch.relayDelayUpgrade" ) ) diff --git a/src/main/scala/li/cil/oc/common/tileentity/Relay.scala b/src/main/scala/li/cil/oc/common/tileentity/Relay.scala index b10b10d3e..e906ddfb0 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Relay.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Relay.scala @@ -199,7 +199,7 @@ class Relay extends traits.SwitchLike with traits.ComponentInventory with traits private def updateLimits(slot: Int, stack: ItemStack) { Option(Driver.driverFor(stack, getClass)) match { case Some(driver) if driver.slot(stack) == Slot.CPU => - relayDelay = math.max(1, relayBaseDelay - ((driver.tier(stack) + 1) * relayDelayPerUpgrade)) + relayDelay = math.max(1, relayBaseDelay - ((driver.tier(stack) + 1) * relayDelayPerUpgrade).toInt) case Some(driver) if driver.slot(stack) == Slot.Memory => relayAmount = math.max(1, relayBaseAmount + (Delegator.subItem(stack) match { case Some(ram: item.Memory) => (ram.tier + 1) * relayAmountPerUpgrade diff --git a/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala b/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala index bbdcd1caa..b5ff9948f 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/ServerRack.scala @@ -56,7 +56,7 @@ class ServerRack extends traits.PowerAcceptor with traits.Hub with traits.PowerB var lastAccess = Array.fill(4)(0L) val builtInSwitchTier = Settings.get.serverRackSwitchTier - relayDelay = math.max(1, relayBaseDelay - (builtInSwitchTier + 1) * relayDelayPerUpgrade) + relayDelay = math.max(1, relayBaseDelay - ((builtInSwitchTier + 1) * relayDelayPerUpgrade).toInt) relayAmount = math.max(1, relayBaseAmount + (builtInSwitchTier + 1) * relayAmountPerUpgrade) maxQueueSize = math.max(1, queueBaseSize + (builtInSwitchTier + 1) * queueSizePerUpgrade) diff --git a/src/main/scala/li/cil/oc/common/tileentity/Switch.scala b/src/main/scala/li/cil/oc/common/tileentity/Switch.scala index 794893d9a..45f972270 100644 --- a/src/main/scala/li/cil/oc/common/tileentity/Switch.scala +++ b/src/main/scala/li/cil/oc/common/tileentity/Switch.scala @@ -61,7 +61,7 @@ class Switch extends traits.SwitchLike with traits.NotAnalyzable with traits.Com private def updateLimits(slot: Int, stack: ItemStack) { Option(Driver.driverFor(stack, getClass)) match { case Some(driver) if driver.slot(stack) == Slot.CPU => - relayDelay = math.max(1, relayBaseDelay - ((driver.tier(stack) + 1) * relayDelayPerUpgrade)) + relayDelay = math.max(1, relayBaseDelay - ((driver.tier(stack) + 1) * relayDelayPerUpgrade).toInt) case Some(driver) if driver.slot(stack) == Slot.Memory => relayAmount = math.max(1, relayBaseAmount + (Delegator.subItem(stack) match { case Some(ram: item.Memory) => (ram.tier + 1) * relayAmountPerUpgrade 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 d17611648..4770c6c70 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 @@ -71,7 +71,7 @@ trait Hub extends traits.Environment with SidedEnvironment { relayPacket(sourceSide, packet) } if (queue.nonEmpty) { - relayCooldown = relayDelay + relayCooldown = relayDelay - 1 } } else if (world.getTotalWorldTime % relayDelay == 0) { @@ -84,7 +84,7 @@ trait Hub extends traits.Environment with SidedEnvironment { if (packet.ttl > 0 && queue.size < maxQueueSize) { queue += sourceSide -> packet.hop() if (relayCooldown < 0) { - relayCooldown = relayDelay + relayCooldown = relayDelay - 1 } true }