fix ntnet circuit components (#60917) (#7633)

* fix ntnet

* fix typos and switcheroos

* whoops, tracked a test circuit json.

Co-authored-by: Gurkenglas <gurkenglas@hotmail.de>
This commit is contained in:
SkyratBot
2021-08-19 17:44:07 +02:00
committed by GitHub
parent a04e7e45ec
commit af632bec7f
8 changed files with 24 additions and 39 deletions

View File

@@ -56,11 +56,12 @@
parent.children[network_node_id] = src
root_devices = parent.root_devices
networks = parent.networks
networks[network_id] = src
else
network_node_id = net_id
parent = null
networks = list()
root_devices = list()
root_devices = linked_devices
SSnetworks.root_networks[network_id] = src
SSnetworks.networks[network_id] = src
@@ -72,6 +73,7 @@
/// A network should NEVER be deleted. If you don't want to show it exists just check if its
/// empty
/datum/ntnet/Destroy()
networks -= network_id
if(children.len > 0 || linked_devices.len > 0)
CRASH("Trying to delete a network with devices still in them")
@@ -142,19 +144,10 @@
*/
/datum/ntnet/proc/add_interface(datum/component/ntnet_interface/interface)
if(interface.network)
if(!networks[interface.network.network_id])
/// If we are doing a hard jump to a new network, log it
log_telecomms("The device {[interface.hardware_id]} is jumping networks from '[interface.network.network_id]' to '[network_id]'")
interface.network.remove_interface(interface, TRUE)
else // we are on the same network so we just want to be aliased to another branch
if(!interface.alias[network_id])
interface.alias[network_id] = src // add to the alias list
linked_devices[interface.hardware_id] = interface
else
log_telecomms("The device {[interface.hardware_id]} is trying to join '[network_id]' for a second time!")
return
// we have no network
interface.network = src // now we do!
/// If we are doing a hard jump to a new network, log it
log_telecomms("The device {[interface.hardware_id]} is jumping networks from '[interface.network.network_id]' to '[network_id]'")
interface.network.remove_interface(interface, TRUE)
interface.network ||= src
interface.alias[network_id] = src // add to the alias just to make removing easier.
linked_devices[interface.hardware_id] = interface
root_devices[interface.hardware_id] = interface