mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2025-12-11 18:22:14 +00:00
* fix ntnet * fix typos and switcheroos * whoops, tracked a test circuit json. Co-authored-by: Gurkenglas <gurkenglas@hotmail.de>
This commit is contained in:
@@ -91,5 +91,4 @@
|
|||||||
#define NETWORK_ERROR_BAD_NETWORK "network_error_bad_network"
|
#define NETWORK_ERROR_BAD_NETWORK "network_error_bad_network"
|
||||||
#define NETWORK_ERROR_BAD_RECEIVER_ID "network_error_bad_receiver_id"
|
#define NETWORK_ERROR_BAD_RECEIVER_ID "network_error_bad_receiver_id"
|
||||||
#define NETWORK_ERROR_UNAUTHORIZED "network_error_bad_unauthorized"
|
#define NETWORK_ERROR_UNAUTHORIZED "network_error_bad_unauthorized"
|
||||||
#define NETWORK_ERROR_BAD_TARGET_ID "network_error_bad_target_id"
|
|
||||||
|
|
||||||
|
|||||||
@@ -140,7 +140,8 @@ SUBSYSTEM_DEF(networks)
|
|||||||
/// Check if we are a list. If so process the list
|
/// Check if we are a list. If so process the list
|
||||||
if(islist(current.receiver_id)) // are we a broadcast list
|
if(islist(current.receiver_id)) // are we a broadcast list
|
||||||
var/list/receivers = current.receiver_id
|
var/list/receivers = current.receiver_id
|
||||||
var/receiver_id = receivers[receivers.len--] // pop it
|
var/receiver_id = receivers[receivers.len] // pop it
|
||||||
|
receivers.len--
|
||||||
_process_packet(receiver_id, current)
|
_process_packet(receiver_id, current)
|
||||||
if(receivers.len == 0) // pop it if done
|
if(receivers.len == 0) // pop it if done
|
||||||
count_broadcasts_packets++
|
count_broadcasts_packets++
|
||||||
|
|||||||
@@ -14,20 +14,19 @@
|
|||||||
*/
|
*/
|
||||||
/datum/proc/ntnet_send(packet_data, target_id = null, passkey = null)
|
/datum/proc/ntnet_send(packet_data, target_id = null, passkey = null)
|
||||||
var/datum/netdata/data = packet_data
|
var/datum/netdata/data = packet_data
|
||||||
if(!data) // check for easy case
|
if(!istype(data)) // construct netdata from list()
|
||||||
if(!islist(packet_data) || target_id == null)
|
if(!islist(packet_data))
|
||||||
stack_trace("ntnet_send: Bad packet creation") // hard fail as its runtime fault
|
stack_trace("ntnet_send: Bad packet creation") // hard fail as its runtime fault
|
||||||
return
|
return
|
||||||
data = new(packet_data)
|
data = new(packet_data)
|
||||||
data.receiver_id = target_id
|
data.receiver_id = target_id
|
||||||
data.passkey = passkey
|
data.passkey = passkey
|
||||||
if(data.receiver_id == null)
|
|
||||||
return NETWORK_ERROR_BAD_TARGET_ID
|
|
||||||
var/datum/component/ntnet_interface/NIC = GetComponent(/datum/component/ntnet_interface)
|
var/datum/component/ntnet_interface/NIC = GetComponent(/datum/component/ntnet_interface)
|
||||||
if(!NIC)
|
if(!NIC)
|
||||||
return NETWORK_ERROR_NOT_ON_NETWORK
|
return NETWORK_ERROR_NOT_ON_NETWORK
|
||||||
data.sender_id = NIC.hardware_id
|
data.sender_id = NIC.hardware_id
|
||||||
data.network_id = NIC.network.network_id
|
data.network_id = NIC.network.network_id
|
||||||
|
data.receiver_id ||= data.network_id
|
||||||
return SSnetworks.transmit(data)
|
return SSnetworks.transmit(data)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|||||||
@@ -56,11 +56,12 @@
|
|||||||
parent.children[network_node_id] = src
|
parent.children[network_node_id] = src
|
||||||
root_devices = parent.root_devices
|
root_devices = parent.root_devices
|
||||||
networks = parent.networks
|
networks = parent.networks
|
||||||
|
networks[network_id] = src
|
||||||
else
|
else
|
||||||
network_node_id = net_id
|
network_node_id = net_id
|
||||||
parent = null
|
parent = null
|
||||||
networks = list()
|
networks = list()
|
||||||
root_devices = list()
|
root_devices = linked_devices
|
||||||
SSnetworks.root_networks[network_id] = src
|
SSnetworks.root_networks[network_id] = src
|
||||||
|
|
||||||
SSnetworks.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
|
/// A network should NEVER be deleted. If you don't want to show it exists just check if its
|
||||||
/// empty
|
/// empty
|
||||||
/datum/ntnet/Destroy()
|
/datum/ntnet/Destroy()
|
||||||
|
networks -= network_id
|
||||||
if(children.len > 0 || linked_devices.len > 0)
|
if(children.len > 0 || linked_devices.len > 0)
|
||||||
CRASH("Trying to delete a network with devices still in them")
|
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)
|
/datum/ntnet/proc/add_interface(datum/component/ntnet_interface/interface)
|
||||||
if(interface.network)
|
if(interface.network)
|
||||||
if(!networks[interface.network.network_id])
|
/// If we are doing a hard jump to a new network, log it
|
||||||
/// 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]'")
|
||||||
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.remove_interface(interface, TRUE)
|
interface.network ||= src
|
||||||
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!
|
|
||||||
interface.alias[network_id] = src // add to the alias just to make removing easier.
|
interface.alias[network_id] = src // add to the alias just to make removing easier.
|
||||||
linked_devices[interface.hardware_id] = interface
|
linked_devices[interface.hardware_id] = interface
|
||||||
root_devices[interface.hardware_id] = interface
|
root_devices[interface.hardware_id] = interface
|
||||||
|
|||||||
@@ -234,12 +234,12 @@
|
|||||||
build_path = /obj/item/circuit_component/module
|
build_path = /obj/item/circuit_component/module
|
||||||
|
|
||||||
/datum/design/component/ntnet_receive
|
/datum/design/component/ntnet_receive
|
||||||
name = "Pressure NTNet Transmitter"
|
name = "NTNet Receiver"
|
||||||
id = "comp_ntnet_receive"
|
id = "comp_ntnet_receive"
|
||||||
build_path = /obj/item/circuit_component/ntnet_receive
|
build_path = /obj/item/circuit_component/ntnet_receive
|
||||||
|
|
||||||
/datum/design/component/ntnet_send
|
/datum/design/component/ntnet_send
|
||||||
name = "NTNet Request Component"
|
name = "NTNet Transmitter"
|
||||||
id = "comp_ntnet_send"
|
id = "comp_ntnet_send"
|
||||||
build_path = /obj/item/circuit_component/ntnet_send
|
build_path = /obj/item/circuit_component/ntnet_send
|
||||||
|
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
/**
|
/**
|
||||||
* # NTNet Reciever Component
|
* # NTNet Receiver Component
|
||||||
*
|
*
|
||||||
* Recieves data through NTNet.
|
* Receives data through NTNet.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/obj/item/circuit_component/ntnet_receive
|
/obj/item/circuit_component/ntnet_receive
|
||||||
display_name = "NTNet Receiver"
|
display_name = "NTNet Receiver"
|
||||||
desc = "Recieves data packages through NTNet. If Encryption Key is set then only signals with the same Encryption Key will be received."
|
desc = "Receives data packages through NTNet. If Encryption Key is set then only signals with the same Encryption Key will be received."
|
||||||
|
|
||||||
circuit_flags = CIRCUIT_FLAG_OUTPUT_SIGNAL //trigger_output
|
circuit_flags = CIRCUIT_FLAG_OUTPUT_SIGNAL //trigger_output
|
||||||
|
|
||||||
@@ -22,7 +22,6 @@
|
|||||||
|
|
||||||
/obj/item/circuit_component/ntnet_receive/Initialize()
|
/obj/item/circuit_component/ntnet_receive/Initialize()
|
||||||
. = ..()
|
. = ..()
|
||||||
AddComponent(/datum/component/ntnet_interface)
|
|
||||||
data_package = add_output_port("Data Package", PORT_TYPE_ANY)
|
data_package = add_output_port("Data Package", PORT_TYPE_ANY)
|
||||||
secondary_package = add_output_port("Secondary Package", PORT_TYPE_ANY)
|
secondary_package = add_output_port("Secondary Package", PORT_TYPE_ANY)
|
||||||
enc_key = add_input_port("Encryption Key", PORT_TYPE_STRING)
|
enc_key = add_input_port("Encryption Key", PORT_TYPE_STRING)
|
||||||
@@ -50,6 +49,8 @@
|
|||||||
if(COMPONENT_TRIGGERED_BY(secondary_data_type_options, port))
|
if(COMPONENT_TRIGGERED_BY(secondary_data_type_options, port))
|
||||||
secondary_package.set_datatype(secondary_data_type_options.value)
|
secondary_package.set_datatype(secondary_data_type_options.value)
|
||||||
|
|
||||||
|
return TRUE
|
||||||
|
|
||||||
/obj/item/circuit_component/ntnet_receive/proc/ntnet_receive(datum/source, datum/netdata/data)
|
/obj/item/circuit_component/ntnet_receive/proc/ntnet_receive(datum/source, datum/netdata/data)
|
||||||
SIGNAL_HANDLER
|
SIGNAL_HANDLER
|
||||||
|
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
|
|
||||||
/obj/item/circuit_component/ntnet_send
|
/obj/item/circuit_component/ntnet_send
|
||||||
display_name = "NTNet Transmitter"
|
display_name = "NTNet Transmitter"
|
||||||
desc = "Sends a data package through NTNet when triggered. If target HID is not provided, data will be sent to all circuits in the network. If Encryption Key is set then transmitted data will be only picked up by receivers with the same Encryption Key."
|
desc = "Sends a data package through NTNet. If Encryption Key is set then transmitted data will be only picked up by receivers with the same Encryption Key."
|
||||||
|
|
||||||
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
|
circuit_flags = CIRCUIT_FLAG_INPUT_SIGNAL
|
||||||
|
|
||||||
@@ -24,14 +24,6 @@
|
|||||||
|
|
||||||
/obj/item/circuit_component/ntnet_send/input_received(datum/port/input/port)
|
/obj/item/circuit_component/ntnet_send/input_received(datum/port/input/port)
|
||||||
. = ..()
|
. = ..()
|
||||||
if(. || !data_package.value)
|
if(.)
|
||||||
return
|
return
|
||||||
|
ntnet_send(list("data" = data_package.value, "data_secondary" = secondary_package.value, "enc_key" = enc_key.value))
|
||||||
var/list/datalist = list("data" = data_package.value)
|
|
||||||
if(secondary_package.value)
|
|
||||||
datalist["data_secondary"] = secondary_package.value
|
|
||||||
if(enc_key.value)
|
|
||||||
datalist["enc_key"] = enc_key.value
|
|
||||||
var/datum/netdata/data = new(datalist)
|
|
||||||
data.network_id = __NETWORK_CIRCUITS
|
|
||||||
ntnet_send(data)
|
|
||||||
@@ -3771,8 +3771,8 @@
|
|||||||
#include "code\modules\wiremod\components\math\logic.dm"
|
#include "code\modules\wiremod\components\math\logic.dm"
|
||||||
#include "code\modules\wiremod\components\math\not.dm"
|
#include "code\modules\wiremod\components\math\not.dm"
|
||||||
#include "code\modules\wiremod\components\math\random.dm"
|
#include "code\modules\wiremod\components\math\random.dm"
|
||||||
#include "code\modules\wiremod\components\ntnet\ntnet_reciever.dm"
|
#include "code\modules\wiremod\components\ntnet\ntnet_receive.dm"
|
||||||
#include "code\modules\wiremod\components\ntnet\ntnet_request.dm"
|
#include "code\modules\wiremod\components\ntnet\ntnet_send.dm"
|
||||||
#include "code\modules\wiremod\components\sensors\pressuresensor.dm"
|
#include "code\modules\wiremod\components\sensors\pressuresensor.dm"
|
||||||
#include "code\modules\wiremod\components\sensors\tempsensor.dm"
|
#include "code\modules\wiremod\components\sensors\tempsensor.dm"
|
||||||
#include "code\modules\wiremod\components\string\concat.dm"
|
#include "code\modules\wiremod\components\string\concat.dm"
|
||||||
|
|||||||
Reference in New Issue
Block a user