mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-16 02:39:48 -04:00
rack send message to mountables immediately
relay (hub) doesn't repeat message in reverse relay shows actual packets/cycle closes #3095
This commit is contained in:
parent
fac5ecbe87
commit
df1939cb0e
@ -132,12 +132,7 @@ class Rack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
protected def sendPacketToMountables(sourceSide: Option[ForgeDirection], packet: Packet): Unit = {
|
||||||
// Hub
|
|
||||||
|
|
||||||
override protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet): Unit = {
|
|
||||||
if (isRelayEnabled) super.relayPacket(sourceSide, packet)
|
|
||||||
|
|
||||||
// When a message arrives on a bus, also send it to all secondary nodes
|
// When a message arrives on a bus, also send it to all secondary nodes
|
||||||
// connected to it. Only deliver it to that very node, if it's not the
|
// connected to it. Only deliver it to that very node, if it's not the
|
||||||
// sender, to avoid loops.
|
// sender, to avoid loops.
|
||||||
@ -159,6 +154,22 @@ class Rack extends traits.PowerAcceptor with traits.Hub with traits.PowerBalance
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// ----------------------------------------------------------------------- //
|
||||||
|
// Hub
|
||||||
|
|
||||||
|
override def tryEnqueuePacket(sourceSide: Option[ForgeDirection], packet: Packet): Boolean = {
|
||||||
|
sendPacketToMountables(sourceSide, packet)
|
||||||
|
if (isRelayEnabled)
|
||||||
|
super.tryEnqueuePacket(sourceSide, packet)
|
||||||
|
else
|
||||||
|
true
|
||||||
|
}
|
||||||
|
|
||||||
|
override protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet): Unit = {
|
||||||
|
if (isRelayEnabled)
|
||||||
|
super.relayPacket(sourceSide, packet)
|
||||||
|
}
|
||||||
|
|
||||||
override protected def onPlugConnect(plug: Plug, node: Node): Unit = {
|
override protected def onPlugConnect(plug: Plug, node: Node): Unit = {
|
||||||
super.onPlugConnect(plug, node)
|
super.onPlugConnect(plug, node)
|
||||||
connectComponents()
|
connectComponents()
|
||||||
|
@ -69,8 +69,9 @@ trait Hub extends traits.Environment with SidedEnvironment {
|
|||||||
else {
|
else {
|
||||||
relayCooldown = -1
|
relayCooldown = -1
|
||||||
if (queue.nonEmpty) queue.synchronized {
|
if (queue.nonEmpty) queue.synchronized {
|
||||||
packetsPerCycleAvg += queue.size
|
val packetsToRely = math.min(queue.size, relayAmount)
|
||||||
for (i <- 0 until math.min(queue.size, relayAmount)) {
|
packetsPerCycleAvg += packetsToRely
|
||||||
|
for (i <- 0 until packetsToRely) {
|
||||||
val (sourceSide, packet) = queue.dequeue()
|
val (sourceSide, packet) = queue.dequeue()
|
||||||
relayPacket(sourceSide, packet)
|
relayPacket(sourceSide, packet)
|
||||||
}
|
}
|
||||||
@ -96,8 +97,13 @@ trait Hub extends traits.Environment with SidedEnvironment {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet) {
|
protected def relayPacket(sourceSide: Option[ForgeDirection], packet: Packet) {
|
||||||
for (side <- ForgeDirection.VALID_DIRECTIONS if Option(side) != sourceSide && sidedNode(side) != null) {
|
for (side <- ForgeDirection.VALID_DIRECTIONS) {
|
||||||
sidedNode(side).sendToReachable("network.message", packet)
|
if (sourceSide.isEmpty || sourceSide.get != side) {
|
||||||
|
val node = sidedNode(side)
|
||||||
|
if (node != null) {
|
||||||
|
node.sendToReachable("network.message", packet)
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user