From b503b947e44bd997d99ba50e077d5ee520001d5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Sat, 30 Jul 2016 09:37:34 +0200 Subject: [PATCH] Huh, still had this lying around. Can't remember what it was trying to fix, but it doesn't seem to make things more broken so eh. --- .../li/cil/oc/server/network/Network.scala | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/src/main/scala/li/cil/oc/server/network/Network.scala b/src/main/scala/li/cil/oc/server/network/Network.scala index 27cd434b0..ed3e1762d 100644 --- a/src/main/scala/li/cil/oc/server/network/Network.scala +++ b/src/main/scala/li/cil/oc/server/network/Network.scala @@ -267,16 +267,23 @@ private class Network private(private val data: mutable.Map[String, Network.Vert val node = vertex.data val neighbors = vertex.edges.map(_.other(vertex).data).toArray + var newAddress = "" + do { + newAddress = java.util.UUID.randomUUID().toString + } while (data.contains(newAddress) || otherNetwork.data.contains(newAddress)) + // This may lead to splits, which is the whole reason we have to // check the network of the other nodes after the readdressing. node.remove() - - do { - node.address = java.util.UUID.randomUUID().toString - } while (data.contains(node.address) || otherNetwork.data.contains(node.address)) - + node.address = newAddress Network.joinNewNetwork(node) - neighbors.filter(_.network != null).foreach(_.connect(node)) + + if (node.address == newAddress) { + neighbors.filter(_.network != null).foreach(_.connect(node)) + } else { + OpenComputers.log.error("I can't see this happening any other way than someone directly setting node addresses, which they shouldn't. So yeah. Shit'll be borked. Deal with it.") + node.remove() // well screw you then + } }) duplicates.head.data.network.asInstanceOf[Network.Wrapper].network