check for null on node connections

closes #2952
This commit is contained in:
payonel 2018-10-06 11:32:48 -07:00
parent f38de55699
commit 93d72aaa59

View File

@ -36,7 +36,12 @@ trait Node extends ImmutableNode {
if (network == null) Iterable.empty[ImmutableNode].toSeq if (network == null) Iterable.empty[ImmutableNode].toSeq
else network.neighbors(this) else network.neighbors(this)
def connect(node: ImmutableNode) = network.connect(this, node) // a node should be added to a network before it can connect to a node
// but, sometimes other mods try to create nodes and connect them before
// the network is ready. we dont those things to crash here
// with typical nodes we are talking about components here
// which will be connected anyways when the network is created
def connect(node: ImmutableNode): Unit = if (network != null) network.connect(this, node)
def disconnect(node: ImmutableNode) = def disconnect(node: ImmutableNode) =
if (network != null && isInSameNetwork(node)) network.disconnect(this, node) if (network != null && isInSameNetwork(node)) network.disconnect(this, node)