Fix fully upgraded relays being slower than they should be. Closes #1525.

This commit is contained in:
Florian Nücke 2015-11-14 10:57:52 +01:00
parent 90087b2448
commit 4b49cc6d2a
6 changed files with 11 additions and 7 deletions

View File

@ -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

View File

@ -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"
)
)

View File

@ -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

View File

@ -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)

View File

@ -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

View File

@ -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
}