mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-17 11:15:12 -04:00
Little bit of API cleanup.
This commit is contained in:
parent
b3facc363e
commit
41364ad8f4
@ -72,16 +72,6 @@ public interface MachineHost extends EnvironmentHost {
|
|||||||
*/
|
*/
|
||||||
int componentSlot(String address);
|
int componentSlot(String address);
|
||||||
|
|
||||||
/**
|
|
||||||
* This is called by the machine when its state changed (which can be
|
|
||||||
* multiple times per actual game tick), to notify the owner that it should
|
|
||||||
* save its state on the next world save.
|
|
||||||
* <p/>
|
|
||||||
* This method is called from executor threads, so it must be thread-safe.
|
|
||||||
*/
|
|
||||||
// TODO Merge with {@link EnvironmentHost#markChanged} in 1.5
|
|
||||||
void markForSaving();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This is called on the owner when the machine's {@link Environment#onConnect(Node)}
|
* This is called on the owner when the machine's {@link Environment#onConnect(Node)}
|
||||||
* method gets called. This can be useful for reacting to network events
|
* method gets called. This can be useful for reacting to network events
|
||||||
|
@ -162,8 +162,6 @@ class Drone(val world: World) extends Entity(world) with MachineHost with intern
|
|||||||
|
|
||||||
override def componentSlot(address: String) = -1 // TODO
|
override def componentSlot(address: String) = -1 // TODO
|
||||||
|
|
||||||
override def markForSaving() {}
|
|
||||||
|
|
||||||
override def onMachineConnect(node: Node) {}
|
override def onMachineConnect(node: Node) {}
|
||||||
|
|
||||||
override def onMachineDisconnect(node: Node) {}
|
override def onMachineDisconnect(node: Node) {}
|
||||||
|
@ -250,8 +250,6 @@ class TabletWrapper(var stack: ItemStack, var player: EntityPlayer) extends Comp
|
|||||||
|
|
||||||
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
override def componentSlot(address: String) = components.indexWhere(_.exists(env => env.node != null && env.node.address == address))
|
||||||
|
|
||||||
override def markForSaving() {}
|
|
||||||
|
|
||||||
override def onMachineConnect(node: Node) = onConnect(node)
|
override def onMachineConnect(node: Node) = onConnect(node)
|
||||||
|
|
||||||
override def onMachineDisconnect(node: Node) = onDisconnect(node)
|
override def onMachineDisconnect(node: Node) = onDisconnect(node)
|
||||||
|
@ -261,8 +261,6 @@ class RobotProxy(val robot: Robot) extends traits.Computer with traits.PowerInfo
|
|||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
|
||||||
override def markForSaving() = robot.markForSaving()
|
|
||||||
|
|
||||||
override def hasRedstoneCard = robot.hasRedstoneCard
|
override def hasRedstoneCard = robot.hasRedstoneCard
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -34,8 +34,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
|||||||
|
|
||||||
private var _isRunning = false
|
private var _isRunning = false
|
||||||
|
|
||||||
private var markChunkDirty = false
|
|
||||||
|
|
||||||
private val _users = mutable.Set.empty[String]
|
private val _users = mutable.Set.empty[String]
|
||||||
|
|
||||||
protected def runSound = Option("computer_running")
|
protected def runSound = Option("computer_running")
|
||||||
@ -77,7 +75,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
|||||||
null
|
null
|
||||||
}
|
}
|
||||||
|
|
||||||
override def markForSaving() = markChunkDirty = true
|
|
||||||
|
|
||||||
override def onMachineConnect(node: Node) = this.onConnect(node)
|
override def onMachineConnect(node: Node) = this.onConnect(node)
|
||||||
|
|
||||||
@ -99,11 +96,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
|||||||
// GPU which would otherwise loose track of its screen).
|
// GPU which would otherwise loose track of its screen).
|
||||||
machine.update()
|
machine.update()
|
||||||
|
|
||||||
if (markChunkDirty) {
|
|
||||||
markChunkDirty = false
|
|
||||||
world.markChunkDirty(getPos, this)
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_isRunning != machine.isRunning) {
|
if (_isRunning != machine.isRunning) {
|
||||||
_isRunning = machine.isRunning
|
_isRunning = machine.isRunning
|
||||||
markDirty()
|
markDirty()
|
||||||
|
@ -94,8 +94,6 @@ class Server(val rack: tileentity.ServerRack, val slot: Int) extends Environment
|
|||||||
|
|
||||||
override def world = rack.world
|
override def world = rack.world
|
||||||
|
|
||||||
override def markForSaving() = rack.markForSaving()
|
|
||||||
|
|
||||||
override def markChanged() = rack.markChanged()
|
override def markChanged() = rack.markChanged()
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
|
@ -168,7 +168,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
}
|
}
|
||||||
case Machine.State.Paused if remainingPause > 0 =>
|
case Machine.State.Paused if remainingPause > 0 =>
|
||||||
remainingPause = 0
|
remainingPause = 0
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
true
|
true
|
||||||
case Machine.State.Stopping =>
|
case Machine.State.Stopping =>
|
||||||
switchTo(Machine.State.Restarting)
|
switchTo(Machine.State.Restarting)
|
||||||
@ -196,7 +196,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
state.push(Machine.State.Paused)
|
state.push(Machine.State.Paused)
|
||||||
}
|
}
|
||||||
remainingPause = ticksToPause
|
remainingPause = ticksToPause
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
return true
|
return true
|
||||||
}))
|
}))
|
||||||
}
|
}
|
||||||
@ -762,7 +762,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
remainIdle = 0
|
remainIdle = 0
|
||||||
|
|
||||||
// Mark state change in owner, to send it to clients.
|
// Mark state change in owner, to send it to clients.
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
})
|
})
|
||||||
|
|
||||||
// ----------------------------------------------------------------------- //
|
// ----------------------------------------------------------------------- //
|
||||||
@ -779,7 +779,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Mark state change in owner, to send it to clients.
|
// Mark state change in owner, to send it to clients.
|
||||||
host.markForSaving()
|
host.markChanged()
|
||||||
|
|
||||||
result
|
result
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package li.cil.oc.util
|
package li.cil.oc.util
|
||||||
|
|
||||||
|
import scala.annotation.tailrec
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* https://gist.github.com/viktorklang/1057513
|
* https://gist.github.com/viktorklang/1057513
|
||||||
*/
|
*/
|
||||||
@ -14,7 +16,7 @@ trait ScalaEnum {
|
|||||||
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values
|
private val _values = new AtomicReference(Vector[EnumVal]()) //Stores our enum values
|
||||||
|
|
||||||
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal
|
//Adds an EnumVal to our storage, uses CCAS to make sure it's thread safe, returns the ordinal
|
||||||
private final def addEnumVal(newVal: EnumVal): Int = {
|
@tailrec private final def addEnumVal(newVal: EnumVal): Int = {
|
||||||
import _values.get
|
import _values.get
|
||||||
import _values.{compareAndSet => CAS}
|
import _values.{compareAndSet => CAS}
|
||||||
val oldVec = get
|
val oldVec = get
|
||||||
|
Loading…
x
Reference in New Issue
Block a user