mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -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);
|
||||
|
||||
/**
|
||||
* 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)}
|
||||
* 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 markForSaving() {}
|
||||
|
||||
override def onMachineConnect(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 markForSaving() {}
|
||||
|
||||
override def onMachineConnect(node: Node) = onConnect(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
|
||||
|
||||
// ----------------------------------------------------------------------- //
|
||||
|
@ -34,8 +34,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
|
||||
private var _isRunning = false
|
||||
|
||||
private var markChunkDirty = false
|
||||
|
||||
private val _users = mutable.Set.empty[String]
|
||||
|
||||
protected def runSound = Option("computer_running")
|
||||
@ -77,7 +75,6 @@ trait Computer extends Environment with ComponentInventory with Rotatable with B
|
||||
null
|
||||
}
|
||||
|
||||
override def markForSaving() = markChunkDirty = true
|
||||
|
||||
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).
|
||||
machine.update()
|
||||
|
||||
if (markChunkDirty) {
|
||||
markChunkDirty = false
|
||||
world.markChunkDirty(getPos, this)
|
||||
}
|
||||
|
||||
if (_isRunning != machine.isRunning) {
|
||||
_isRunning = machine.isRunning
|
||||
markDirty()
|
||||
|
@ -94,8 +94,6 @@ class Server(val rack: tileentity.ServerRack, val slot: Int) extends Environment
|
||||
|
||||
override def world = rack.world
|
||||
|
||||
override def markForSaving() = rack.markForSaving()
|
||||
|
||||
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 =>
|
||||
remainingPause = 0
|
||||
host.markForSaving()
|
||||
host.markChanged()
|
||||
true
|
||||
case Machine.State.Stopping =>
|
||||
switchTo(Machine.State.Restarting)
|
||||
@ -196,7 +196,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
||||
state.push(Machine.State.Paused)
|
||||
}
|
||||
remainingPause = ticksToPause
|
||||
host.markForSaving()
|
||||
host.markChanged()
|
||||
return true
|
||||
}))
|
||||
}
|
||||
@ -762,7 +762,7 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
||||
remainIdle = 0
|
||||
|
||||
// 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.
|
||||
host.markForSaving()
|
||||
host.markChanged()
|
||||
|
||||
result
|
||||
}
|
||||
|
@ -1,5 +1,7 @@
|
||||
package li.cil.oc.util
|
||||
|
||||
import scala.annotation.tailrec
|
||||
|
||||
/**
|
||||
* https://gist.github.com/viktorklang/1057513
|
||||
*/
|
||||
@ -14,7 +16,7 @@ trait ScalaEnum {
|
||||
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
|
||||
private final def addEnumVal(newVal: EnumVal): Int = {
|
||||
@tailrec private final def addEnumVal(newVal: EnumVal): Int = {
|
||||
import _values.get
|
||||
import _values.{compareAndSet => CAS}
|
||||
val oldVec = get
|
||||
|
Loading…
x
Reference in New Issue
Block a user