mirror of
https://github.com/MightyPirates/OpenComputers.git
synced 2025-09-15 10:21:45 -04:00
Merge branch 'master-MC1.7.10' of github.com:MightyPirates/OpenComputers into master-MC1.8
This commit is contained in:
commit
114fb63c1e
@ -12,7 +12,7 @@ Network=network:1:dyeLime
|
||||
OpenIRC=irc:1:dyeLightBlue
|
||||
OpenLoader=openloader:1:dyeMagenta
|
||||
OpenOS=openos:0:dyeGreen
|
||||
OPPM=oppm:1:dyeCyan
|
||||
OPPM=oppm:0:dyeCyan
|
||||
# Higher chance to find the dig program, because it has the most immediate
|
||||
# use - OpenOS is craftable and IRC can be downloaded once an internet card
|
||||
# is available - which one needs anyway, to use the program...
|
||||
|
@ -117,19 +117,17 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
||||
}
|
||||
case _ => 0
|
||||
}))
|
||||
val oldArchitecture = architecture
|
||||
architecture = null
|
||||
var newArchitecture: Architecture = null
|
||||
components.find {
|
||||
case stack: ItemStack => Option(Driver.driverFor(stack, host.getClass)) match {
|
||||
case Some(driver: Processor) if driver.slot(stack) == Slot.CPU =>
|
||||
Option(driver.architecture(stack)) match {
|
||||
case Some(clazz) =>
|
||||
if (oldArchitecture == null || oldArchitecture.getClass != clazz) {
|
||||
architecture = clazz.getConstructor(classOf[machine.Machine]).newInstance(this)
|
||||
if (node.network != null) architecture.onConnect()
|
||||
if (architecture == null || architecture.getClass != clazz) {
|
||||
newArchitecture = clazz.getConstructor(classOf[machine.Machine]).newInstance(this)
|
||||
}
|
||||
else {
|
||||
architecture = oldArchitecture
|
||||
newArchitecture = architecture
|
||||
}
|
||||
true
|
||||
case _ => false
|
||||
@ -138,6 +136,12 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
|
||||
}
|
||||
case _ => false
|
||||
}
|
||||
// This needs to operate synchronized against the worker thread, to avoid the
|
||||
// architecture changing while it is currently being executed.
|
||||
if (newArchitecture != architecture) this.synchronized {
|
||||
architecture = newArchitecture
|
||||
if (architecture != null && node.network != null) architecture.onConnect()
|
||||
}
|
||||
hasMemory = Option(architecture).fold(false)(_.recomputeMemory(components))
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user