diff --git a/src/main/java/dan200/computercraft/core/computer/Computer.java b/src/main/java/dan200/computercraft/core/computer/Computer.java index ca45ee420..2f9354031 100644 --- a/src/main/java/dan200/computercraft/core/computer/Computer.java +++ b/src/main/java/dan200/computercraft/core/computer/Computer.java @@ -14,8 +14,8 @@ import dan200.computercraft.api.peripheral.IPeripheral; import dan200.computercraft.core.apis.*; import dan200.computercraft.core.filesystem.FileSystem; import dan200.computercraft.core.filesystem.FileSystemException; -import dan200.computercraft.core.lua.ILuaMachine; import dan200.computercraft.core.lua.CobaltLuaMachine; +import dan200.computercraft.core.lua.ILuaMachine; import dan200.computercraft.core.terminal.Terminal; import java.io.IOException; @@ -420,14 +420,13 @@ public class Computer } } - public boolean pollChanged() + public boolean pollAndResetChanged() { - return m_externalOutputChanged; - } - - public void clearChanged() - { - m_externalOutputChanged = false; + synchronized(this) { + boolean changed = m_externalOutputChanged; + m_externalOutputChanged = false; + return changed; + } } public boolean isBlinking() @@ -687,6 +686,7 @@ public class Computer return; } m_state = State.Starting; + m_externalOutputChanged = true; m_ticksSinceStart = 0; } @@ -746,6 +746,7 @@ public class Computer // Start a new state m_state = State.Running; + m_externalOutputChanged = true; synchronized( m_machine ) { m_machine.handleEvent( null, null ); @@ -764,6 +765,7 @@ public class Computer return; } m_state = State.Stopping; + m_externalOutputChanged = true; } // Turn the computercraft off @@ -827,6 +829,7 @@ public class Computer } m_state = State.Off; + m_externalOutputChanged = true; if( reboot ) { m_startRequested = true; diff --git a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java index dd92b319f..5fe0d6d41 100644 --- a/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java +++ b/src/main/java/dan200/computercraft/shared/computer/core/ServerComputer.java @@ -100,8 +100,7 @@ public class ServerComputer extends ServerTerminal super.update(); m_computer.advance( 0.05 ); - m_changedLastFrame = m_changed || m_computer.pollChanged(); - m_computer.clearChanged(); + m_changedLastFrame = m_computer.pollAndResetChanged() || m_changed; m_changed = false; m_ticksSincePing++;