From 5750ec8ba104dc6d8af7ccd764eb73e46777db39 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Florian=20N=C3=BCcke?= Date: Fri, 13 Feb 2015 13:30:41 +0100 Subject: [PATCH] Should fix #911, merging networks containing nodes with the same address could lead to errors if these nodes had `Visibility.None`. --- src/main/scala/li/cil/oc/server/network/Network.scala | 7 +++++-- 1 file changed, 5 insertions(+), 2 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 dc559092e..17dd7fa3a 100644 --- a/src/main/scala/li/cil/oc/server/network/Network.scala +++ b/src/main/scala/li/cil/oc/server/network/Network.scala @@ -249,10 +249,13 @@ private class Network private(private val data: mutable.Map[String, Network.Vert // editing stuff or using mods to clone blocks (e.g. WorldEdit). otherNetwork.data.filter(entry => data.contains(entry._1)).toArray.foreach { case (address, node: Network.Vertex) => - val neighbors = node.data.neighbors.toArray // Copy to be on the safe side. + val neighbors = node.edges.map(_.other(node)) node.data.remove() node.data.address = java.util.UUID.randomUUID().toString - neighbors.foreach(_.connect(node.data)) + if (neighbors.isEmpty) + otherNetwork.addNew(node.data) + else + neighbors.foreach(_.data.connect(node.data)) } if (addedNode.reachability == Visibility.Neighbors)