mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-09 07:15:11 -04:00
fixed an issue that lead to invalid energy states (missing 'else'...), most notably in robots not turning on when too full; added safeguard to avoid excess energy after load to cause trouble in tryChangeBuffer
This commit is contained in:
parent
01110c0f0e
commit
bd4df5b61d
@ -64,6 +64,10 @@ trait Connector extends network.Connector with Node {
|
||||
else {
|
||||
this.synchronized(distributor match {
|
||||
case Some(d) => d.synchronized {
|
||||
if (localBuffer > localBufferSize) {
|
||||
d.changeBuffer(localBuffer - localBufferSize)
|
||||
localBuffer = localBufferSize
|
||||
}
|
||||
val newGlobalBuffer = globalBuffer + delta
|
||||
newGlobalBuffer >= 0 && newGlobalBuffer <= globalBufferSize && d.changeBuffer(delta) == 0
|
||||
}
|
||||
@ -86,7 +90,7 @@ trait Connector extends network.Connector with Node {
|
||||
if (network != null) {
|
||||
if (localBufferSize <= 0 && size > 0) d.addConnector(this)
|
||||
else if (localBufferSize > 0 && size == 0) d.removeConnector(this)
|
||||
d.globalBufferSize = math.max(d.globalBufferSize - localBufferSize + size, 0)
|
||||
else d.globalBufferSize = math.max(d.globalBufferSize - localBufferSize + size, 0)
|
||||
}
|
||||
localBufferSize = math.max(size, 0)
|
||||
val surplus = math.max(localBuffer - localBufferSize, 0)
|
||||
|
Loading…
x
Reference in New Issue
Block a user