mirror of
https://github.com/KabKebab/GS13.git
synced 2026-08-27 23:16:19 +01:00
Telecomm TGUI Hell
This commit is contained in:
@@ -1,215 +1,164 @@
|
||||
|
||||
/*
|
||||
The log console for viewing the entire telecomms
|
||||
network log
|
||||
*/
|
||||
|
||||
/obj/machinery/computer/telecomms/server
|
||||
name = "telecommunications server monitoring console"
|
||||
icon_screen = "comm_logs"
|
||||
desc = "Has full access to all details and record of the telecommunications network it's monitoring."
|
||||
circuit = /obj/item/circuitboard/computer/comm_server
|
||||
req_access = list(ACCESS_TCOMSAT)
|
||||
|
||||
var/screen = 0 // the screen number:
|
||||
var/list/servers = list() // the servers located by the computer
|
||||
var/obj/machinery/telecomms/server/SelectedServer
|
||||
var/list/machinelist = list() // the servers located by the computer
|
||||
var/obj/machinery/telecomms/server/SelectedMachine = null
|
||||
|
||||
var/network = "NULL" // the network to probe
|
||||
var/temp = "" // temporary feedback messages
|
||||
var/notice = ""
|
||||
var/universal_translate = FALSE // set to TRUE(1) if it can translate nonhuman speech
|
||||
|
||||
var/universal_translate = 0 // set to 1 if it can translate nonhuman speech
|
||||
/obj/machinery/computer/telecomms/server/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE, \
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "tcommsserver", "Telecomms Server Monitor", 575, 400, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
req_access = list(ACCESS_TCOMSAT)
|
||||
circuit = /obj/item/circuitboard/computer/comm_server
|
||||
/obj/machinery/computer/telecomms/server/ui_data(mob/user)
|
||||
var/list/data_out = list()
|
||||
data_out["network"] = network
|
||||
data_out["notice"] = notice
|
||||
|
||||
/obj/machinery/computer/telecomms/server/ui_interact(mob/user)
|
||||
. = ..()
|
||||
var/dat = "<TITLE>Telecommunication Server Monitor</TITLE><center><b>Telecommunications Server Monitor</b></center>"
|
||||
data_out["servers"] = list()
|
||||
for(var/obj/machinery/telecomms/server/T in machinelist)
|
||||
var/list/data = list(
|
||||
name = T.name,
|
||||
id = T.id,
|
||||
ref = REF(T)
|
||||
)
|
||||
data_out["servers"] += list(data)
|
||||
data_out["servers"] = sortList(data_out["servers"]) //a-z sort
|
||||
|
||||
switch(screen)
|
||||
if(!SelectedMachine) //null is bad.
|
||||
data_out["selected"] = null //but in js, null is good.
|
||||
return data_out
|
||||
|
||||
data_out["selected"] = list(
|
||||
name = SelectedMachine.name,
|
||||
id = SelectedMachine.id,
|
||||
status = SelectedMachine.on,
|
||||
traffic = SelectedMachine.totaltraffic, //note: total traffic, not traffic!
|
||||
ref = REF(SelectedMachine)
|
||||
)
|
||||
data_out["selected_logs"] = list()
|
||||
|
||||
// --- Main Menu ---
|
||||
if(!LAZYLEN(SelectedMachine.log_entries))
|
||||
return data_out
|
||||
|
||||
for(var/datum/comm_log_entry/C in SelectedMachine.log_entries)
|
||||
var/list/data = list()
|
||||
data["name"] = C.name //name of the file
|
||||
data["ref"] = REF(C)
|
||||
data["input_type"] = C.input_type //type of input ("Speech File" | "Execution Error").
|
||||
|
||||
if(0)
|
||||
dat += "<br>[temp]<br>"
|
||||
dat += "<br>Current Network: <a href='?src=[REF(src)];network=1'>[network]</a><br>"
|
||||
if(servers.len)
|
||||
dat += "<br>Detected Telecommunication Servers:<ul>"
|
||||
for(var/obj/machinery/telecomms/T in servers)
|
||||
dat += "<li><a href='?src=[REF(src)];viewserver=[T.id]'>[REF(T)] [T.name]</a> ([T.id])</li>"
|
||||
dat += "</ul>"
|
||||
dat += "<br><a href='?src=[REF(src)];operation=release'>\[Flush Buffer\]</a>"
|
||||
if(C.input_type == "Speech File") //there is a reason why this is not a switch.
|
||||
data["source"] = list(
|
||||
name = C.parameters["name"], //name of the mob | obj
|
||||
job = C.parameters["job"] //job of the mob | obj
|
||||
)
|
||||
|
||||
// -- Determine race of orator --
|
||||
var/mobtype = C.parameters["mobtype"]
|
||||
var/race // The actual race of the mob
|
||||
|
||||
if(ispath(mobtype, /mob/living/carbon/human) || ispath(mobtype, /mob/living/brain))
|
||||
race = "Humanoid"
|
||||
else if(ispath(mobtype, /mob/living/simple_animal/slime))
|
||||
race = "Slime" // NT knows a lot about slimes, but not aliens. Can identify slimes
|
||||
else if(ispath(mobtype, /mob/living/carbon/monkey))
|
||||
race = "Monkey"
|
||||
else if(ispath(mobtype, /mob/living/silicon) || C.parameters["job"] == "AI")
|
||||
race = "Artificial Life" // sometimes M gets deleted prematurely for AIs... just check the job
|
||||
else if(isobj(mobtype))
|
||||
race = "Machinery"
|
||||
else if(ispath(mobtype, /mob/living/simple_animal))
|
||||
race = "Domestic Animal"
|
||||
else
|
||||
dat += "<br>No servers detected. Scan for servers: <a href='?src=[REF(src)];operation=scan'>\[Scan\]</a>"
|
||||
race = "Unidentifiable"
|
||||
|
||||
data["race"] = race
|
||||
// based on [/atom/movable/proc/lang_treat]
|
||||
var/message = C.parameters["message"]
|
||||
var/language = C.parameters["language"]
|
||||
|
||||
// --- Viewing Server ---
|
||||
if(universal_translate || user.has_language(language))
|
||||
message = message
|
||||
else if(!user.has_language(language))
|
||||
var/datum/language/D = GLOB.language_datum_instances[language]
|
||||
message = D.scramble(message)
|
||||
else if(language)
|
||||
message = "(unintelligible)"
|
||||
|
||||
if(1)
|
||||
dat += "<br>[temp]<br>"
|
||||
dat += "<center><a href='?src=[REF(src)];operation=mainmenu'>\[Main Menu\]</a> <a href='?src=[REF(src)];operation=refresh'>\[Refresh\]</a></center>"
|
||||
dat += "<br>Current Network: [network]"
|
||||
dat += "<br>Selected Server: [SelectedServer.id]"
|
||||
data["message"] = message
|
||||
|
||||
if(SelectedServer.totaltraffic >= 1024)
|
||||
dat += "<br>Total recorded traffic: [round(SelectedServer.totaltraffic / 1024)] Terrabytes<br><br>"
|
||||
else
|
||||
dat += "<br>Total recorded traffic: [SelectedServer.totaltraffic] Gigabytes<br><br>"
|
||||
else if(C.input_type == "Execution Error")
|
||||
data["message"] = C.parameters["message"]
|
||||
else
|
||||
data["message"] = "(unintelligible)"
|
||||
|
||||
data_out["selected_logs"] += list(data)
|
||||
return data_out
|
||||
|
||||
dat += "Stored Logs: <ol>"
|
||||
|
||||
var/i = 0
|
||||
for(var/datum/comm_log_entry/C in SelectedServer.log_entries)
|
||||
i++
|
||||
|
||||
|
||||
// If the log is a speech file
|
||||
if(C.input_type == "Speech File")
|
||||
dat += "<li><font color = #008F00>[C.name]</font> <font color = #FF0000><a href='?src=[REF(src)];delete=[i]'>\[X\]</a></font><br>"
|
||||
|
||||
// -- Determine race of orator --
|
||||
|
||||
var/mobtype = C.parameters["mobtype"]
|
||||
var/race // The actual race of the mob
|
||||
|
||||
if(ispath(mobtype, /mob/living/carbon/human) || ispath(mobtype, /mob/living/brain))
|
||||
race = "Humanoid"
|
||||
|
||||
// NT knows a lot about slimes, but not aliens. Can identify slimes
|
||||
else if(ispath(mobtype, /mob/living/simple_animal/slime))
|
||||
race = "Slime"
|
||||
|
||||
else if(ispath(mobtype, /mob/living/carbon/monkey))
|
||||
race = "Monkey"
|
||||
|
||||
// sometimes M gets deleted prematurely for AIs... just check the job
|
||||
else if(ispath(mobtype, /mob/living/silicon) || C.parameters["job"] == "AI")
|
||||
race = "Artificial Life"
|
||||
|
||||
else if(isobj(mobtype))
|
||||
race = "Machinery"
|
||||
|
||||
else if(ispath(mobtype, /mob/living/simple_animal))
|
||||
race = "Domestic Animal"
|
||||
|
||||
else
|
||||
race = "<i>Unidentifiable</i>"
|
||||
|
||||
dat += "<u><font color = #18743E>Data type</font></u>: [C.input_type]<br>"
|
||||
dat += "<u><font color = #18743E>Source</font></u>: [C.parameters["name"]] (Job: [C.parameters["job"]])<br>"
|
||||
dat += "<u><font color = #18743E>Class</font></u>: [race]<br>"
|
||||
var/message = C.parameters["message"]
|
||||
var/language = C.parameters["language"]
|
||||
|
||||
// based on [/atom/movable/proc/lang_treat]
|
||||
if (universal_translate || user.has_language(language))
|
||||
message = "\"[message]\""
|
||||
else if (!user.has_language(language))
|
||||
var/datum/language/D = GLOB.language_datum_instances[language]
|
||||
message = "\"[D.scramble(message)]\""
|
||||
else if (language)
|
||||
message = "<i>(unintelligible)</i>"
|
||||
|
||||
dat += "<u><font color = #18743E>Contents</font></u>: [message]<br>"
|
||||
dat += "</li><br>"
|
||||
|
||||
else if(C.input_type == "Execution Error")
|
||||
dat += "<li><font color = #990000>[C.name]</font> <a href='?src=[REF(src)];delete=[i]'>\[X\]</a><br>"
|
||||
dat += "<u><font color = #787700>Error</font></u>: \"[C.parameters["message"]]\"<br>"
|
||||
dat += "</li><br>"
|
||||
|
||||
else
|
||||
dat += "<li><font color = #000099>[C.name]</font> <a href='?src=[REF(src)];delete=[i]'>\[X\]</a><br>"
|
||||
dat += "<u><font color = #18743E>Data type</font></u>: [C.input_type]<br>"
|
||||
dat += "<u><font color = #18743E>Contents</font></u>: <i>(unintelligible)</i><br>"
|
||||
dat += "</li><br>"
|
||||
|
||||
|
||||
dat += "</ol>"
|
||||
|
||||
|
||||
|
||||
user << browse(dat, "window=comm_monitor;size=575x400")
|
||||
onclose(user, "server_control")
|
||||
|
||||
temp = ""
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/computer/telecomms/server/Topic(href, href_list)
|
||||
/obj/machinery/computer/telecomms/server/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
|
||||
|
||||
add_fingerprint(usr)
|
||||
usr.set_machine(src)
|
||||
|
||||
if(href_list["viewserver"])
|
||||
screen = 1
|
||||
for(var/obj/machinery/telecomms/T in servers)
|
||||
if(T.id == href_list["viewserver"])
|
||||
SelectedServer = T
|
||||
break
|
||||
|
||||
if(href_list["operation"])
|
||||
switch(href_list["operation"])
|
||||
|
||||
if("release")
|
||||
servers = list()
|
||||
screen = 0
|
||||
|
||||
if("mainmenu")
|
||||
screen = 0
|
||||
|
||||
if("scan")
|
||||
if(servers.len > 0)
|
||||
temp = "<font color = #D70B00>- FAILED: CANNOT PROBE WHEN BUFFER FULL -</font color>"
|
||||
|
||||
else
|
||||
for(var/obj/machinery/telecomms/server/T in urange(25, src))
|
||||
if(T.network == network)
|
||||
servers.Add(T)
|
||||
|
||||
if(!servers.len)
|
||||
temp = "<font color = #D70B00>- FAILED: UNABLE TO LOCATE SERVERS IN \[[network]\] -</font color>"
|
||||
else
|
||||
temp = "<font color = #336699>- [servers.len] SERVERS PROBED & BUFFERED -</font color>"
|
||||
|
||||
screen = 0
|
||||
|
||||
if(href_list["delete"])
|
||||
|
||||
if(!src.allowed(usr) && !(obj_flags & EMAGGED))
|
||||
to_chat(usr, "<span class='danger'>ACCESS DENIED.</span>")
|
||||
switch(action)
|
||||
if("mainmenu")
|
||||
SelectedMachine = null
|
||||
notice = ""
|
||||
return
|
||||
if("release")
|
||||
machinelist = list()
|
||||
notice = ""
|
||||
return
|
||||
if("network") //network change, flush the selected machine and buffer
|
||||
var/newnet = sanitize(sanitize_text(params["value"], network))
|
||||
if(length(newnet) > 15) //i'm looking at you, you href fuckers
|
||||
notice = "FAILED: Network tag string too lengthy"
|
||||
return
|
||||
network = newnet
|
||||
SelectedMachine = null
|
||||
machinelist = list()
|
||||
return
|
||||
if("probe")
|
||||
if(LAZYLEN(machinelist) > 0)
|
||||
notice = "FAILED: Cannot probe when buffer full"
|
||||
return
|
||||
|
||||
for(var/obj/machinery/telecomms/T in GLOB.telecomms_list) //telecomms just went global!
|
||||
if(T.network == network)
|
||||
LAZYADD(machinelist, T)
|
||||
|
||||
if(SelectedServer)
|
||||
if(!LAZYLEN(machinelist))
|
||||
notice = "FAILED: Unable to locate network entities in \[[network]\]"
|
||||
return
|
||||
if("viewmachine")
|
||||
for(var/obj/machinery/telecomms/T in machinelist)
|
||||
if(T.id == params["value"])
|
||||
SelectedMachine = T
|
||||
break
|
||||
if("delete")
|
||||
if(!src.allowed(usr) && !CHECK_BITFIELD(obj_flags, EMAGGED))
|
||||
to_chat(usr, "<span class='danger'>ACCESS DENIED.</span>")
|
||||
return
|
||||
|
||||
var/datum/comm_log_entry/D = SelectedServer.log_entries[text2num(href_list["delete"])]
|
||||
|
||||
temp = "<font color = #336699>- DELETED ENTRY: [D.name] -</font color>"
|
||||
|
||||
SelectedServer.log_entries.Remove(D)
|
||||
if(!SelectedMachine)
|
||||
notice = "ALERT: No server detected. Server may be nonresponsive."
|
||||
return
|
||||
var/datum/comm_log_entry/D = locate(params["value"])
|
||||
if(!istype(D))
|
||||
notice = "NOTICE: Object not found"
|
||||
return
|
||||
notice = "Deleted entry: [D.name]"
|
||||
LAZYREMOVE(SelectedMachine.log_entries, D)
|
||||
qdel(D)
|
||||
|
||||
else
|
||||
temp = "<font color = #D70B00>- FAILED: NO SELECTED MACHINE -</font color>"
|
||||
|
||||
if(href_list["network"])
|
||||
|
||||
var/newnet = stripped_input(usr, "Which network do you want to view?", "Comm Monitor", network)
|
||||
|
||||
if(newnet && ((usr in range(1, src)) || issilicon(usr)))
|
||||
if(length(newnet) > 15)
|
||||
temp = "<font color = #D70B00>- FAILED: NETWORK TAG STRING TOO LENGHTLY -</font color>"
|
||||
|
||||
else
|
||||
|
||||
network = newnet
|
||||
screen = 0
|
||||
servers = list()
|
||||
temp = "<font color = #336699>- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -</font color>"
|
||||
|
||||
updateUsrDialog()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/telecomms/server/attackby()
|
||||
. = ..()
|
||||
updateUsrDialog()
|
||||
@@ -1,464 +1,399 @@
|
||||
/*
|
||||
The monitoring computer for the messaging server.
|
||||
Lets you read PDA and request console messages.
|
||||
*/
|
||||
|
||||
#define LINKED_SERVER_NONRESPONSIVE (!linkedServer || (linkedServer.stat & (NOPOWER|BROKEN)))
|
||||
|
||||
// The monitor itself.
|
||||
/obj/machinery/computer/message_monitor
|
||||
name = "message monitor console"
|
||||
desc = "Used to monitor the crew's PDA messages, as well as request console messages."
|
||||
icon_screen = "comm_logs"
|
||||
circuit = /obj/item/circuitboard/computer/message_monitor
|
||||
//Server linked to.
|
||||
var/obj/machinery/telecomms/message_server/linkedServer = null
|
||||
//Sparks effect - For emag
|
||||
var/datum/effect_system/spark_spread/spark_system = new /datum/effect_system/spark_spread
|
||||
//Messages - Saves me time if I want to change something.
|
||||
var/noserver = "<span class='alert'>ALERT: No server detected.</span>"
|
||||
var/incorrectkey = "<span class='warning'>ALERT: Incorrect decryption key!</span>"
|
||||
var/defaultmsg = "<span class='notice'>Welcome. Please select an option.</span>"
|
||||
var/rebootmsg = "<span class='warning'>%$&(�: Critical %$$@ Error // !RestArting! <lOadiNg backUp iNput ouTput> - ?pLeaSe wAit!</span>"
|
||||
//Computer properties
|
||||
var/screen = 0 // 0 = Main menu, 1 = Message Logs, 2 = Hacked screen, 3 = Custom Message
|
||||
var/hacking = FALSE // Is it being hacked into by the AI/Cyborg
|
||||
var/message = "<span class='notice'>System bootup complete. Please select an option.</span>" // The message that shows on the main menu.
|
||||
var/auth = FALSE // Are they authenticated?
|
||||
var/optioncount = 7
|
||||
// Custom Message Properties
|
||||
var/customsender = "System Administrator"
|
||||
var/obj/item/pda/customrecepient = null
|
||||
var/customjob = "Admin"
|
||||
var/custommessage = "This is a test, please ignore."
|
||||
|
||||
light_color = LIGHT_COLOR_GREEN
|
||||
|
||||
/obj/machinery/computer/message_monitor/attackby(obj/item/O, mob/living/user, params)
|
||||
if(istype(O, /obj/item/screwdriver) && (obj_flags & EMAGGED))
|
||||
//Stops people from just unscrewing the monitor and putting it back to get the console working again.
|
||||
to_chat(user, "<span class='warning'>It is too hot to mess with!</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/computer/message_monitor/emag_act(mob/user)
|
||||
if(obj_flags & EMAGGED)
|
||||
return
|
||||
if(!isnull(linkedServer))
|
||||
obj_flags |= EMAGGED
|
||||
screen = 2
|
||||
spark_system.set_up(5, 0, src)
|
||||
spark_system.start()
|
||||
var/obj/item/paper/monitorkey/MK = new(loc, linkedServer)
|
||||
// Will help make emagging the console not so easy to get away with.
|
||||
MK.info += "<br><br><font color='red'>�%@%(*$%&(�&?*(%&�/{}</font>"
|
||||
var/time = 100 * length(linkedServer.decryptkey)
|
||||
addtimer(CALLBACK(src, .proc/UnmagConsole), time)
|
||||
message = rebootmsg
|
||||
else
|
||||
to_chat(user, "<span class='notice'>A no server error appears on the screen.</span>")
|
||||
|
||||
/obj/machinery/computer/message_monitor/New()
|
||||
. = ..()
|
||||
GLOB.telecomms_list += src
|
||||
|
||||
/obj/machinery/computer/message_monitor/Initialize()
|
||||
..()
|
||||
return INITIALIZE_HINT_LATELOAD
|
||||
|
||||
/obj/machinery/computer/message_monitor/LateInitialize()
|
||||
//Is the server isn't linked to a server, and there's a server available, default it to the first one in the list.
|
||||
if(!linkedServer)
|
||||
for(var/obj/machinery/telecomms/message_server/S in GLOB.telecomms_list)
|
||||
linkedServer = S
|
||||
break
|
||||
|
||||
/obj/machinery/computer/message_monitor/Destroy()
|
||||
GLOB.telecomms_list -= src
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/computer/message_monitor/ui_interact(mob/living/user)
|
||||
. = ..()
|
||||
//If the computer is being hacked or is emagged, display the reboot message.
|
||||
if(hacking || (obj_flags & EMAGGED))
|
||||
message = rebootmsg
|
||||
var/dat = "<center><font color='blue'[message]</font></center>"
|
||||
|
||||
if(auth)
|
||||
dat += "<h4><dd><A href='?src=[REF(src)];auth=1'>	<font color='green'>\[Authenticated\]</font></a>	/"
|
||||
dat += " Server Power: <A href='?src=[REF(src)];active=1'>[linkedServer && linkedServer.toggled ? "<font color='green'>\[On\]</font>":"<font color='red'>\[Off\]</font>"]</a></h4>"
|
||||
else
|
||||
dat += "<h4><dd><A href='?src=[REF(src)];auth=1'>	<font color='red'>\[Unauthenticated\]</font></a>	/"
|
||||
dat += " Server Power: <u>[linkedServer && linkedServer.toggled ? "<font color='green'>\[On\]</font>":"<font color='red'>\[Off\]</font>"]</u></h4>"
|
||||
|
||||
if(hacking || (obj_flags & EMAGGED))
|
||||
screen = 2
|
||||
else if(!auth || LINKED_SERVER_NONRESPONSIVE)
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
screen = 0
|
||||
|
||||
switch(screen)
|
||||
//Main menu
|
||||
if(0)
|
||||
//	 = TAB
|
||||
var/i = 0
|
||||
dat += "<dd><A href='?src=[REF(src)];find=1'>	[++i]. Link To A Server</a></dd>"
|
||||
if(auth)
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
dat += "<dd><A>	ERROR: Server not found!</A><br></dd>"
|
||||
else
|
||||
dat += "<dd><A href='?src=[REF(src)];view_logs=1'>	[++i]. View Message Logs </a><br></dd>"
|
||||
dat += "<dd><A href='?src=[REF(src)];view_requests=1'>	[++i]. View Request Console Logs </a></br></dd>"
|
||||
dat += "<dd><A href='?src=[REF(src)];clear_logs=1'>	[++i]. Clear Message Logs</a><br></dd>"
|
||||
dat += "<dd><A href='?src=[REF(src)];clear_requests=1'>	[++i]. Clear Request Console Logs</a><br></dd>"
|
||||
dat += "<dd><A href='?src=[REF(src)];pass=1'>	[++i]. Set Custom Key</a><br></dd>"
|
||||
dat += "<dd><A href='?src=[REF(src)];msg=1'>	[++i]. Send Admin Message</a><br></dd>"
|
||||
else
|
||||
for(var/n = ++i; n <= optioncount; n++)
|
||||
dat += "<dd><font color='blue'>	[n]. ---------------</font><br></dd>"
|
||||
var/mob/living/silicon/S = usr
|
||||
if(istype(S) && S.hack_software)
|
||||
//Malf/Traitor AIs can bruteforce into the system to gain the Key.
|
||||
dat += "<dd><A href='?src=[REF(src)];hack=1'><i><font color='Red'>*&@#. Bruteforce Key</font></i></font></a><br></dd>"
|
||||
else
|
||||
dat += "<br>"
|
||||
|
||||
//Bottom message
|
||||
if(!auth)
|
||||
dat += "<br><hr><dd><span class='notice'>Please authenticate with the server in order to show additional options.</span>"
|
||||
else
|
||||
dat += "<br><hr><dd><span class='warning'>Reg, #514 forbids sending messages to a Head of Staff containing Erotic Rendering Properties.</span>"
|
||||
|
||||
//Message Logs
|
||||
if(1)
|
||||
var/index = 0
|
||||
dat += "<center><A href='?src=[REF(src)];back=1'>Back</a> - <A href='?src=[REF(src)];refresh=1'>Refresh</a></center><hr>"
|
||||
dat += "<table border='1' width='100%'><tr><th width = '5%'>X</th><th width='15%'>Sender</th><th width='15%'>Recipient</th><th width='300px' word-wrap: break-word>Message</th></tr>"
|
||||
for(var/datum/data_pda_msg/pda in linkedServer.pda_msgs)
|
||||
index++
|
||||
if(index > 3000)
|
||||
break
|
||||
// Del - Sender - Recepient - Message
|
||||
// X - Al Green - Your Mom - WHAT UP!?
|
||||
dat += "<tr><td width = '5%'><center><A href='?src=[REF(src)];delete_logs=[REF(pda)]' style='color: rgb(255,0,0)'>X</a></center></td><td width='15%'>[pda.sender]</td><td width='15%'>[pda.recipient]</td><td width='300px'>[pda.message][pda.picture ? " <a href='byond://?src=[REF(pda)];photo=1'>(Photo)</a>":""]</td></tr>"
|
||||
dat += "</table>"
|
||||
//Hacking screen.
|
||||
if(2)
|
||||
if(isAI(user) || iscyborg(user))
|
||||
dat += "Brute-forcing for server key.<br> It will take 20 seconds for every character that the password has."
|
||||
dat += "In the meantime, this console can reveal your true intentions if you let someone access it. Make sure no humans enter the room during that time."
|
||||
else
|
||||
//It's the same message as the one above but in binary. Because robots understand binary and humans don't... well I thought it was clever.
|
||||
dat += {"01000010011100100111010101110100011001010010110<br>
|
||||
10110011001101111011100100110001101101001011011100110011<br>
|
||||
10010000001100110011011110111001000100000011100110110010<br>
|
||||
10111001001110110011001010111001000100000011010110110010<br>
|
||||
10111100100101110001000000100100101110100001000000111011<br>
|
||||
10110100101101100011011000010000001110100011000010110101<br>
|
||||
10110010100100000001100100011000000100000011100110110010<br>
|
||||
10110001101101111011011100110010001110011001000000110011<br>
|
||||
00110111101110010001000000110010101110110011001010111001<br>
|
||||
00111100100100000011000110110100001100001011100100110000<br>
|
||||
10110001101110100011001010111001000100000011101000110100<br>
|
||||
00110000101110100001000000111010001101000011001010010000<br>
|
||||
00111000001100001011100110111001101110111011011110111001<br>
|
||||
00110010000100000011010000110000101110011001011100010000<br>
|
||||
00100100101101110001000000111010001101000011001010010000<br>
|
||||
00110110101100101011000010110111001110100011010010110110<br>
|
||||
10110010100101100001000000111010001101000011010010111001<br>
|
||||
10010000001100011011011110110111001110011011011110110110<br>
|
||||
00110010100100000011000110110000101101110001000000111001<br>
|
||||
00110010101110110011001010110000101101100001000000111100<br>
|
||||
10110111101110101011100100010000001110100011100100111010<br>
|
||||
10110010100100000011010010110111001110100011001010110111<br>
|
||||
00111010001101001011011110110111001110011001000000110100<br>
|
||||
10110011000100000011110010110111101110101001000000110110<br>
|
||||
00110010101110100001000000111001101101111011011010110010<br>
|
||||
10110111101101110011001010010000001100001011000110110001<br>
|
||||
10110010101110011011100110010000001101001011101000010111<br>
|
||||
00010000001001101011000010110101101100101001000000111001<br>
|
||||
10111010101110010011001010010000001101110011011110010000<br>
|
||||
00110100001110101011011010110000101101110011100110010000<br>
|
||||
00110010101101110011101000110010101110010001000000111010<br>
|
||||
00110100001100101001000000111001001101111011011110110110<br>
|
||||
10010000001100100011101010111001001101001011011100110011<br>
|
||||
10010000001110100011010000110000101110100001000000111010<br>
|
||||
001101001011011010110010100101110"}
|
||||
|
||||
//Fake messages
|
||||
if(3)
|
||||
dat += "<center><A href='?src=[REF(src)];back=1'>Back</a> - <A href='?src=[REF(src)];Reset=1'>Reset</a></center><hr>"
|
||||
|
||||
dat += {"<table border='1' width='100%'>
|
||||
<tr><td width='20%'><A href='?src=[REF(src)];select=Sender'>Sender</a></td>
|
||||
<td width='20%'><A href='?src=[REF(src)];select=RecJob'>Sender's Job</a></td>
|
||||
<td width='20%'><A href='?src=[REF(src)];select=Recepient'>Recipient</a></td>
|
||||
<td width='300px' word-wrap: break-word><A href='?src=[REF(src)];select=Message'>Message</a></td></tr>"}
|
||||
//Sender - Sender's Job - Recepient - Message
|
||||
//Al Green- Your Dad - Your Mom - WHAT UP!?
|
||||
|
||||
dat += {"<tr><td width='20%'>[customsender]</td>
|
||||
<td width='20%'>[customjob]</td>
|
||||
<td width='20%'>[customrecepient ? customrecepient.owner : "NONE"]</td>
|
||||
<td width='300px'>[custommessage]</td></tr>"}
|
||||
dat += "</table><br><center><A href='?src=[REF(src)];select=Send'>Send</a>"
|
||||
|
||||
//Request Console Logs
|
||||
if(4)
|
||||
|
||||
var/index = 0
|
||||
/* data_rc_msg
|
||||
X - 5%
|
||||
var/rec_dpt = "Unspecified" //name of the person - 15%
|
||||
var/send_dpt = "Unspecified" //name of the sender- 15%
|
||||
var/message = "Blank" //transferred message - 300px
|
||||
var/stamp = "Unstamped" - 15%
|
||||
var/id_auth = "Unauthenticated" - 15%
|
||||
var/priority = "Normal" - 10%
|
||||
*/
|
||||
dat += "<center><A href='?src=[REF(src)];back=1'>Back</a> - <A href='?src=[REF(src)];refresh=1'>Refresh</a></center><hr>"
|
||||
dat += {"<table border='1' width='100%'><tr><th width = '5%'>X</th><th width='15%'>Sending Dep.</th><th width='15%'>Receiving Dep.</th>
|
||||
<th width='300px' word-wrap: break-word>Message</th><th width='15%'>Stamp</th><th width='15%'>ID Auth.</th><th width='15%'>Priority.</th></tr>"}
|
||||
for(var/datum/data_rc_msg/rc in linkedServer.rc_msgs)
|
||||
index++
|
||||
if(index > 3000)
|
||||
break
|
||||
// Del - Sender - Recepient - Message
|
||||
// X - Al Green - Your Mom - WHAT UP!?
|
||||
dat += {"<tr><td width = '5%'><center><A href='?src=[REF(src)];delete_requests=[REF(rc)]' style='color: rgb(255,0,0)'>X</a></center></td><td width='15%'>[rc.send_dpt]</td>
|
||||
<td width='15%'>[rc.rec_dpt]</td><td width='300px'>[rc.message]</td><td width='15%'>[rc.stamp]</td><td width='15%'>[rc.id_auth]</td><td width='15%'>[rc.priority]</td></tr>"}
|
||||
dat += "</table>"
|
||||
|
||||
message = defaultmsg
|
||||
var/datum/browser/popup = new(user, "hologram_console", name, 700, 700)
|
||||
popup.set_content(dat)
|
||||
popup.set_title_image(user.browse_rsc_icon(icon, icon_state))
|
||||
popup.open()
|
||||
|
||||
/obj/machinery/computer/message_monitor/proc/BruteForce(mob/user)
|
||||
if(isnull(linkedServer))
|
||||
to_chat(user, "<span class='warning'>Could not complete brute-force: Linked Server Disconnected!</span>")
|
||||
else
|
||||
var/currentKey = linkedServer.decryptkey
|
||||
to_chat(user, "<span class='warning'>Brute-force completed! The key is '[currentKey]'.</span>")
|
||||
hacking = FALSE
|
||||
screen = 0 // Return the screen back to normal
|
||||
|
||||
/obj/machinery/computer/message_monitor/proc/UnmagConsole()
|
||||
obj_flags &= ~EMAGGED
|
||||
|
||||
/obj/machinery/computer/message_monitor/proc/ResetMessage()
|
||||
customsender = "System Administrator"
|
||||
customrecepient = null
|
||||
custommessage = "This is a test, please ignore."
|
||||
customjob = "Admin"
|
||||
|
||||
/obj/machinery/computer/message_monitor/Topic(href, href_list)
|
||||
if(..())
|
||||
return
|
||||
|
||||
if(usr.contents.Find(src) || (in_range(src, usr) && isturf(loc)) || issilicon(usr))
|
||||
//Authenticate
|
||||
if (href_list["auth"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
auth = FALSE
|
||||
screen = 0
|
||||
else
|
||||
var/dkey = trim(input(usr, "Please enter the decryption key.") as text|null)
|
||||
if(dkey && dkey != "")
|
||||
if(linkedServer.decryptkey == dkey)
|
||||
auth = TRUE
|
||||
else
|
||||
message = incorrectkey
|
||||
|
||||
//Turn the server on/off.
|
||||
if (href_list["active"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
linkedServer.toggled = !linkedServer.toggled
|
||||
//Find a server
|
||||
if (href_list["find"])
|
||||
var/list/message_servers = list()
|
||||
for (var/obj/machinery/telecomms/message_server/M in GLOB.telecomms_list)
|
||||
message_servers += M
|
||||
|
||||
if(message_servers.len > 1)
|
||||
linkedServer = input(usr, "Please select a server.", "Select a server.", null) as null|anything in message_servers
|
||||
message = "<span class='alert'>NOTICE: Server selected.</span>"
|
||||
else if(message_servers.len > 0)
|
||||
linkedServer = message_servers[1]
|
||||
message = "<span class='notice'>NOTICE: Only Single Server Detected - Server selected.</span>"
|
||||
else
|
||||
message = noserver
|
||||
|
||||
//View the logs - KEY REQUIRED
|
||||
if (href_list["view_logs"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
screen = 1
|
||||
|
||||
//Clears the logs - KEY REQUIRED
|
||||
if (href_list["clear_logs"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
linkedServer.pda_msgs = list()
|
||||
message = "<span class='notice'>NOTICE: Logs cleared.</span>"
|
||||
//Clears the request console logs - KEY REQUIRED
|
||||
if (href_list["clear_requests"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
linkedServer.rc_msgs = list()
|
||||
message = "<span class='notice'>NOTICE: Logs cleared.</span>"
|
||||
//Change the password - KEY REQUIRED
|
||||
if (href_list["pass"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
var/dkey = stripped_input(usr, "Please enter the decryption key.")
|
||||
if(dkey && dkey != "")
|
||||
if(linkedServer.decryptkey == dkey)
|
||||
var/newkey = trim(input(usr,"Please enter the new key (3 - 16 characters max):"))
|
||||
if(length(newkey) <= 3)
|
||||
message = "<span class='notice'>NOTICE: Decryption key too short!</span>"
|
||||
else if(length(newkey) > 16)
|
||||
message = "<span class='notice'>NOTICE: Decryption key too long!</span>"
|
||||
else if(newkey && newkey != "")
|
||||
linkedServer.decryptkey = newkey
|
||||
message = "<span class='notice'>NOTICE: Decryption key set.</span>"
|
||||
else
|
||||
message = incorrectkey
|
||||
|
||||
//Hack the Console to get the password
|
||||
if (href_list["hack"])
|
||||
var/mob/living/silicon/S = usr
|
||||
if(istype(S) && S.hack_software)
|
||||
hacking = TRUE
|
||||
screen = 2
|
||||
//Time it takes to bruteforce is dependant on the password length.
|
||||
spawn(100*length(linkedServer.decryptkey))
|
||||
if(src && linkedServer && usr)
|
||||
BruteForce(usr)
|
||||
//Delete the log.
|
||||
if (href_list["delete_logs"])
|
||||
//Are they on the view logs screen?
|
||||
if(screen == 1)
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else //if(istype(href_list["delete_logs"], /datum/data_pda_msg))
|
||||
linkedServer.pda_msgs -= locate(href_list["delete_logs"])
|
||||
message = "<span class='notice'>NOTICE: Log Deleted!</span>"
|
||||
//Delete the request console log.
|
||||
if (href_list["delete_requests"])
|
||||
//Are they on the view logs screen?
|
||||
if(screen == 4)
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else //if(istype(href_list["delete_logs"], /datum/data_pda_msg))
|
||||
linkedServer.rc_msgs -= locate(href_list["delete_requests"])
|
||||
message = "<span class='notice'>NOTICE: Log Deleted!</span>"
|
||||
//Create a custom message
|
||||
if (href_list["msg"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
screen = 3
|
||||
//Fake messaging selection - KEY REQUIRED
|
||||
if (href_list["select"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
screen = 0
|
||||
else
|
||||
switch(href_list["select"])
|
||||
|
||||
//Reset
|
||||
if("Reset")
|
||||
ResetMessage()
|
||||
|
||||
//Select Your Name
|
||||
if("Sender")
|
||||
customsender = stripped_input(usr, "Please enter the sender's name.") || customsender
|
||||
|
||||
//Select Receiver
|
||||
if("Recepient")
|
||||
//Get out list of viable PDAs
|
||||
var/list/obj/item/pda/sendPDAs = get_viewable_pdas()
|
||||
if(GLOB.PDAs && GLOB.PDAs.len > 0)
|
||||
customrecepient = input(usr, "Select a PDA from the list.") as null|anything in sortNames(sendPDAs)
|
||||
else
|
||||
customrecepient = null
|
||||
|
||||
//Enter custom job
|
||||
if("RecJob")
|
||||
customjob = stripped_input(usr, "Please enter the sender's job.") || customjob
|
||||
|
||||
//Enter message
|
||||
if("Message")
|
||||
custommessage = stripped_input(usr, "Please enter your message.") || custommessage
|
||||
|
||||
//Send message
|
||||
if("Send")
|
||||
if(isnull(customsender) || customsender == "")
|
||||
customsender = "UNKNOWN"
|
||||
|
||||
if(isnull(customrecepient))
|
||||
message = "<span class='notice'>NOTICE: No recepient selected!</span>"
|
||||
return attack_hand(usr)
|
||||
|
||||
if(isnull(custommessage) || custommessage == "")
|
||||
message = "<span class='notice'>NOTICE: No message entered!</span>"
|
||||
return attack_hand(usr)
|
||||
|
||||
var/datum/signal/subspace/pda/signal = new(src, list(
|
||||
"name" = "[customsender]",
|
||||
"job" = "[customjob]",
|
||||
"message" = custommessage,
|
||||
"emoji_message" = emoji_parse(custommessage),
|
||||
"targets" = list("[customrecepient.owner] ([customrecepient.ownjob])")
|
||||
))
|
||||
// this will log the signal and transmit it to the target
|
||||
linkedServer.receive_information(signal, null)
|
||||
usr.log_message("(PDA: [name] | [usr.real_name]) sent \"[custommessage]\" to [signal.format_target()]", LOG_PDA)
|
||||
|
||||
|
||||
//Request Console Logs - KEY REQUIRED
|
||||
if(href_list["view_requests"])
|
||||
if(LINKED_SERVER_NONRESPONSIVE)
|
||||
message = noserver
|
||||
else if(auth)
|
||||
screen = 4
|
||||
|
||||
if (href_list["back"])
|
||||
screen = 0
|
||||
|
||||
return attack_hand(usr)
|
||||
|
||||
#undef LINKED_SERVER_NONRESPONSIVE
|
||||
|
||||
/obj/item/paper/monitorkey
|
||||
name = "monitor decryption key"
|
||||
|
||||
/obj/item/paper/monitorkey/Initialize(mapload, obj/machinery/telecomms/message_server/server)
|
||||
..()
|
||||
if (server)
|
||||
print(server)
|
||||
return INITIALIZE_HINT_NORMAL
|
||||
else
|
||||
return INITIALIZE_HINT_LATELOAD
|
||||
|
||||
/obj/item/paper/monitorkey/proc/print(obj/machinery/telecomms/message_server/server)
|
||||
info = "<center><h2>Daily Key Reset</h2></center><br>The new message monitor key is '[server.decryptkey]'.<br>Please keep this a secret and away from the clown.<br>If necessary, change the password to a more secure one."
|
||||
info_links = info
|
||||
add_overlay("paper_words")
|
||||
|
||||
/obj/item/paper/monitorkey/LateInitialize()
|
||||
for (var/obj/machinery/telecomms/message_server/server in GLOB.telecomms_list)
|
||||
if (server.decryptkey)
|
||||
print(server)
|
||||
break
|
||||
/*
|
||||
The monitoring computer for the messaging server.
|
||||
Lets you read PDA and request console messages.
|
||||
*/
|
||||
|
||||
// The monitor itself.
|
||||
/obj/machinery/computer/message_monitor
|
||||
name = "message monitor console"
|
||||
desc = "Used to monitor the crew's PDA messages, as well as request console messages."
|
||||
icon_screen = "comm_logs"
|
||||
circuit = /obj/item/circuitboard/computer/message_monitor
|
||||
|
||||
//Servers, and server linked to.
|
||||
var/network = "tcommsat" // the network to probe
|
||||
var/list/machinelist = list() // the servers located by the computer
|
||||
var/obj/machinery/telecomms/message_server/linkedServer = null
|
||||
|
||||
//Sparks effect - For emag
|
||||
var/datum/effect_system/spark_spread/spark_system = new /datum/effect_system/spark_spread
|
||||
|
||||
//Messages - Saves me time if I want to change something.
|
||||
var/noserver = "ALERT: No server detected. Server may be nonresponsive."
|
||||
var/incorrectkey = "ALERT: Incorrect decryption key!"
|
||||
var/rebootmsg = "%$�(�:SYS&EM INTRN@L ACfES VIOL�TIa█ DEtE₡TED! Ree3ARcinG A█ BAaKUP RdST�RE PbINT \[0xcff32ca/ - PLfASE aAIT"
|
||||
|
||||
//Computer properties
|
||||
var/hacking = FALSE // Is it being hacked into by the AI/Cyborg
|
||||
var/message = "" // The message that shows on the main menu.
|
||||
var/auth = FALSE // Are they authenticated?
|
||||
|
||||
// Custom Message Properties
|
||||
var/obj/item/pda/customrecepient = null
|
||||
var/customsender = "System Administrator"
|
||||
var/customjob = "Admin"
|
||||
var/custommessage = "This is a test, please ignore."
|
||||
|
||||
light_color = LIGHT_COLOR_GREEN
|
||||
|
||||
/obj/machinery/computer/message_monitor/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE,\
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "telepdalog", name, 727, 510, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/message_monitor/ui_static_data(mob/user)
|
||||
var/list/data_out = list()
|
||||
|
||||
if(!linkedServer || !auth) // no need building this if the usr isn't authenticated
|
||||
return data_out
|
||||
|
||||
data_out["recon_logs"] = list()
|
||||
var/i1 = 0
|
||||
for(var/datum/data_rc_msg/rc in linkedServer.rc_msgs)
|
||||
i1++
|
||||
if(i1 > 3000)
|
||||
break
|
||||
var/list/data = list(
|
||||
sender = rc.send_dpt,
|
||||
recipient = rc.rec_dpt,
|
||||
message = rc.message,
|
||||
stamp = rc.stamp,
|
||||
auth = rc.id_auth,
|
||||
priority = rc.priority,
|
||||
ref = REF(rc)
|
||||
)
|
||||
data_out["recon_logs"] += list(data)
|
||||
|
||||
data_out["message_logs"] = list()
|
||||
var/i2 = 0
|
||||
for(var/datum/data_pda_msg/pda in linkedServer.pda_msgs)
|
||||
i2++
|
||||
if(i2 > 3000)
|
||||
break
|
||||
var/list/data = list(
|
||||
sender = pda.sender,
|
||||
recipient = pda.recipient,
|
||||
message = pda.message,
|
||||
picture = pda.picture ? TRUE : FALSE,
|
||||
ref = REF(pda)
|
||||
)
|
||||
data_out["message_logs"] += list(data)
|
||||
|
||||
return data_out
|
||||
|
||||
/obj/machinery/computer/message_monitor/ui_data(mob/user)
|
||||
var/list/data_out = list()
|
||||
|
||||
data_out["notice"] = message
|
||||
data_out["authenticated"] = auth
|
||||
data_out["network"] = network
|
||||
|
||||
var/mob/living/silicon/S = user
|
||||
if(istype(S) && S.hack_software)
|
||||
data_out["canhack"] = TRUE
|
||||
|
||||
data_out["hacking"] = (hacking || CHECK_BITFIELD(obj_flags, EMAGGED))
|
||||
if(hacking)
|
||||
data_out["borg"] = ((isAI(user) || iscyborg(user)) && !CHECK_BITFIELD(obj_flags, EMAGGED)) //even borgs can't read emag
|
||||
return data_out
|
||||
|
||||
data_out["servers"] = list()
|
||||
for(var/obj/machinery/telecomms/message_server/T in machinelist)
|
||||
var/list/data = list(
|
||||
name = T.name,
|
||||
id = T.id,
|
||||
ref = REF(T)
|
||||
)
|
||||
data_out["servers"] += list(data) // This /might/ cause an oom. Too bad!
|
||||
data_out["servers"] = sortList(data_out["servers"]) //a-z sort
|
||||
|
||||
data_out["fake_message"] = list(
|
||||
sender = customsender,
|
||||
job = customjob,
|
||||
message = custommessage,
|
||||
recepient = (customrecepient ? "[customrecepient.owner] ([customrecepient.ownjob])" : null)
|
||||
)
|
||||
|
||||
if(!linkedServer)
|
||||
data_out["selected"] = null
|
||||
return data_out
|
||||
|
||||
data_out["selected"] = list(
|
||||
name = linkedServer.name,
|
||||
id = linkedServer.id,
|
||||
ref = REF(linkedServer),
|
||||
status = (linkedServer.on && (linkedServer.toggled != FALSE)) // returns true if server is running
|
||||
)
|
||||
return data_out
|
||||
|
||||
/obj/machinery/computer/message_monitor/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("mainmenu") //deselect
|
||||
linkedServer = null
|
||||
auth = FALSE
|
||||
message = ""
|
||||
return
|
||||
if("release") //release server listing
|
||||
machinelist = list()
|
||||
message = ""
|
||||
return
|
||||
if("network") //network change, flush the selected machine and buffer, and de-auth them, if blank, return default
|
||||
var/newnet = sanitize(sanitize_text(params["value"], network))
|
||||
if(length(newnet) > 15) //i'm looking at you, you href fuckers
|
||||
message = "FAILED: Network tag string too lengthy"
|
||||
return
|
||||
network = newnet
|
||||
linkedServer = null
|
||||
machinelist = list()
|
||||
auth = FALSE
|
||||
message = "NOTICE: Network change detected. Server disconnected, please re-authenticate."
|
||||
return
|
||||
if("probe") //probe network for the pda serbs
|
||||
if(LAZYLEN(machinelist) > 0)
|
||||
message = "FAILED: Cannot probe when buffer full"
|
||||
return
|
||||
|
||||
for(var/obj/machinery/telecomms/message_server/T in GLOB.telecomms_list)
|
||||
if(T.network == network)
|
||||
LAZYADD(machinelist, T)
|
||||
|
||||
if(!LAZYLEN(machinelist))
|
||||
message = "FAILED: Unable to locate network entities in \[[network]\]"
|
||||
return
|
||||
if("viewmachine") //selected but not authorized
|
||||
for(var/obj/machinery/telecomms/message_server/T in machinelist)
|
||||
if(T.id == params["value"])
|
||||
linkedServer = T
|
||||
break
|
||||
|
||||
if("auth")
|
||||
if(!(linkedServer.on && (linkedServer.toggled != FALSE)))
|
||||
message = noserver
|
||||
return
|
||||
if(auth)
|
||||
auth = FALSE
|
||||
update_static_data(usr) //make sure it's cleared!
|
||||
return
|
||||
var/dkey = stripped_input(usr, "Please enter the decryption key.")
|
||||
if(dkey && dkey == "")
|
||||
return
|
||||
if(linkedServer.decryptkey == dkey)
|
||||
auth = TRUE
|
||||
else
|
||||
message = incorrectkey
|
||||
update_static_data(usr)
|
||||
if("change_auth")
|
||||
if(!auth)
|
||||
message = "WARNING: Auth failed! Please log in to change the password!"
|
||||
return
|
||||
else if(!(linkedServer.on && (linkedServer.toggled != FALSE)))
|
||||
message = noserver
|
||||
return
|
||||
|
||||
var/dkey = stripped_input(usr, "Please enter the old decryption key.")
|
||||
if(dkey && dkey != "")
|
||||
if(linkedServer.decryptkey == dkey)
|
||||
var/newkey = stripped_input(usr, "Please enter the new key (3 - 20 characters max):")
|
||||
if(!ISINRANGE(length(newkey), 3, 20))
|
||||
message = "NOTICE: Decryption key length too long/short!"
|
||||
return
|
||||
if(newkey && newkey != "")
|
||||
linkedServer.decryptkey = newkey
|
||||
message = "NOTICE: Decryption key set."
|
||||
return
|
||||
message = incorrectkey
|
||||
|
||||
if("hack")
|
||||
if(!(linkedServer.on && (linkedServer.toggled != FALSE)))
|
||||
message = noserver
|
||||
return
|
||||
|
||||
var/mob/living/silicon/S = usr
|
||||
if(istype(S) && S.hack_software)
|
||||
hacking = TRUE
|
||||
//Time it takes to bruteforce is dependant on the password length.
|
||||
addtimer(CALLBACK(src, .proc/BruteForce, usr), (10 SECONDS) * length(linkedServer.decryptkey))
|
||||
|
||||
if("del_log")
|
||||
if(!auth)
|
||||
message = "WARNING: Auth failed! Delete aborted!"
|
||||
return
|
||||
else if(!(linkedServer.on && (linkedServer.toggled != FALSE)))
|
||||
message = noserver
|
||||
return
|
||||
|
||||
var/datum/data_ref = locate(params["ref"])
|
||||
if(istype(data_ref, /datum/data_rc_msg))
|
||||
LAZYREMOVE(linkedServer.rc_msgs, data_ref)
|
||||
message = "NOTICE: Log Deleted!"
|
||||
else if(istype(data_ref, /datum/data_pda_msg))
|
||||
LAZYREMOVE(linkedServer.pda_msgs, data_ref)
|
||||
message = "NOTICE: Log Deleted!"
|
||||
else
|
||||
message = "NOTICE: Log not found! It may have already been deleted"
|
||||
update_static_data(usr)
|
||||
|
||||
if("clear_log")
|
||||
if(!auth)
|
||||
message = "WARNING: Auth failed! Delete aborted!"
|
||||
return
|
||||
else if(!(linkedServer.on && (linkedServer.toggled != FALSE)))
|
||||
message = noserver
|
||||
return
|
||||
|
||||
var/what = params["value"]
|
||||
if(what == "pda_logs")
|
||||
linkedServer.pda_msgs = list()
|
||||
if(what == "rc_msgs")
|
||||
linkedServer.rc_msgs = list()
|
||||
update_static_data(usr)
|
||||
if("fake")
|
||||
if(!auth)
|
||||
message = "WARNING: Auth failed!"
|
||||
return
|
||||
else if(!(linkedServer.on && (linkedServer.toggled != FALSE)))
|
||||
message = noserver
|
||||
return
|
||||
|
||||
if("reset" in params)
|
||||
ResetMessage()
|
||||
return
|
||||
if("send" in params)
|
||||
if(isnull(customrecepient))
|
||||
message = "NOTICE: No recepient selected!"
|
||||
return
|
||||
if(length(custommessage) <= 0 || custommessage == "")
|
||||
message = "NOTICE: No message entered!"
|
||||
return
|
||||
if(length(customjob) <= 0 || customjob == "")
|
||||
customjob = "Admin"
|
||||
return
|
||||
if(length(customsender) <= 0 || customsender == "")
|
||||
customsender = "UNKNOWN"
|
||||
//sanitize text!!!
|
||||
var/datum/signal/subspace/pda/signal = new(src, list(
|
||||
"name" = sanitize(customsender),
|
||||
"job" = sanitize(customjob),
|
||||
"message" = sanitize(custommessage),
|
||||
"emojis" = TRUE,
|
||||
"targets" = list("[customrecepient.owner] ([customrecepient.ownjob])")
|
||||
))
|
||||
// this will log the signal and transmit it to the target
|
||||
linkedServer.receive_information(signal, null)
|
||||
usr.log_message("(PDA: [name] | [usr.real_name]) sent \"[sanitize(custommessage)]\" to [signal.format_target()]", LOG_PDA)
|
||||
message = ""
|
||||
return
|
||||
// Do not check if it's blank yet
|
||||
// But do check if it's above our set limit (for people who manualy send hrefs at us!)
|
||||
if("sender" in params)
|
||||
var/S = params["sender"]
|
||||
if(length(S) > MAX_NAME_LEN)
|
||||
message = "FAILED: Job string too lengthy"
|
||||
return
|
||||
customsender = S
|
||||
return
|
||||
if("job" in params)
|
||||
var/J = params["job"]
|
||||
if(length(J) > 100)
|
||||
message = "FAILED: Job string too lengthy"
|
||||
return
|
||||
|
||||
customjob = J
|
||||
return
|
||||
if("message" in params)
|
||||
var/M = params["message"]
|
||||
if(length(M) > MAX_MESSAGE_LEN)
|
||||
message = "FAILED: Message string too lengthy"
|
||||
return
|
||||
custommessage = M
|
||||
return
|
||||
|
||||
if("recepient" in params)
|
||||
// Get out list of viable PDAs
|
||||
var/list/obj/item/pda/sendPDAs = get_viewable_pdas()
|
||||
if(GLOB.PDAs && LAZYLEN(GLOB.PDAs) > 0)
|
||||
customrecepient = input(usr, "Select a PDA from the list.") as null|anything in sortNames(sendPDAs)
|
||||
else
|
||||
customrecepient = null
|
||||
return
|
||||
if("refresh")
|
||||
update_static_data(usr)
|
||||
|
||||
/obj/machinery/computer/message_monitor/attackby(obj/item/O, mob/living/user, params)
|
||||
if(istype(O, /obj/item/screwdriver) && CHECK_BITFIELD(obj_flags, EMAGGED))
|
||||
//Stops people from just unscrewing the monitor and putting it back to get the console working again.
|
||||
//Why this though, you should make it emag to a board level. (i wont do it)
|
||||
to_chat(user, "<span class='warning'>It is too hot to mess with!</span>")
|
||||
else
|
||||
return ..()
|
||||
|
||||
/obj/machinery/computer/message_monitor/emag_act(mob/user)
|
||||
. = ..()
|
||||
if(CHECK_BITFIELD(obj_flags, EMAGGED))
|
||||
return
|
||||
if(isnull(linkedServer))
|
||||
to_chat(user, "<span class='notice'>A no server error appears on the screen.</span>")
|
||||
return
|
||||
ENABLE_BITFIELD(obj_flags, EMAGGED)
|
||||
spark_system.set_up(5, 0, src)
|
||||
spark_system.start()
|
||||
var/obj/item/paper/monitorkey/MK = new(loc, linkedServer)
|
||||
// Will help make emagging the console not so easy to get away with.
|
||||
MK.info += "<br><br><font color='red'>�%@%(*$%&(�&?*(%&�/{}</font>"
|
||||
addtimer(CALLBACK(src, .proc/UnmagConsole), (10 SECONDS) * length(linkedServer.decryptkey))
|
||||
//message = rebootmsg
|
||||
return TRUE
|
||||
|
||||
/obj/machinery/computer/message_monitor/New()
|
||||
. = ..()
|
||||
GLOB.telecomms_list += src
|
||||
|
||||
/obj/machinery/computer/message_monitor/Destroy()
|
||||
GLOB.telecomms_list -= src
|
||||
. = ..()
|
||||
|
||||
/obj/machinery/computer/message_monitor/proc/BruteForce(mob/user)
|
||||
if(isnull(linkedServer))
|
||||
to_chat(user, "<span class='warning'>Could not complete brute-force: Linked Server Disconnected!</span>")
|
||||
else
|
||||
var/currentKey = linkedServer.decryptkey
|
||||
to_chat(user, "<span class='warning'>Brute-force completed! The key is '[currentKey]'.</span>")
|
||||
hacking = FALSE
|
||||
message = ""
|
||||
|
||||
/obj/machinery/computer/message_monitor/proc/UnmagConsole()
|
||||
DISABLE_BITFIELD(obj_flags, EMAGGED)
|
||||
message = ""
|
||||
|
||||
/obj/machinery/computer/message_monitor/proc/ResetMessage()
|
||||
customsender = "System Administrator"
|
||||
customrecepient = null
|
||||
custommessage = "This is a test, please ignore."
|
||||
customjob = "Admin"
|
||||
|
||||
/obj/item/paper/monitorkey
|
||||
name = "monitor decryption key"
|
||||
|
||||
/obj/item/paper/monitorkey/Initialize(mapload, obj/machinery/telecomms/message_server/server)
|
||||
..()
|
||||
if(server)
|
||||
print(server)
|
||||
return INITIALIZE_HINT_NORMAL
|
||||
else
|
||||
return INITIALIZE_HINT_LATELOAD
|
||||
|
||||
/obj/item/paper/monitorkey/proc/print(obj/machinery/telecomms/message_server/server)
|
||||
info = "<center><h2>Daily Key Reset</h2></center><br>The new message monitor key is '[server.decryptkey]'.<br>Please keep this a secret and away from the clown.<br>If necessary, change the password to a more secure one."
|
||||
info_links = info
|
||||
add_overlay("paper_words")
|
||||
|
||||
/obj/item/paper/monitorkey/LateInitialize()
|
||||
for(var/obj/machinery/telecomms/message_server/server in GLOB.telecomms_list)
|
||||
if(server.decryptkey)
|
||||
print(server)
|
||||
break
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
|
||||
/*
|
||||
Telecomms monitor tracks the overall trafficing of a telecommunications network
|
||||
and displays a heirarchy of linked machines.
|
||||
@@ -10,117 +9,98 @@
|
||||
icon_screen = "comm_monitor"
|
||||
desc = "Monitors the details of the telecommunications network it's synced with."
|
||||
|
||||
var/screen = 0 // the screen number:
|
||||
var/list/machinelist = list() // the machines located by the computer
|
||||
var/obj/machinery/telecomms/SelectedMachine
|
||||
var/obj/machinery/telecomms/SelectedMachine = null
|
||||
|
||||
var/network = "NULL" // the network to probe
|
||||
var/notice = ""
|
||||
|
||||
var/temp = "" // temporary feedback messages
|
||||
circuit = /obj/item/circuitboard/computer/comm_monitor
|
||||
|
||||
/obj/machinery/computer/telecomms/monitor/ui_interact(mob/user)
|
||||
. = ..()
|
||||
var/dat = "<TITLE>Telecommunications Monitor</TITLE><center><b>Telecommunications Monitor</b></center>"
|
||||
/obj/machinery/computer/telecomms/monitor/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = FALSE,\
|
||||
datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
||||
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
||||
|
||||
switch(screen)
|
||||
if(!ui)
|
||||
ui = new(user, src, ui_key, "telemonitor", name, 575, 400, master_ui, state)
|
||||
ui.open()
|
||||
|
||||
/obj/machinery/computer/telecomms/monitor/ui_data(mob/user)
|
||||
var/list/data_out = list()
|
||||
data_out["network"] = network
|
||||
data_out["notice"] = notice
|
||||
|
||||
// --- Main Menu ---
|
||||
data_out["servers"] = list()
|
||||
for(var/obj/machinery/telecomms/T in machinelist)
|
||||
var/list/data = list(
|
||||
name = T.name,
|
||||
id = T.id,
|
||||
ref = REF(T)
|
||||
)
|
||||
data_out["servers"] += list(data)
|
||||
data_out["servers"] = sortList(data_out["servers"])
|
||||
|
||||
if(0)
|
||||
dat += "<br>[temp]<br><br>"
|
||||
dat += "<br>Current Network: <a href='?src=[REF(src)];network=1'>[network]</a><br>"
|
||||
if(machinelist.len)
|
||||
dat += "<br>Detected Network Entities:<ul>"
|
||||
for(var/obj/machinery/telecomms/T in machinelist)
|
||||
dat += "<li><a href='?src=[REF(src)];viewmachine=[T.id]'>[REF(T)] [T.name]</a> ([T.id])</li>"
|
||||
dat += "</ul>"
|
||||
dat += "<br><a href='?src=[REF(src)];operation=release'>\[Flush Buffer\]</a>"
|
||||
else
|
||||
dat += "<a href='?src=[REF(src)];operation=probe'>\[Probe Network\]</a>"
|
||||
if(!SelectedMachine) //null is bad.
|
||||
data_out["selected"] = null //but in js, null is good.
|
||||
return data_out
|
||||
|
||||
data_out["selected"] = list(
|
||||
name = SelectedMachine.name,
|
||||
id = SelectedMachine.id,
|
||||
status = SelectedMachine.on,
|
||||
traffic = SelectedMachine.traffic,
|
||||
netspeed = SelectedMachine.netspeed,
|
||||
freq_listening = SelectedMachine.freq_listening,
|
||||
long_range_link = SelectedMachine.long_range_link,
|
||||
ref = REF(SelectedMachine)
|
||||
)
|
||||
data_out["selected_servers"] = list()
|
||||
for(var/obj/machinery/telecomms/T in SelectedMachine.links)
|
||||
if(!T.hide)
|
||||
var/list/data = list(
|
||||
name = T.name,
|
||||
id = T.id,
|
||||
ref = REF(T)
|
||||
)
|
||||
data_out["selected_servers"] += list(data)
|
||||
|
||||
return data_out
|
||||
|
||||
// --- Viewing Machine ---
|
||||
|
||||
if(1)
|
||||
dat += "<br>[temp]<br>"
|
||||
dat += "<center><a href='?src=[REF(src)];operation=mainmenu'>\[Main Menu\]</a></center>"
|
||||
dat += "<br>Current Network: [network]<br>"
|
||||
dat += "Selected Network Entity: [SelectedMachine.name] ([SelectedMachine.id])<br>"
|
||||
dat += "Linked Entities: <ol>"
|
||||
for(var/obj/machinery/telecomms/T in SelectedMachine.links)
|
||||
if(!T.hide)
|
||||
dat += "<li><a href='?src=[REF(src)];viewmachine=[T.id]'>[REF(T.id)] [T.name]</a> ([T.id])</li>"
|
||||
dat += "</ol>"
|
||||
|
||||
|
||||
|
||||
user << browse(dat, "window=comm_monitor;size=575x400")
|
||||
onclose(user, "server_control")
|
||||
|
||||
temp = ""
|
||||
return
|
||||
|
||||
|
||||
/obj/machinery/computer/telecomms/monitor/Topic(href, href_list)
|
||||
/obj/machinery/computer/telecomms/monitor/ui_act(action, params)
|
||||
if(..())
|
||||
return
|
||||
switch(action)
|
||||
if("mainmenu")
|
||||
SelectedMachine = null
|
||||
notice = ""
|
||||
return
|
||||
if("release")
|
||||
machinelist = list()
|
||||
notice = ""
|
||||
return
|
||||
if("network") //network change, flush the selected machine and buffer
|
||||
var/newnet = sanitize(sanitize_text(params["value"], network))
|
||||
if(length(newnet) > 15) //i'm looking at you, you href fuckers
|
||||
notice = "FAILED: Network tag string too lengthy"
|
||||
return
|
||||
network = newnet
|
||||
SelectedMachine = null
|
||||
machinelist = list()
|
||||
return
|
||||
if("probe")
|
||||
if(LAZYLEN(machinelist) > 0)
|
||||
notice = "FAILED: Cannot probe when buffer full"
|
||||
return
|
||||
|
||||
for(var/obj/machinery/telecomms/T in GLOB.telecomms_list)
|
||||
if(T.network == network)
|
||||
LAZYADD(machinelist, T)
|
||||
|
||||
|
||||
add_fingerprint(usr)
|
||||
usr.set_machine(src)
|
||||
|
||||
if(href_list["viewmachine"])
|
||||
screen = 1
|
||||
for(var/obj/machinery/telecomms/T in machinelist)
|
||||
if(T.id == href_list["viewmachine"])
|
||||
SelectedMachine = T
|
||||
break
|
||||
|
||||
if(href_list["operation"])
|
||||
switch(href_list["operation"])
|
||||
|
||||
if("release")
|
||||
machinelist = list()
|
||||
screen = 0
|
||||
|
||||
if("mainmenu")
|
||||
screen = 0
|
||||
|
||||
if("probe")
|
||||
if(machinelist.len > 0)
|
||||
temp = "<font color = #D70B00>- FAILED: CANNOT PROBE WHEN BUFFER FULL -</font color>"
|
||||
|
||||
else
|
||||
for(var/obj/machinery/telecomms/T in urange(25, src))
|
||||
if(T.network == network)
|
||||
machinelist.Add(T)
|
||||
|
||||
if(!machinelist.len)
|
||||
temp = "<font color = #D70B00>- FAILED: UNABLE TO LOCATE NETWORK ENTITIES IN \[[network]\] -</font color>"
|
||||
else
|
||||
temp = "<font color = #336699>- [machinelist.len] ENTITIES LOCATED & BUFFERED -</font color>"
|
||||
|
||||
screen = 0
|
||||
|
||||
|
||||
if(href_list["network"])
|
||||
|
||||
var/newnet = stripped_input(usr, "Which network do you want to view?", "Comm Monitor", network)
|
||||
if(newnet && ((usr in range(1, src)) || issilicon(usr)))
|
||||
if(length(newnet) > 15)
|
||||
temp = "<font color = #D70B00>- FAILED: NETWORK TAG STRING TOO LENGHTLY -</font color>"
|
||||
|
||||
else
|
||||
network = newnet
|
||||
screen = 0
|
||||
machinelist = list()
|
||||
temp = "<font color = #336699>- NEW NETWORK TAG SET IN ADDRESS \[[network]\] -</font color>"
|
||||
|
||||
updateUsrDialog()
|
||||
return
|
||||
|
||||
/obj/machinery/computer/telecomms/monitor/attackby()
|
||||
. = ..()
|
||||
updateUsrDialog()
|
||||
if(!LAZYLEN(machinelist))
|
||||
notice = "FAILED: Unable to locate network entities in \[[network]\]"
|
||||
return
|
||||
if("viewmachine")
|
||||
for(var/obj/machinery/telecomms/T in machinelist)
|
||||
if(T.id == params["value"])
|
||||
SelectedMachine = T
|
||||
break
|
||||
|
||||
Reference in New Issue
Block a user