[READY]NTnet refactor, assimilates exonet

This commit is contained in:
oranges
2017-11-23 10:52:44 +13:00
committed by CitadelStationBot
parent 2e9f3bc1c0
commit c2c22d56c7
23 changed files with 311 additions and 371 deletions
@@ -543,55 +543,55 @@
for(var/mob/O in hearers(1, get_turf(src)))
audible_message("[icon2html(src, hearers(src))] *beep* *beep*", null, 1)
/obj/item/integrated_circuit/input/EPv2
name = "EPv2 circuit"
desc = "Enables the sending and receiving of messages on the Exonet with the EPv2 protocol."
extended_desc = "An EPv2 address is a string with the format of XXXX:XXXX:XXXX:XXXX. Data can be send or received using the \
/obj/item/integrated_circuit/input/ntnet_packet
name = "NTNet networking circuit"
desc = "Enables the sending and receiving of messages on NTNet with packet data protocol."
extended_desc = "Data can be send or received using the \
second pin on each side, with additonal data reserved for the third pin. When a message is received, the second activation pin \
will pulse whatever's connected to it. Pulsing the first activation pin will send a message."
icon_state = "signal"
complexity = 4
inputs = list(
"target EPv2 address" = IC_PINTYPE_STRING,
"target NTNet address" = IC_PINTYPE_STRING,
"data to send" = IC_PINTYPE_STRING,
"secondary text" = IC_PINTYPE_STRING
"secondary text" = IC_PINTYPE_STRING,
"passkey" = IC_PINTYPE_STRING, //No this isn't a real passkey encryption scheme but that's why you keep your nodes secure so no one can find it out!
)
outputs = list(
"address received" = IC_PINTYPE_STRING,
"data received" = IC_PINTYPE_STRING,
"secondary text received" = IC_PINTYPE_STRING
"secondary text received" = IC_PINTYPE_STRING,
"passkey" = IC_PINTYPE_STRING
)
activators = list("send data" = IC_PINTYPE_PULSE_IN, "on data received" = IC_PINTYPE_PULSE_OUT)
spawn_flags = IC_SPAWN_DEFAULT|IC_SPAWN_RESEARCH
origin_tech = list(TECH_ENGINEERING = 2, TECH_DATA = 2, TECH_MAGNET = 2, TECH_BLUESPACE = 2)
power_draw_per_use = 50
var/datum/exonet_protocol/exonet = null
var/datum/ntnet_connection/exonet = null
/obj/item/integrated_circuit/input/EPv2/New()
..()
exonet = new(src)
exonet.make_address("EPv2_circuit-[REF(src)]")
desc += "<br>This circuit's EPv2 address is: [exonet.address]"
/obj/item/integrated_circuit/input/ntnet_packet/Initialize()
. = ..()
var/datum/component/ntnet_interface/net = LoadComponent(/datum/component/ntnet_interface)
desc += "<br>This circuit's NTNet hardware address is: [net.hardware_id]"
/obj/item/integrated_circuit/input/EPv2/Destroy()
if(exonet)
exonet.remove_address()
qdel(exonet)
exonet = null
return ..()
/obj/item/integrated_circuit/input/EPv2/do_work()
/obj/item/integrated_circuit/input/ntnet_packet/do_work()
var/target_address = get_pin_data(IC_INPUT, 1)
var/message = get_pin_data(IC_INPUT, 2)
var/text = get_pin_data(IC_INPUT, 3)
var/key = get_pin_data(IC_INPUT, 4)
if(target_address && istext(target_address))
exonet.send_message(target_address, message, text)
var/datum/netdata/data = new
data.recipient_ids += target_address
data.plaintext_data = message
data.plaintext_data_secondary = text
data.plaintext_passkey = key
ntnet_send(data)
/obj/item/integrated_circuit/input/receive_exonet_message(var/atom/origin_atom, var/origin_address, var/message, var/text)
set_pin_data(IC_OUTPUT, 1, origin_address)
set_pin_data(IC_OUTPUT, 2, message)
set_pin_data(IC_OUTPUT, 3, text)
/obj/item/integrated_circuit/input/ntnet_recieve(datum/netdata/data)
set_pin_data(IC_OUTPUT, 1, length(data.recipient_ids) >= 1? data.recipient_ids[1] : null)
set_pin_data(IC_OUTPUT, 2, data.plaintext_data)
set_pin_data(IC_OUTPUT, 3, data.plaintext_data_secondary)
set_pin_data(IC_OUTPUT, 4, data.plaintext_passkey)
push_data()
activate_pin(2)