Skip to content

Commit

Permalink
Merge pull request #2174 from Vexatos/no-crash-in-NBT
Browse files Browse the repository at this point in the history
Fix robots duplicating with SpongeForge.
  • Loading branch information
fnuecke authored Dec 11, 2016
2 parents 21be185 + f48dfee commit 6e1270e
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/main/scala/li/cil/oc/server/machine/Machine.scala
Original file line number Diff line number Diff line change
Expand Up @@ -765,7 +765,11 @@ class Machine(val host: MachineHost) extends prefab.ManagedEnvironment with mach
})

override def save(nbt: NBTTagCompound): Unit = Machine.this.synchronized(state.synchronized {
assert(!isExecuting) // Lock on 'this' should guarantee this.
// The lock on 'this' should guarantee that this never happens regularly.
// If something other than regular saving tries to save while we are executing code,
// e.g. SpongeForge saving during robot.move due to block changes being captured,
// just don't save this at all. What could possibly go wrong?
if(isExecuting) return

if (SaveHandler.savingForClients) {
return
Expand Down Expand Up @@ -1076,4 +1080,4 @@ object Machine extends MachineAPI {
}

private val threadPool = ThreadPoolFactory.create("Computer", Settings.get.threads)
}
}

0 comments on commit 6e1270e

Please sign in to comment.