diff --git a/code/modules/integrated_electronics/subtypes/data_transfer.dm b/code/modules/integrated_electronics/subtypes/data_transfer.dm index 19b43d1cfd9..783d34705a0 100644 --- a/code/modules/integrated_electronics/subtypes/data_transfer.dm +++ b/code/modules/integrated_electronics/subtypes/data_transfer.dm @@ -143,6 +143,7 @@ var/data = get_pin_data(IC_INPUT, 1) if (data != null) var/chan = "[WP_ELECTRONICS][get_pin_data(IC_INPUT, 2) || "default"]" + ntsl2.receive_subspace(chan, data) for (var/thing in GET_LISTENERS(chan)) var/listener/L = thing var/obj/item/integrated_circuit/transfer/wireless/W = L.target diff --git a/code/modules/modular_computers/file_system/programs/generic/ntsl2_interpreter.dm b/code/modules/modular_computers/file_system/programs/generic/ntsl2_interpreter.dm index 061d846343b..52ff9f621d0 100644 --- a/code/modules/modular_computers/file_system/programs/generic/ntsl2_interpreter.dm +++ b/code/modules/modular_computers/file_system/programs/generic/ntsl2_interpreter.dm @@ -14,7 +14,7 @@ /datum/computer_file/program/ntsl2_interpreter/process_tick() if(istype(running)) - running.cycle(5000) + running.cycle(30000) ..() /datum/computer_file/program/ntsl2_interpreter/kill_program() @@ -50,8 +50,8 @@ if(copytext(topc, 1, 2) == "?") topc = copytext(topc, 2) + "?" + input("", "Enter Data") running.topic(topc) - running.cycle(300) - . = TRUE + running.cycle(5000) + . = 1 if(href_list["PRG_refresh"]) . = TRUE diff --git a/code/modules/ntsl2/ntsl2.dm b/code/modules/ntsl2/ntsl2.dm index 28d163751ac..da2405b082a 100644 --- a/code/modules/ntsl2/ntsl2.dm +++ b/code/modules/ntsl2/ntsl2.dm @@ -1,21 +1,50 @@ /datum/NTSL_interpreter var/connected = 0 + var/locked = 0 // Due to the psudo-threaded nature of Byond, two messages could be sent at the same time. This is a measure against that. var/list/programs = list() /datum/NTSL_interpreter/proc/attempt_connect() + locked = 0 var/res = send(list(action="clear")) if(!res) log_debug("NTSL2+ Daemon could not be connected to. Functionality will not be enabled.") else + START_PROCESSING(SSfast_process, src) connected = 1 log_debug("NTSL2+ Daemon connected successfully.") /datum/NTSL_interpreter/proc/disconnect() connected = 0 send(list(action="clear")) + STOP_PROCESSING(SSfast_process, src) for(var/datum/ntsl_program/P in programs) P.kill() +/datum/NTSL_interpreter/process() + if(connected) + var/received_message = send(list(action="subspace_transmit")) + if(received_message && received_message!="0") + var/messages = splittext(received_message, "\n") + for(var/individual_message in messages) + var/list/message_info = params2list(individual_message); + var/channel = "[WP_ELECTRONICS][message_info["channel"]]" + var/message_type = message_info["type"] + var/message_body = message_info["data"] + + var/message = 0 + if(message_type == "num") + message = text2num(message_body) + else if(message_type == "text") + message = html_encode(message_body) + else if(message_type == "ref") + message = locate(message_body) + for (var/thing in GET_LISTENERS(channel)) + var/listener/L = thing + var/obj/item/integrated_circuit/transfer/wireless/W = L.target + if (W != src) + W.receive(message) + + /datum/NTSL_interpreter/proc/new_program(var/code, var/computer, var/mob/user) if(!connected) return 0 @@ -28,12 +57,24 @@ return P return 0 +/datum/NTSL_interpreter/proc/receive_subspace(var/channel, var/data) + if(istext(data)) + ntsl2.send(list(action="subspace_receive", channel=copytext(channel, length(WP_ELECTRONICS)+1), type="text", data=html_decode(data))) + else if(isnum(data)) + ntsl2.send(list(action="subspace_receive", channel=copytext(channel, length(WP_ELECTRONICS)+1), type="num", data="[data]")) + else // Probably an object or something, just get a ref to it. + ntsl2.send(list(action="subspace_receive", channel=copytext(channel, length(WP_ELECTRONICS)+1), type="ref", data="\ref[data]")) + /* Sends a command to the Daemon. This is an internal function, and should be avoided when used externally. */ /datum/NTSL_interpreter/proc/send(var/list/commands) + while(locked) // Prevent multiple requests being sent simultaneously and thus collisions. + sleep(1) if(config.ntsl_hostname && config.ntsl_port) // Requires config to be set. + locked = 1 var/http[] = world.Export("http://[config.ntsl_hostname]:[config.ntsl_port]/[list2params(commands)]") + locked = 0 if(http) return file2text(http["CONTENT"]) return 0 diff --git a/code/modules/ntsl2/telecomms.dm b/code/modules/ntsl2/telecomms.dm index 3a8bfee4b0d..c1568c3e3ee 100644 --- a/code/modules/ntsl2/telecomms.dm +++ b/code/modules/ntsl2/telecomms.dm @@ -15,12 +15,12 @@ /datum/TCS_Compiler/ntsl2/Run(var/datum/signal/signal) if(istype(running_code)) running_code.tc_message(signal) - running_code.cycle(10000) + running_code.cycle(100000) update_code() /datum/TCS_Compiler/ntsl2/proc/update_code() if(istype(running_code)) - running_code.cycle(10000) + running_code.cycle(100000) var/list/dat = json_decode(ntsl2.send(list(action="get_signals",id=running_code.id))) if(istype(dat) && "content" in dat) var/datum/signal/sig = null diff --git a/html/changelogs/tehflamintaco - ntsl2fix.yml b/html/changelogs/tehflamintaco - ntsl2fix.yml new file mode 100644 index 00000000000..ffad3652c6d --- /dev/null +++ b/html/changelogs/tehflamintaco - ntsl2fix.yml @@ -0,0 +1,43 @@ +################################ +# Example Changelog File +# +# Note: This file, and files beginning with ".", and files that don't end in ".yml" will not be read. If you change this file, you will look really dumb. +# +# Your changelog will be merged with a master changelog. (New stuff added only, and only on the date entry for the day it was merged.) +# When it is, any changes listed below will disappear. +# +# Valid Prefixes: +# bugfix +# wip (For works in progress) +# tweak +# soundadd +# sounddel +# rscadd (general adding of nice things) +# rscdel (general deleting of nice things) +# imageadd +# imagedel +# maptweak +# spellcheck (typo fixes) +# experiment +# balance +# admin +# backend +# security +# refactor +################################# + +# Your name. +author: Teh Flamin' Taco + +# Optional: Remove this file after generating master changelog. Useful for PR changelogs that won't get used again. +delete-after: True + +# Any changes you've made. See valid prefix list above. +# INDENT WITH TWO SPACES. NOT TABS. SPACES. +# SCREW THIS UP AND IT WON'T WORK. +# Also, all entries are changed into a single [] after a master changelog generation. Just remove the brackets when you add new entries. +# Please surround your changes in double quotes ("), as certain characters otherwise screws up compiling. The quotes will not show up in the changelog. +changes: + - bugfix: "NTSL2+ Programs should experience strange computer hopping properties less often." + - tweak: "NTSL2+ Programs in general run a lot faster." + - rscadd: "Subspace Transmitters can talk to NTSL2+ via the net.subscribe and net.message functions." \ No newline at end of file