From e45fb628f4be3181001266363058fbfc63a202f5 Mon Sep 17 00:00:00 2001 From: Neerti Date: Sat, 7 Jan 2017 13:19:11 -0500 Subject: [PATCH] Adds Telecomms Logging to EPv2 The Exonet Node now has a log window, showing all successful message transmissions that pass through it. Each line contains information about the origin address, target address, the message type, and the contents of the message. Changes the documentation for some procs to be more clear on what they're actually doing. --- code/datums/EPv2.dm | 26 +++++++++++++++----------- code/game/machinery/exonet_node.dm | 15 +++++++++++++++ nano/templates/exonet_node.tmpl | 9 +++++++++ 3 files changed, 39 insertions(+), 11 deletions(-) diff --git a/code/datums/EPv2.dm b/code/datums/EPv2.dm index a4e57d346d1..37a1a0ba1f1 100644 --- a/code/datums/EPv2.dm +++ b/code/datums/EPv2.dm @@ -112,23 +112,27 @@ var/global/list/all_exonet_connections = list() return null // Proc: send_message() -// Parameters: 3 (target_address - the desired address to send the message to, message - the message to send, text - the message text if message is of type "text") -// Description: Sends the message to target_address, by calling receive_message() on the desired datum. -/datum/exonet_protocol/proc/send_message(var/target_address, var/message, var/text) +// Parameters: 3 (target_address - the desired address to send the message to, data_type - text stating what the content is meant to be used for, +// content - the actual 'message' being sent to the address) +// Description: Sends the message to target_address, by calling receive_message() on the desired datum. Returns true if the message is recieved. +/datum/exonet_protocol/proc/send_message(var/target_address, var/data_type, var/content) if(!address) - return 0 + return FALSE + var/obj/machinery/exonet_node/node = get_exonet_node() + if(!node) // Telecomms went boom, ion storm, etc. + return FALSE for(var/datum/exonet_protocol/exonet in all_exonet_connections) if(exonet.address == target_address) - exonet.receive_message(holder, address, message, text) - break + node.write_log(src.address, target_address, data_type, content) + return exonet.receive_message(holder, address, data_type, content) // Proc: receive_message() -// Parameters: 4 (origin_atom - the origin datum's holder, origin_address - the address the message originated from, message - the message that was sent, -// text - the message text if message is of type "text") +// Parameters: 4 (origin_atom - the origin datum's holder, origin_address - the address the message originated from, +// data_type - text stating what the content is meant to be used for, content - the actual 'message' being sent from origin_atom) // Description: Called when send_message() successfully reaches the intended datum. By default, calls receive_exonet_message() on the holder atom. -/datum/exonet_protocol/proc/receive_message(var/atom/origin_atom, var/origin_address, var/message, var/text) - holder.receive_exonet_message(origin_atom, origin_address, message, text) - return +/datum/exonet_protocol/proc/receive_message(var/atom/origin_atom, var/origin_address, var/data_type, var/content) + holder.receive_exonet_message(origin_atom, origin_address, data_type, content) + return TRUE // for send_message() // Proc: receive_exonet_message() // Parameters: 3 (origin_atom - the origin datum's holder, origin_address - the address the message originated from, message - the message that was sent) diff --git a/code/game/machinery/exonet_node.dm b/code/game/machinery/exonet_node.dm index aa36e34c9ef..d871a3ec38e 100644 --- a/code/game/machinery/exonet_node.dm +++ b/code/game/machinery/exonet_node.dm @@ -15,6 +15,8 @@ var/opened = 0 + var/list/logs = list() // Gets written to by exonet's send_message() function. + // Proc: New() // Parameters: None // Description: Adds components to the machine for deconstruction. @@ -60,6 +62,7 @@ else on = 0 idle_power_usage = 0 + update_icon() // Proc: emp_act() // Parameters: 1 (severity - how strong the EMP is, with lower numbers being stronger) @@ -114,6 +117,7 @@ data["allowPDAs"] = allow_external_PDAs data["allowCommunicators"] = allow_external_communicators data["allowNewscasters"] = allow_external_newscasters + data["logs"] = logs // update the ui if it exists, returns null if no ui is passed/found @@ -171,3 +175,14 @@ for(var/obj/machinery/exonet_node/E in machines) if(E.on) return E + +// Proc: write_log() +// Parameters: 4 (origin_address - Where the message is from, target_address - Where the message is going, data_type - Instructions on how to interpet content, +// content - The actual message. +// Description: This writes to the logs list, so that people can see what people are doing on the Exonet ingame. Note that this is not an admin logging function. +// Communicators are already logged seperately. +/obj/machinery/exonet_node/proc/write_log(var/origin_address, var/target_address, var/data_type, var/content) + //var/timestamp = time2text(station_time_in_ticks, "hh:mm:ss") + var/timestamp = "[stationdate2text()] [stationtime2text()]" + var/msg = "[timestamp] | FROM [origin_address] TO [target_address] | TYPE: [data_type] | CONTENT: [content]" + logs.Add(msg) diff --git a/nano/templates/exonet_node.tmpl b/nano/templates/exonet_node.tmpl index f9d81d4e92f..df075c8b89f 100644 --- a/nano/templates/exonet_node.tmpl +++ b/nano/templates/exonet_node.tmpl @@ -38,3 +38,12 @@ Used In File(s): code\game\machinery/exonet_node.dm {{:helper.link('Open', 'check', {'toggle_newscaster_port' : 1}, data.allowNewscasters ? 'selected' : null)}}{{:helper.link('Close', 'close', {'toggle_newscaster_port' : 1}, data.allowNewscasters ? null : 'selected')}} + +

Logging

+
+ {{for data.logs}} +
+ {{:value}} +
+ {{/for}} +