mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-01-03 05:21:27 +00:00
[MIRROR] Removes networks from the game [MDB IGNORE] (#20083)
* Removes networks from the game (#74142) ## About The Pull Request This is a continuation of https://github.com/tgstation/tgstation/pull/74085 - I announced in the comments there that this would be my next PR, and this is it. Removes SSnetwork, ``/datum/ntnet``, ``/datum/component/ntnet_interface``, ``var/network_root_id``, the network unit test, and a lot of other things related to networks. - NTNet circuits now check for an Ntnet relay, and uses signals to operate. - Logs in Wirecarp is now only for PDA and Ntnet Relay things, so you can no longer see what ruins exist using it (why should Wirecarp know that Oldstation spawned? The flavor is that they dont know its there). - Removed it from MULEbots entirely, I don't think it even did anything for them? Botkeeper seems to work without it, so it's possibly there from pre-tgui PDAs. - Moves assigning random names to a base proc instead of being tied to network, this is things like random-naming scrubbers/vents. The behavior hasn't changed at all. - Makes Ntos work for consoles when relays are down, as the comments said they're supposed to (because they're wired). I think this was an accidental change on my part, so this is a revert of that. ## Why It's Good For The Game Ntnet is ancient code that hasn't given us much that we can't do with already existing alternatives, we've been slowly moving away from it for init times, and though a large portion of that was limited to airlocks, I still don't think this is a system worth keeping around. It's way too complex to expect feature coders to do anything with it, and too old with better alternatives for anyone to want to improve any of it. ## Changelog 🆑 fix: Computers are now properly connected to Ethernet, and can use Ntos when Relays are down. refactor: Removes Ntnet and Ntnet interfaces, which was only used by Ntnet circuits (which now directly checks for a Relay to work) and MULEbots, which did nothing with it. balance: Wirecarp no longer tells you what ruins spawned in a round, instead it's limited to PDA logs, and tells you the source too. This means the RD can catch someone running illegal programs if they don't make any attempt at hiding it. qol: Wirecarp logs is now set to save 300 at once, instead of 100 and being increased to 300 by the RD during the round. This is pretty insignificant, since there's no reason to NOT want as many logs as possible. /🆑 --------- Co-authored-by: Zephyr <12817816+ZephyrTFA@ users.noreply.github.com> * Removes networks from the game --------- Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Zephyr <12817816+ZephyrTFA@ users.noreply.github.com>
This commit is contained in:
@@ -1,16 +0,0 @@
|
||||
//NTnet
|
||||
|
||||
///called on an object by its NTNET connection component on receive. (data(datum/netdata))
|
||||
#define COMSIG_COMPONENT_NTNET_RECEIVE "ntnet_receive"
|
||||
///called on an object by its NTNET connection component on a port update (hardware_id, port))
|
||||
#define COMSIG_COMPONENT_NTNET_PORT_UPDATE "ntnet_port_update"
|
||||
/// called when packet was accepted by the target (datum/netdata, error_code)
|
||||
#define COMSIG_COMPONENT_NTNET_ACK "ntnet_ack"
|
||||
/// called when packet was not acknoledged by the target (datum/netdata, error_code)
|
||||
#define COMSIG_COMPONENT_NTNET_NAK "ntnet_nack"
|
||||
|
||||
// Some internal NTnet signals used on ports
|
||||
///called on an object by its NTNET connection component on a port distruction (port, list/data))
|
||||
#define COMSIG_COMPONENT_NTNET_PORT_DESTROYED "ntnet_port_destroyed"
|
||||
///called on an object by its NTNET connection component on a port distruction (port, list/data))
|
||||
#define COMSIG_COMPONENT_NTNET_PORT_UPDATED "ntnet_port_updated"
|
||||
@@ -72,3 +72,6 @@
|
||||
|
||||
/// Called when a ui action is sent for the circuit component
|
||||
#define COMSIG_CIRCUIT_COMPONENT_PERFORM_ACTION "circuit_component_perform_action"
|
||||
|
||||
///Called when an Ntnet sender is sending Ntnet data
|
||||
#define COMSIG_GLOB_CIRCUIT_NTNET_DATA_SENT "!circuit_ntnet_data_sent"
|
||||
|
||||
@@ -1,70 +0,0 @@
|
||||
#define HID_RESTRICTED_END 101 //the first nonrestricted ID, automatically assigned on connection creation.
|
||||
|
||||
#define NETWORK_BROADCAST_ID "ALL"
|
||||
|
||||
/// To debug networks use this to check
|
||||
//#define DEBUG_NETWORKS 1
|
||||
|
||||
|
||||
/// We do some macro magic to make sure the strings are created at compile time rather than runtime
|
||||
/// We do it this way so that if someone changes any of the names of networks we don't have to hunt down
|
||||
/// all the constants though all the files for them. hurrah!
|
||||
|
||||
/// Ugh, couldn't get recursive stringafy to work in byond for some reason
|
||||
#define NETWORK_NAME_COMBINE(L,R) ((L) + "." + (R))
|
||||
|
||||
/// Station network names. Used as the root networks for main parts of the station
|
||||
#define HOLODECK_NETWORK_ROOT "HOLODECK"
|
||||
#define STATION_NETWORK_ROOT "SS13"
|
||||
#define CENTCOM_NETWORK_ROOT "CENTCOM"
|
||||
#define SYNDICATE_NETWORK_ROOT "SYNDI"
|
||||
#define LIMBO_NETWORK_ROOT "LIMBO" // Limbo is a dead network
|
||||
|
||||
|
||||
/// various sub networks pieces
|
||||
#define __NETWORK_CARGO "CARGO"
|
||||
#define __NETWORK_BOTS "BOTS"
|
||||
#define __NETWORK_CIRCUITS "CIRCUITS"
|
||||
|
||||
/// Various combined subnetworks
|
||||
#define NETWORK_BOTS_CARGO NETWORK_NAME_COMBINE(__NETWORK_CARGO, __NETWORK_BOTS)
|
||||
|
||||
/// Network name should be all caps and no punctuation except for _ and . between domains
|
||||
/// This does a quick an dirty fix to a network name to make sure it works
|
||||
/proc/simple_network_name_fix(name)
|
||||
// can't make this as a define, some reason findtext(name,@"^[^\. ]+[A-Z0-9_\.]+[^\. ]+$") dosn't work
|
||||
var/static/regex/check_regex = new(@"[ \-]{1}","g")
|
||||
return check_regex.Replace(uppertext(name),"_")
|
||||
/*
|
||||
* Helper that verifies a network name is valid.
|
||||
*
|
||||
* A valid network name (ie, SS13.ATMOS.SCRUBBERS) is all caps, no spaces with periods between
|
||||
* branches. Returns false if it doesn't meat this requirement
|
||||
*
|
||||
* Arguments:
|
||||
* * name - network text name to check
|
||||
*/
|
||||
/proc/verify_network_name(name)
|
||||
// can't make this as a define, some reason findtext(name,@"^[^\. ]+[A-Z0-9_\.]+[^\. ]+$") dosn't work
|
||||
var/static/regex/check_regex = new(@"^(?=[^\. ]+)[A-Z0-9_\.]+[^\. ]+$")
|
||||
return istext(name) && check_regex.Find(name)
|
||||
|
||||
|
||||
|
||||
/// Port protocol. A port is just a list with a few vars that are used to send signals
|
||||
/// that something is refreshed or updated. These macros make it faster rather than
|
||||
/// calling procs
|
||||
#define NETWORK_PORT_DISCONNECTED(LIST) (!LIST || LIST["_disconnected"])
|
||||
#define NETWORK_PORT_UPDATED(LIST) (LIST && !LIST["_disconnected"] && LIST["_updated"])
|
||||
#define NETWORK_PORT_UPDATE(LIST) if(LIST) { LIST["_updated"] = TRUE }
|
||||
#define NETWORK_PORT_CLEAR_UPDATE(LIST) if(LIST) { LIST["_updated"] = FALSE }
|
||||
#define NETWORK_PORT_SET_UPDATE(LIST) if(LIST) { LIST["_updated"] = TRUE }
|
||||
#define NETWORK_PORT_DISCONNECT(LIST) if(LIST) { LIST["_disconnected"] = TRUE }
|
||||
|
||||
/// Error codes
|
||||
#define NETWORK_ERROR_OK null
|
||||
#define NETWORK_ERROR_NOT_ON_NETWORK "network_error_not_on_network"
|
||||
#define NETWORK_ERROR_BAD_NETWORK "network_error_bad_network"
|
||||
#define NETWORK_ERROR_BAD_RECEIVER_ID "network_error_bad_receiver_id"
|
||||
#define NETWORK_ERROR_UNAUTHORIZED "network_error_bad_unauthorized"
|
||||
|
||||
@@ -156,7 +156,6 @@
|
||||
#define INIT_ORDER_EARLY_ASSETS 48
|
||||
#define INIT_ORDER_RESEARCH 47
|
||||
#define INIT_ORDER_TIMETRACK 46
|
||||
#define INIT_ORDER_NETWORKS 45
|
||||
#define INIT_ORDER_SPATIAL_GRID 43
|
||||
#define INIT_ORDER_ECONOMY 40
|
||||
#define INIT_ORDER_OUTPUTS 35
|
||||
@@ -213,7 +212,6 @@
|
||||
#define FIRE_PRIORITY_REAGENTS 26
|
||||
#define FIRE_PRIORITY_SPACEDRIFT 30
|
||||
#define FIRE_PRIOTITY_SMOOTHING 35
|
||||
#define FIRE_PRIORITY_NETWORKS 40
|
||||
#define FIRE_PRIORITY_OBJ 40
|
||||
#define FIRE_PRIORITY_ACID 40
|
||||
#define FIRE_PRIOTITY_BURNING 40
|
||||
|
||||
@@ -243,6 +243,40 @@ GLOBAL_DATUM(syndicate_code_response_regex, /regex)
|
||||
/proc/hive_name()
|
||||
return "[pick(GLOB.hive_names)]-hive"
|
||||
|
||||
/**
|
||||
* Generate a name devices
|
||||
*
|
||||
* Creates a randomly generated tag or name for devices or anything really
|
||||
* it keeps track of a special list that makes sure no name is used more than
|
||||
* once
|
||||
*
|
||||
* args:
|
||||
* * len (int)(Optional) Default=5 The length of the name
|
||||
* * prefix (string)(Optional) static text in front of the random name
|
||||
* * postfix (string)(Optional) static text in back of the random name
|
||||
* Returns (string) The generated name
|
||||
*/
|
||||
/proc/assign_random_name(len=5, prefix="", postfix="")
|
||||
//DO NOT REMOVE NAMES HERE UNLESS YOU KNOW WHAT YOU'RE DOING
|
||||
//All names already used
|
||||
var/static/list/used_names = list()
|
||||
|
||||
var/static/valid_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
var/list/new_name = list()
|
||||
var/text
|
||||
// machine id's should be fun random chars hinting at a larger world
|
||||
do
|
||||
new_name.Cut()
|
||||
new_name += prefix
|
||||
for(var/i = 1 to len)
|
||||
new_name += valid_chars[rand(1,length(valid_chars))]
|
||||
new_name += postfix
|
||||
text = new_name.Join()
|
||||
while(used_names[text])
|
||||
used_names[text] = TRUE
|
||||
return text
|
||||
|
||||
|
||||
/**
|
||||
* returns an ic name of the tool needed
|
||||
* Arguments:
|
||||
|
||||
@@ -1,7 +1,13 @@
|
||||
///The maximum amount of logs that can be generated before they start overwriting eachother.
|
||||
#define MAX_LOG_COUNT 300
|
||||
|
||||
SUBSYSTEM_DEF(modular_computers)
|
||||
name = "Modular Computers"
|
||||
flags = SS_NO_FIRE
|
||||
|
||||
///List of all ModPC logging
|
||||
var/list/logs = list()
|
||||
|
||||
///List of all programs available to download from the NTNet store.
|
||||
var/list/available_station_software = list()
|
||||
///List of all programs that can be downloaded from an emagged NTNet store.
|
||||
@@ -14,9 +20,6 @@ SUBSYSTEM_DEF(modular_computers)
|
||||
///Boolean to show a message warning if there's an active intrusion for Wirecarp users.
|
||||
var/intrusion_detection_alarm = FALSE
|
||||
|
||||
///List of all available NTNet relays.
|
||||
var/list/obj/machinery/ntnet_relay/ntnet_relays = list()
|
||||
|
||||
/datum/controller/subsystem/modular_computers/Initialize()
|
||||
build_software_lists()
|
||||
initialized = TRUE
|
||||
@@ -35,22 +38,43 @@ SUBSYSTEM_DEF(modular_computers)
|
||||
if(prog.available_on_syndinet)
|
||||
available_antag_software.Add(prog)
|
||||
|
||||
///Checks if at least one ntnet relay is functional.
|
||||
/datum/controller/subsystem/modular_computers/proc/check_relay_operation()
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in ntnet_relays)
|
||||
if(!relays.is_operational)
|
||||
continue
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
///Attempts to find a new file through searching the available stores with its name.
|
||||
/datum/controller/subsystem/modular_computers/proc/find_ntnet_file_by_name(filename)
|
||||
for(var/datum/computer_file/program/programs as anything in available_station_software + available_antag_software)
|
||||
if(filename == programs.filename)
|
||||
return programs
|
||||
return null
|
||||
|
||||
///Attempts to find a chatorom using the ID of the channel.
|
||||
/datum/controller/subsystem/modular_computers/proc/get_chat_channel_by_id(id)
|
||||
for(var/datum/ntnet_conversation/chan as anything in chat_channels)
|
||||
if(chan.id == id)
|
||||
return chan
|
||||
return null
|
||||
|
||||
/**
|
||||
* Records a message into the station logging system for the network
|
||||
* Arguments:
|
||||
* * log_string - The message being logged
|
||||
*/
|
||||
/datum/controller/subsystem/modular_computers/proc/add_log(log_string)
|
||||
var/list/log_text = list()
|
||||
log_text += "\[[station_time_timestamp()]\]"
|
||||
log_text += "*SYSTEM* - "
|
||||
log_text += log_string
|
||||
log_string = log_text.Join()
|
||||
|
||||
logs.Add(log_string)
|
||||
|
||||
// We have too many logs, remove the oldest entries until we get into the limit
|
||||
if(logs.len > MAX_LOG_COUNT)
|
||||
logs = logs.Copy(logs.len - MAX_LOG_COUNT, 0)
|
||||
|
||||
/**
|
||||
* Removes all station logs and leaves it with an alert that it's been wiped.
|
||||
*/
|
||||
/datum/controller/subsystem/modular_computers/proc/purge_logs()
|
||||
logs = list()
|
||||
add_log("-!- LOGS DELETED BY SYSTEM OPERATOR -!-")
|
||||
|
||||
#undef MAX_LOG_COUNT
|
||||
|
||||
@@ -1,485 +0,0 @@
|
||||
SUBSYSTEM_DEF(networks)
|
||||
name = "Networks"
|
||||
priority = FIRE_PRIORITY_NETWORKS
|
||||
wait = 5
|
||||
flags = SS_KEEP_TIMING
|
||||
init_order = INIT_ORDER_NETWORKS
|
||||
|
||||
/// all interfaces by their hardware address.
|
||||
/// Do NOT use to verify a reciver_id is valid, use the network.root_devices for that
|
||||
var/list/interfaces_by_hardware_id = list()
|
||||
|
||||
/// List of networks using their fully qualified network name. Used for quick lookups
|
||||
/// of networks for sending packets
|
||||
var/list/networks = list()
|
||||
/// List of the root networks starting at their root names. Used to find and/or build
|
||||
/// network tress
|
||||
var/list/root_networks = list()
|
||||
|
||||
// Why not list? Because its a Copy() every time we add a packet, and thats stupid.
|
||||
var/datum/netdata/first = null // start of the queue. Pulled off in fire.
|
||||
var/datum/netdata/last = null // end of the queue. pushed on by transmit
|
||||
var/packet_count = 0
|
||||
// packet stats
|
||||
var/count_broadcasts_packets = 0 // count of broadcast packets sent
|
||||
var/count_failed_packets = 0 // count of message fails
|
||||
// Logs moved here
|
||||
// Amount of logs the system tries to keep in memory. Keep below 999 to prevent byond from acting weirdly.
|
||||
// High values make displaying logs much laggier.
|
||||
var/setting_maxlogcount = 100
|
||||
var/list/logs = list()
|
||||
|
||||
/// Random name search to make sure we have unique names.
|
||||
/// DO NOT REMOVE NAMES HERE UNLESS YOU KNOW WHAT YOUR DOING
|
||||
var/list/used_names = list()
|
||||
|
||||
|
||||
/// You shouldn't need to do this. But mapping is async and there is no guarantee that Initialize
|
||||
/// will run before these networks are dynamically created. So its here.
|
||||
/datum/controller/subsystem/networks/PreInit()
|
||||
/// Limbo network needs to be made at boot up for all error devices
|
||||
new/datum/ntnet(LIMBO_NETWORK_ROOT)
|
||||
new/datum/ntnet(STATION_NETWORK_ROOT)
|
||||
new/datum/ntnet(SYNDICATE_NETWORK_ROOT)
|
||||
/// As well as the station network incase something funny goes during startup
|
||||
new/datum/ntnet(CENTCOM_NETWORK_ROOT)
|
||||
|
||||
|
||||
/datum/controller/subsystem/networks/stat_entry(msg)
|
||||
msg = "NET: QUEUE([packet_count]) FAILS([count_failed_packets]) BROADCAST([count_broadcasts_packets])"
|
||||
return ..()
|
||||
|
||||
/datum/controller/subsystem/networks/Initialize()
|
||||
assign_areas_root_ids(get_sorted_areas()) // setup area names before Initialize
|
||||
initialized = TRUE
|
||||
// Now when the objects Initialize they will join the right network
|
||||
return SS_INIT_SUCCESS
|
||||
|
||||
/*
|
||||
* Process incoming queued packet and return NAK/ACK signals
|
||||
*
|
||||
* This should only be called when you want the target object to process the NAK/ACK signal, usually
|
||||
* during fire. At this point data.receiver_id has already been converted if it was a broadcast but
|
||||
* is undefined in this function.
|
||||
* Arguments:
|
||||
* * receiver_id - text hardware id for the target device
|
||||
* * data - packet to be sent
|
||||
*/
|
||||
|
||||
/datum/controller/subsystem/networks/proc/_process_packet(receiver_id, datum/netdata/data)
|
||||
/// Used only for sending NAK/ACK and error reply's
|
||||
var/datum/component/ntnet_interface/sending_interface = interfaces_by_hardware_id[data.sender_id]
|
||||
|
||||
/// Check if the network_id is valid and if not send an error and return
|
||||
var/datum/ntnet/target_network = networks[data.network_id]
|
||||
if(!target_network)
|
||||
count_failed_packets++
|
||||
add_log("Bad target network '[data.network_id]'", null, data.sender_id)
|
||||
if(!QDELETED(sending_interface))
|
||||
SEND_SIGNAL(sending_interface.parent, COMSIG_COMPONENT_NTNET_NAK, data , NETWORK_ERROR_BAD_NETWORK)
|
||||
return
|
||||
|
||||
/// Check if the receiver_id is in the network. If not send an error and return
|
||||
var/datum/component/ntnet_interface/target_interface = target_network.root_devices[receiver_id]
|
||||
if(QDELETED(target_interface))
|
||||
count_failed_packets++
|
||||
add_log("Bad target device '[receiver_id]'", target_network, data.sender_id)
|
||||
if(!QDELETED(sending_interface))
|
||||
SEND_SIGNAL(sending_interface.parent, COMSIG_COMPONENT_NTNET_NAK, data, NETWORK_ERROR_BAD_RECEIVER_ID)
|
||||
return
|
||||
|
||||
// Check if we care about permissions. If we do check if we are allowed the message to be processed
|
||||
if(data.passkey) // got to check permissions
|
||||
var/obj/O = target_interface.parent
|
||||
if(O)
|
||||
if(!O.check_access_ntnet(data.passkey))
|
||||
count_failed_packets++
|
||||
add_log("Access denied to ([receiver_id]) from ([data.network_id])", target_network, data.sender_id)
|
||||
if(!QDELETED(sending_interface))
|
||||
SEND_SIGNAL(sending_interface.parent, COMSIG_COMPONENT_NTNET_NAK, data, NETWORK_ERROR_UNAUTHORIZED)
|
||||
return
|
||||
else
|
||||
add_log("A access key message was sent to a non-device", target_network, data.sender_id)
|
||||
if(!QDELETED(sending_interface))
|
||||
SEND_SIGNAL(sending_interface.parent, COMSIG_COMPONENT_NTNET_NAK, data, NETWORK_ERROR_UNAUTHORIZED)
|
||||
|
||||
|
||||
SEND_SIGNAL(target_interface.parent, COMSIG_COMPONENT_NTNET_RECEIVE, data)
|
||||
// All is good, send the packet then send an ACK to the sender
|
||||
if(!QDELETED(sending_interface))
|
||||
SEND_SIGNAL(sending_interface.parent, COMSIG_COMPONENT_NTNET_ACK, data)
|
||||
|
||||
/// Helper define to make sure we pop the packet and qdel it
|
||||
#define POP_PACKET(CURRENT) first = CURRENT.next; packet_count--; if(!first) { last = null; packet_count = 0; }; qdel(CURRENT);
|
||||
|
||||
/datum/controller/subsystem/networks/fire(resumed = 0)
|
||||
var/datum/netdata/current
|
||||
var/datum/component/ntnet_interface/target_interface
|
||||
while(first)
|
||||
current = first
|
||||
/// Check if we are a list. If so process the list
|
||||
if(islist(current.receiver_id)) // are we a broadcast list
|
||||
var/list/receivers = current.receiver_id
|
||||
var/receiver_id = receivers[receivers.len] // pop it
|
||||
receivers.len--
|
||||
_process_packet(receiver_id, current)
|
||||
if(receivers.len == 0) // pop it if done
|
||||
count_broadcasts_packets++
|
||||
POP_PACKET(current)
|
||||
else // else set up a broadcast or send a single targete
|
||||
// check if we are sending to a network or to a single target
|
||||
target_interface = interfaces_by_hardware_id[current.receiver_id]
|
||||
if(target_interface) // a single sender id
|
||||
_process_packet(current.receiver_id, current) // single target
|
||||
POP_PACKET(current)
|
||||
else // ok so lets find the network to send it too
|
||||
var/datum/ntnet/net = networks[current.network_id] // get the sending network
|
||||
net = net?.networks[current.receiver_id] // find the target network to broadcast
|
||||
if(net) // we found it
|
||||
current.receiver_id = net.collect_interfaces() // make a list of all the sending targets
|
||||
else
|
||||
// We got an error, the network is bad so send a NAK
|
||||
target_interface = interfaces_by_hardware_id[current.sender_id]
|
||||
if(!QDELETED(target_interface))
|
||||
SEND_SIGNAL(target_interface.parent, COMSIG_COMPONENT_NTNET_NAK, current , NETWORK_ERROR_BAD_NETWORK)
|
||||
POP_PACKET(current) // and get rid of it
|
||||
if (MC_TICK_CHECK)
|
||||
return
|
||||
|
||||
#undef POP_PACKET
|
||||
|
||||
/*
|
||||
* Main function to queue a packet. As long as we have valid receiver_id and network_id we will take it
|
||||
*
|
||||
* Main queuing function for any message sent. if the data.receiver_id is null, then it will be broadcasted
|
||||
* error checking is only done during the process this just throws it on the queue.
|
||||
* Arguments:
|
||||
* * data - packet to be sent
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/transmit(datum/netdata/data)
|
||||
data.next = null // sanity check
|
||||
|
||||
if(!last)
|
||||
first = last = data
|
||||
else
|
||||
last.next = data
|
||||
last = data
|
||||
packet_count++
|
||||
// We do error checking when the packet is sent
|
||||
return NETWORK_ERROR_OK
|
||||
|
||||
/**
|
||||
* Records a message into the station logging system for the network
|
||||
*
|
||||
* This CAN be read in station by personal so do not use it for game debugging
|
||||
* during fire. At this point data.receiver_id has already been converted if it was a broadcast but
|
||||
* is undefined in this function. It is also dumped to normal logs but remember players can read/intercept
|
||||
* these messages
|
||||
* Arguments:
|
||||
* * log_string - message to log
|
||||
* * network - optional, It can be a ntnet or just the text equivalent
|
||||
* * hardware_id = optional, text, will look it up and return with the parent.name as well
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/add_log(log_string, network = null)
|
||||
set waitfor = FALSE // so process keeps running
|
||||
var/list/log_text = list()
|
||||
log_text += "\[[station_time_timestamp()]\]"
|
||||
if(network)
|
||||
var/datum/ntnet/net = network
|
||||
if(!istype(net))
|
||||
net = networks[network]
|
||||
if(net) // bad network?
|
||||
log_text += "{[net.network_id]}"
|
||||
else // bad network?
|
||||
log_text += "{[network] *BAD*}"
|
||||
|
||||
log_text += "*SYSTEM* - "
|
||||
log_text += log_string
|
||||
log_string = log_text.Join()
|
||||
|
||||
logs.Add(log_string)
|
||||
//log_telecomms("NetLog: [log_string]") // causes runtime on startup humm
|
||||
|
||||
// We have too many logs, remove the oldest entries until we get into the limit
|
||||
if(logs.len > setting_maxlogcount)
|
||||
logs = logs.Copy(logs.len-setting_maxlogcount,0)
|
||||
|
||||
/**
|
||||
* Removes all station logs for the current game
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/purge_logs()
|
||||
logs = list()
|
||||
add_log("-!- LOGS DELETED BY SYSTEM OPERATOR -!-")
|
||||
|
||||
/datum/controller/subsystem/networks/proc/log_data_transfer( datum/netdata/data)
|
||||
logs += "[station_time_timestamp()] - [data.generate_netlog()]"
|
||||
if(logs.len > setting_maxlogcount)
|
||||
logs = logs.Copy(logs.len - setting_maxlogcount, 0)
|
||||
|
||||
/**
|
||||
* Updates the maximum amount of logs and purges those that go beyond that number
|
||||
*
|
||||
* Shouldn't been needed to be run by players but maybe admins need it?
|
||||
* Arguments:
|
||||
* * lognumber - new setting_maxlogcount count
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/update_max_log_count(lognumber)
|
||||
if(!lognumber)
|
||||
return FALSE
|
||||
// Trim the value if necessary
|
||||
lognumber = max(MIN_NTNET_LOGS, min(lognumber, MAX_NTNET_LOGS))
|
||||
setting_maxlogcount = lognumber
|
||||
add_log("Configuration Updated. Now keeping [setting_maxlogcount] logs in system memory.")
|
||||
|
||||
|
||||
|
||||
/**
|
||||
* Gives an area a root and a network_area_id
|
||||
*
|
||||
* When a device is added to the network on map load, it needs to know where it is.
|
||||
* So that it is added to that ruins/base's network instead of the general station network
|
||||
* This way people on the station cannot just hack Charlie's doors and visa versa. All area's
|
||||
* "should" have this information and if not one is created from existing map tags or
|
||||
* ruin template id's. This SHOULD run before the Initialize of a atom, or the root will not
|
||||
* be put in the object.area
|
||||
*
|
||||
* An example on what the area.network_root_id does/
|
||||
* Before Init: obj.network_id = "ATMOS.SCRUBBER" area.network_root_id="SS13_STATION" area.network_area_id = "BRIDGE"
|
||||
* After Init: obj.network_id = "SS13_STATION.ATMOS.SCRUBBER" also obj.network_id = "SS13_STATION.AREA.BRIDGE"
|
||||
*
|
||||
* Arguments:
|
||||
* * area - Area to modify the root id.
|
||||
* * template - optional, map_template of that area
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/lookup_area_root_id(area/A, datum/map_template/M=null)
|
||||
/// Check if the area is valid and if it doesn't have a network root id.
|
||||
if(!istype(A) || A.network_root_id != null)
|
||||
return
|
||||
|
||||
/// If we are a ruin or a shuttle, we get our own network
|
||||
if(M)
|
||||
/// if we have a template, try to get the network id from the template
|
||||
if(M.station_id && M.station_id != LIMBO_NETWORK_ROOT) // check if the template specifies it
|
||||
A.network_root_id = simple_network_name_fix(M.station_id)
|
||||
else if(istype(M, /datum/map_template/shuttle)) // if not, then check if its a shuttle type
|
||||
var/datum/map_template/shuttle/T = M // we are a shuttle so use shuttle id
|
||||
A.network_root_id = simple_network_name_fix(T.shuttle_id)
|
||||
else if(istype(M,/datum/map_template/ruin)) // if not again, check if its a ruin type
|
||||
var/datum/map_template/ruin/R = M
|
||||
A.network_root_id = simple_network_name_fix(R.id)
|
||||
|
||||
if(!A.network_root_id) // not assigned? Then lets use some defaults
|
||||
// Anything in Centcom is completely isolated
|
||||
// Special case for holodecks.
|
||||
if(istype(A,/area/station/holodeck))
|
||||
A.network_root_id = HOLODECK_NETWORK_ROOT // isolated from the station network
|
||||
else if(SSmapping.level_trait(A.z, ZTRAIT_CENTCOM))
|
||||
A.network_root_id = CENTCOM_NETWORK_ROOT
|
||||
else if(SSmapping.level_trait(A.z, ZTRAIT_RESERVED))
|
||||
A.network_root_id = SYNDICATE_NETWORK_ROOT
|
||||
// Otherwise the default is the station
|
||||
else
|
||||
A.network_root_id = STATION_NETWORK_ROOT
|
||||
|
||||
/datum/controller/subsystem/networks/proc/assign_area_network_id(area/A, datum/map_template/M=null)
|
||||
if(!istype(A))
|
||||
return
|
||||
if(!A.network_root_id)
|
||||
lookup_area_root_id(A, M)
|
||||
// finally set the network area id, bit copy paste from area Initialize
|
||||
// This is done in case we have more than one area type, each area instance has its own network name
|
||||
if(!A.network_area_id)
|
||||
A.network_area_id = A.network_root_id + ".AREA." + simple_network_name_fix(A.name) // Make the string
|
||||
if(!(A.area_flags & UNIQUE_AREA)) // if we aren't a unique area, make sure our name is different
|
||||
A.network_area_id = SSnetworks.assign_random_name(5, A.network_area_id + "_") // tack on some garbage incase there are two area types
|
||||
|
||||
/datum/controller/subsystem/networks/proc/assign_areas_root_ids(list/areas, datum/map_template/map_template)
|
||||
for(var/area/area as anything in areas)
|
||||
assign_area_network_id(area, map_template)
|
||||
|
||||
/**
|
||||
* Converts a list of string's into a full network_id
|
||||
*
|
||||
* Converts a list of individual branches into a proper network id. Validates
|
||||
* individual parts to make sure they are clean.
|
||||
*
|
||||
* ex. list("A","B","C") -> A.B.C
|
||||
*
|
||||
* Arguments:
|
||||
* * tree - List of strings
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/network_list_to_string(list/tree)
|
||||
#ifdef DEBUG_NETWORKS
|
||||
ASSERT(tree && tree.len > 0) // this should be obvious but JUST in case.
|
||||
for(var/part in tree)
|
||||
if(!verify_network_name(part) || findtext(name,".") != 0) // and no stray dots
|
||||
stack_trace("network_list_to_string: Cannot create network with ([part]) of ([tree.Join(".")])")
|
||||
break
|
||||
#endif
|
||||
return tree.Join(".")
|
||||
|
||||
/**
|
||||
* Converts string into a list of network branches
|
||||
*
|
||||
* Converts a a proper network id into a list of the individual branches
|
||||
*
|
||||
* ex. A.B.C -> list("A","B","C")
|
||||
*
|
||||
* Arguments:
|
||||
* * tree - List of strings
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/network_string_to_list(name)
|
||||
#ifdef DEBUG_NETWORKS
|
||||
if(!verify_network_name(name))
|
||||
stack_trace("network_string_to_list: [name] IS INVALID")
|
||||
#endif
|
||||
return splittext(name,".") // should we do a splittext_char? I doubt we really need unicode in network names
|
||||
|
||||
|
||||
/**
|
||||
* Hard creates a network. Helper function for create_network_simple and create_network
|
||||
*
|
||||
* Hard creates a using a list of branches and returns. No error checking as it should
|
||||
* of been done before this call
|
||||
*
|
||||
* Arguments:
|
||||
* * network_tree - list,text List of branches of network
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/_hard_create_network(list/network_tree)
|
||||
var/network_name_part = network_tree[1]
|
||||
var/network_id = network_name_part
|
||||
var/datum/ntnet/parent = root_networks[network_name_part]
|
||||
var/datum/ntnet/network
|
||||
if(!parent) // we have no network root? Must be mapload of a ruin or such
|
||||
parent = new(network_name_part)
|
||||
|
||||
// go up the branches, creating nodes
|
||||
for(var/i in 2 to network_tree.len)
|
||||
network_name_part = network_tree[i]
|
||||
network = parent.children[network_name_part]
|
||||
network_id += "." + network_name_part
|
||||
if(!network)
|
||||
network = new(network_id, network_name_part, parent)
|
||||
|
||||
parent = network
|
||||
return network
|
||||
|
||||
|
||||
/**
|
||||
* Creates or finds a network anywhere in the world using a fully qualified name
|
||||
*
|
||||
* This is the simple case finding of a network in the world. It must take a full
|
||||
* qualified network name and it will either return an existing network or build
|
||||
* a new one from scratch. We must be able to create names on the fly as there is
|
||||
* no way for the map loader to tell us ahead of time what networks to create or
|
||||
* use for any maps or templates. So this thing will throw silent mapping errors
|
||||
* and log them, but will always return a network for something.
|
||||
*
|
||||
* Arguments:
|
||||
* * network_id - text, Fully qualified network name
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/create_network_simple(network_id)
|
||||
|
||||
var/datum/ntnet/network = networks[network_id]
|
||||
if(network != null)
|
||||
return network // don't worry about it
|
||||
|
||||
/// Checks to make sure the network is valid. We log BOTH to mapping and telecoms
|
||||
/// so if your checking for network errors you can find it in mapping to (because its their fault!)
|
||||
if(!verify_network_name(network_id))
|
||||
log_mapping("create_network_simple: [network_id] IS INVALID, replacing with LIMBO")
|
||||
log_telecomms("create_network_simple: [network_id] IS INVALID, replacing with LIMBO")
|
||||
return networks[LIMBO_NETWORK_ROOT]
|
||||
|
||||
var/list/network_tree = network_string_to_list(network_id)
|
||||
if(!network_tree || network_tree.len == 0)
|
||||
log_mapping("create_network_simple: [network_id] IS INVALID, replacing with LIMBO")
|
||||
log_telecomms("create_network_simple: [network_id] IS INVALID, replacing with LIMBO")
|
||||
return networks[LIMBO_NETWORK_ROOT]
|
||||
|
||||
network = _hard_create_network(network_tree)
|
||||
#ifdef DEBUG_NETWORKS
|
||||
if(!network)
|
||||
CRASH("NETWORK CANNOT BE NULL")
|
||||
#endif
|
||||
log_telecomms("create_network_simple: created final [network.network_id]")
|
||||
return network // and we are done!
|
||||
|
||||
|
||||
/**
|
||||
* Creates or finds a network anywhere in the world using bits of text
|
||||
*
|
||||
* This works the same as create_network_simple however it allows the addition
|
||||
* of qualified network names. So you can call it with a root_id and a sub
|
||||
* network. However this function WILL return null if it cannot be created
|
||||
* so it should be used with error checking is involved.
|
||||
*
|
||||
* ex. create_network("ROOT_NETWORK", "ATMOS.SCRUBBERS") -> ROOT_NETWORK.ATMOS.SCRUBBERS
|
||||
*
|
||||
* Arguments:
|
||||
* * tree - List of string
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/create_network(...)
|
||||
var/list/network_tree = list()
|
||||
|
||||
for(var/i in 1 to args.len)
|
||||
var/part = args[i]
|
||||
#ifdef DEBUG_NETWORKS
|
||||
if(!part || !istext(part))
|
||||
/// stack trace here because this is a bad error
|
||||
stack_trace("create_network: We only take text on [part] index [i]")
|
||||
return null
|
||||
#endif
|
||||
network_tree += network_string_to_list(part)
|
||||
|
||||
var/datum/ntnet/network = _hard_create_network(network_tree)
|
||||
log_telecomms("create_network: created final [network.network_id]")
|
||||
return network
|
||||
|
||||
/**
|
||||
* Generate a hardware id for devices.
|
||||
*
|
||||
* Creates a 32 bit hardware id for network devices. This is random so masking
|
||||
* the number won't make routing "easier" (Think Ethernet) It does check if
|
||||
* an existing device has the number but will NOT assign it as thats
|
||||
* up to the collar
|
||||
*
|
||||
* Returns (string) The generated name
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/get_next_HID()
|
||||
do
|
||||
var/string = md5("[num2text(rand(HID_RESTRICTED_END, 999999999), 12)]")
|
||||
if(!string)
|
||||
log_runtime("Could not generagea m5 hash from address, problem with md5?")
|
||||
return //errored
|
||||
. = "[copytext_char(string, 1, 9)]" //16 ^ 8 possibilities I think.
|
||||
while(interfaces_by_hardware_id[.])
|
||||
|
||||
/**
|
||||
* Generate a name devices
|
||||
*
|
||||
* Creates a randomly generated tag or name for devices or anything really
|
||||
* it keeps track of a special list that makes sure no name is used more than
|
||||
* once
|
||||
*
|
||||
* args:
|
||||
* * len (int)(Optional) Default=5 The length of the name
|
||||
* * prefix (string)(Optional) static text in front of the random name
|
||||
* * postfix (string)(Optional) static text in back of the random name
|
||||
* Returns (string) The generated name
|
||||
*/
|
||||
/datum/controller/subsystem/networks/proc/assign_random_name(len=5, prefix="", postfix="")
|
||||
var/static/valid_chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
|
||||
var/list/new_name = list()
|
||||
var/text
|
||||
// machine id's should be fun random chars hinting at a larger world
|
||||
do
|
||||
new_name.Cut()
|
||||
new_name += prefix
|
||||
for(var/i = 1 to len)
|
||||
new_name += valid_chars[rand(1,length(valid_chars))]
|
||||
new_name += postfix
|
||||
text = new_name.Join()
|
||||
while(used_names[text])
|
||||
used_names[text] = TRUE
|
||||
return text
|
||||
@@ -1,140 +0,0 @@
|
||||
|
||||
/*
|
||||
* Helper function that does 90% of the work in sending a packet
|
||||
*
|
||||
* This function gets the component and builds a packet so the sending
|
||||
* person doesn't have to lift a finger. Just create a netdata datum or even
|
||||
* just a list and it will send it on its merry way.
|
||||
*
|
||||
* Arguments:
|
||||
* * packet_data - Either a list() or a /datum/netdata. If its netdata, the other args are ignored
|
||||
* * target_id - Target hardware id or network_id for this packet. If we are a network id, then its
|
||||
broadcasted to that network.
|
||||
* * passkey - Authentication for the packet. If the target doesn't authenticate the packet is dropped
|
||||
*/
|
||||
/datum/proc/ntnet_send(packet_data, target_id = null, passkey = null)
|
||||
var/datum/netdata/data = packet_data
|
||||
if(!istype(data)) // construct netdata from list()
|
||||
if(!islist(packet_data))
|
||||
stack_trace("ntnet_send: Bad packet creation") // hard fail as its runtime fault
|
||||
return
|
||||
data = new(packet_data)
|
||||
data.receiver_id = target_id
|
||||
data.passkey = passkey
|
||||
var/datum/component/ntnet_interface/NIC = GetComponent(/datum/component/ntnet_interface)
|
||||
if(!NIC)
|
||||
return NETWORK_ERROR_NOT_ON_NETWORK
|
||||
data.sender_id = NIC.hardware_id
|
||||
data.network_id = NIC.network.network_id
|
||||
data.receiver_id ||= data.network_id
|
||||
return SSnetworks.transmit(data)
|
||||
|
||||
/*
|
||||
* # /datum/component/ntnet_interface
|
||||
*
|
||||
* This component connects a obj/datum to the station network.
|
||||
*
|
||||
* Anything can be connected to the station network. Any obj can auto connect as long as its network_id
|
||||
* var is set before the parent new is called. This allows map objects to be connected. Technically the
|
||||
* component only handles getting you on the network while SSnetwork and datum/ntnet does all the real work.
|
||||
* There are quite a few stack_traces in here. This is because error checking should be done before this component is
|
||||
* added. Also, there never should be a component that has no network. If it needs a network assign it to LIMBO
|
||||
*
|
||||
*/
|
||||
/datum/component/ntnet_interface
|
||||
var/hardware_id = null // text. this is the true ID. do not change this. stuff like ID forgery can be done manually.
|
||||
var/id_tag = null // named tag, mainly used to look up mapping objects
|
||||
var/datum/ntnet/network = null // network we are on, we MUST be on a network or there is no point in this component
|
||||
var/list/registered_sockets = list()// list of ports opened up on devices
|
||||
var/list/alias = list() // if we live in more than one network branch
|
||||
|
||||
/**
|
||||
* Initialize for the interface
|
||||
*
|
||||
* Assigns a hardware id and gets your object onto the network
|
||||
*
|
||||
* Arguments:
|
||||
* * network_name - Fully qualified network id of the network we are joining
|
||||
* * network_tag - The objects id_tag. Used for finding the device at mapload time
|
||||
*/
|
||||
/datum/component/ntnet_interface/Initialize(network_name, network_tag = null)
|
||||
if(network_name == null || !istext(network_name))
|
||||
log_telecomms("ntnet_interface/Initialize: Bad network '[network_name]' for '[parent]', going to limbo it")
|
||||
network_name = LIMBO_NETWORK_ROOT
|
||||
// Tags cannot be numbers and must be unique over the world
|
||||
if(network_tag != null && !istext(network_tag))
|
||||
// numbers are not allowed as lookups for interfaces
|
||||
log_telecomms("Tag cannot be a number? '[network_name]' for '[parent]', going to limbo it")
|
||||
network_tag = "BADTAG_" + network_tag
|
||||
|
||||
hardware_id = SSnetworks.get_next_HID()
|
||||
id_tag = network_tag
|
||||
SSnetworks.interfaces_by_hardware_id[hardware_id] = src
|
||||
|
||||
network = SSnetworks.create_network_simple(network_name)
|
||||
|
||||
network.add_interface(src)
|
||||
|
||||
|
||||
/**
|
||||
* Create a port for this interface
|
||||
*
|
||||
* A port is basicity a shared associated list() with some values that
|
||||
* indicated its been updated. (see _DEFINES/network.dm). By using a shared
|
||||
* we don't have to worry about qdeling this object if it goes out of scope.
|
||||
*
|
||||
* Once a port is created any number of devices can use the port, however only
|
||||
* the creating interface can disconnect it.
|
||||
*
|
||||
* Arguments:
|
||||
* * port - text, Name of the port installed on this interface
|
||||
* * data - list, shared list of data. Don't put objects in this
|
||||
*/
|
||||
/datum/component/ntnet_interface/proc/register_port(port, list/data)
|
||||
if(!port || !length(data))
|
||||
stack_trace("port is null or data is empty")
|
||||
return
|
||||
if(registered_sockets[port])
|
||||
stack_trace("port already regestered")
|
||||
return
|
||||
data["_updated"] = FALSE
|
||||
registered_sockets[port] = data
|
||||
|
||||
/**
|
||||
* Disconnects an existing port in the interface
|
||||
*
|
||||
* Removes a port from this interface and marks it that its
|
||||
* has been disconnected
|
||||
*
|
||||
* Arguments:
|
||||
* * port - text, Name of the port installed on this interface
|
||||
* * data - list, shared list of data. Don't put objects in this
|
||||
*/
|
||||
/datum/component/ntnet_interface/proc/deregister_port(port)
|
||||
if(registered_sockets[port]) // should I runtime if this isn't in here?
|
||||
var/list/datalink = registered_sockets[port]
|
||||
NETWORK_PORT_DISCONNECT(datalink)
|
||||
// this should remove all outstanding ports
|
||||
registered_sockets.Remove(port)
|
||||
|
||||
|
||||
/**
|
||||
* Connect to a port on this interface
|
||||
*
|
||||
* Returns the shared list that this interface uses to send
|
||||
* data though a port.
|
||||
*
|
||||
* Arguments:
|
||||
* * port - text, Name of the port installed on this interface
|
||||
*/
|
||||
/datum/component/ntnet_interface/proc/connect_port(port)
|
||||
return registered_sockets[port]
|
||||
|
||||
/datum/component/ntnet_interface/Destroy()
|
||||
network.remove_interface(src, TRUE)
|
||||
SSnetworks.interfaces_by_hardware_id.Remove(hardware_id)
|
||||
for(var/port in registered_sockets)
|
||||
var/list/datalink = registered_sockets[port]
|
||||
NETWORK_PORT_DISCONNECT(datalink)
|
||||
registered_sockets.Cut()
|
||||
return ..()
|
||||
@@ -107,11 +107,6 @@
|
||||
///This datum, if set, allows terrain generation behavior to be ran on Initialize()
|
||||
var/datum/map_generator/map_generator
|
||||
|
||||
/// Default network root for this area aka station, lavaland, etc
|
||||
var/network_root_id = null
|
||||
/// Area network id when you want to find all devices hooked up to this area
|
||||
var/network_area_id = null
|
||||
|
||||
///Used to decide what kind of reverb the area makes sound have
|
||||
var/sound_environment = SOUND_ENVIRONMENT_NONE
|
||||
|
||||
@@ -200,11 +195,6 @@ GLOBAL_LIST_EMPTY(teleportlocs)
|
||||
|
||||
reg_in_areas_in_z()
|
||||
|
||||
if(!mapload)
|
||||
if(!network_root_id)
|
||||
network_root_id = STATION_NETWORK_ROOT // default to station root because this might be created with a blueprint
|
||||
SSnetworks.assign_area_network_id(src)
|
||||
|
||||
update_base_lighting()
|
||||
|
||||
return INITIALIZE_HINT_LATELOAD
|
||||
|
||||
@@ -1,14 +1,5 @@
|
||||
|
||||
// CENTCOM
|
||||
|
||||
/*
|
||||
Side note, be sure to change the network_root_id of any areas that are not a part of centcom
|
||||
and just using the z space as safe harbor. It shouldn't matter much as centcom z is isolated
|
||||
from everything anyway.
|
||||
|
||||
The areas used here are STRICTLY on the CC Z level.
|
||||
*/
|
||||
|
||||
// CentCom itself
|
||||
/area/centcom
|
||||
name = "CentCom"
|
||||
@@ -175,7 +166,7 @@ The areas used here are STRICTLY on the CC Z level.
|
||||
has_gravity = STANDARD_GRAVITY
|
||||
area_flags = UNIQUE_AREA | NOTELEPORT
|
||||
flags_1 = NONE
|
||||
network_root_id = "MAGIC_NET"
|
||||
|
||||
|
||||
//Abductors
|
||||
/area/centcom/abductor_ship
|
||||
@@ -187,7 +178,6 @@ The areas used here are STRICTLY on the CC Z level.
|
||||
base_lighting_alpha = 255
|
||||
has_gravity = STANDARD_GRAVITY
|
||||
flags_1 = NONE
|
||||
network_root_id = "ALIENS"
|
||||
|
||||
//Syndicates
|
||||
/area/centcom/syndicate_mothership
|
||||
@@ -198,7 +188,6 @@ The areas used here are STRICTLY on the CC Z level.
|
||||
area_flags = UNIQUE_AREA | NOTELEPORT
|
||||
flags_1 = NONE
|
||||
ambience_index = AMBIENCE_DANGER
|
||||
network_root_id = SYNDICATE_NETWORK_ROOT
|
||||
|
||||
/area/centcom/syndicate_mothership/control
|
||||
name = "Syndicate Control Room"
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
|
||||
var/obj/machinery/computer/holodeck/linked
|
||||
var/restricted = FALSE // if true, program goes on emag list
|
||||
network_root_id = "HOLODECK"
|
||||
/*
|
||||
Power tracking: Use the holodeck computer's power grid
|
||||
Asserts are to avoid the inevitable infinite loops
|
||||
|
||||
@@ -536,7 +536,6 @@
|
||||
ambientsounds = list('sound/ambience/ambisin2.ogg', 'sound/ambience/signal.ogg', 'sound/ambience/signal.ogg', 'sound/ambience/ambigen10.ogg', 'sound/ambience/ambitech.ogg',\
|
||||
'sound/ambience/ambitech2.ogg', 'sound/ambience/ambitech3.ogg', 'sound/ambience/ambimystery.ogg')
|
||||
airlock_wires = /datum/wires/airlock/engineering
|
||||
network_root_id = STATION_NETWORK_ROOT
|
||||
|
||||
//ABANDONED BOX WHITESHIP
|
||||
|
||||
|
||||
@@ -1433,7 +1433,6 @@
|
||||
ambientsounds = list('sound/ambience/ambisin2.ogg', 'sound/ambience/signal.ogg', 'sound/ambience/signal.ogg', 'sound/ambience/ambigen10.ogg', 'sound/ambience/ambitech.ogg',\
|
||||
'sound/ambience/ambitech2.ogg', 'sound/ambience/ambitech3.ogg', 'sound/ambience/ambimystery.ogg')
|
||||
airlock_wires = /datum/wires/airlock/engineering
|
||||
network_root_id = STATION_NETWORK_ROOT // They should of unpluged the router before they left
|
||||
|
||||
/area/station/tcommsat/computer
|
||||
name = "\improper Telecomms Control Room"
|
||||
|
||||
@@ -57,19 +57,6 @@
|
||||
return FALSE
|
||||
return ..()
|
||||
|
||||
// Call this if you want to add your object to a network
|
||||
/obj/proc/init_network_id(network_id)
|
||||
var/area/A = get_area(src)
|
||||
if(A)
|
||||
if(!A.network_root_id)
|
||||
log_telecomms("Area '[A.name]([REF(A)])' has no network network_root_id, force assigning in object [src]([REF(src)])")
|
||||
SSnetworks.lookup_area_root_id(A)
|
||||
network_id = NETWORK_NAME_COMBINE(A.network_root_id, network_id) // I regret nothing!!
|
||||
else
|
||||
log_telecomms("Created [src]([REF(src)] in nullspace, assuming network to be in station")
|
||||
network_id = NETWORK_NAME_COMBINE(STATION_NETWORK_ROOT, network_id) // I regret nothing!!
|
||||
AddComponent(/datum/component/ntnet_interface, network_id, id_tag)
|
||||
|
||||
/// A list of all /obj by their id_tag
|
||||
GLOBAL_LIST_EMPTY(objects_by_id_tag)
|
||||
|
||||
|
||||
@@ -1,126 +0,0 @@
|
||||
// This netlink class shares a list to two devices
|
||||
// This allows skipping of sending many many packets
|
||||
// just to update simple data
|
||||
/datum/netlink
|
||||
var/server_id
|
||||
var/server_network
|
||||
var/port
|
||||
var/passkey = null // sends auth data used to check if we can connect or send data to a device
|
||||
var/list/data
|
||||
|
||||
/datum/netlink/New(datum/component/ntnet_interface/conn, port)
|
||||
data = conn.registered_sockets[port]
|
||||
ASSERT(data != null)
|
||||
server_id = conn.hardware_id
|
||||
server_network = conn.network.network_id
|
||||
src.port = port
|
||||
RegisterSignal(conn, COMSIG_COMPONENT_NTNET_PORT_DESTROYED, PROC_REF(_server_disconnected))
|
||||
..()
|
||||
|
||||
/datum/netlink/proc/_server_disconnected(datum/component/com)
|
||||
SIGNAL_HANDLER
|
||||
data = null
|
||||
|
||||
/datum/netlink/Destroy()
|
||||
passkey = null
|
||||
data = null
|
||||
return ..()
|
||||
|
||||
// If you don't want to use this fine, but this just shows how the system works
|
||||
|
||||
// I hate you all. I want to operator overload []
|
||||
// So fuck you all, Do NOT access data directly you freaks
|
||||
// or this breaks god knows what.
|
||||
// FINE, you don't have to use get, is dirty or even clean
|
||||
// proc overhead is WAY more important than fucking clarity or
|
||||
// sealed classes. But for the LOVE OF GOD make sure _updated
|
||||
// is set if your going to do this.
|
||||
/datum/netlink/proc/get(idx)
|
||||
return data ? data[idx] : null
|
||||
|
||||
/datum/netlink/proc/put(idx, V)
|
||||
// is it posable to do this async without worry about racing conditions?
|
||||
if(data && data[idx] != V)
|
||||
data["_updated"] = TRUE
|
||||
data[idx] = V
|
||||
|
||||
|
||||
/datum/netlink/proc/is_dirty()
|
||||
return data && data["_updated"]
|
||||
|
||||
/datum/netlink/proc/clean()
|
||||
if(data)
|
||||
data["_updated"] = FALSE
|
||||
|
||||
/datum/netlink/proc/is_connected()
|
||||
return data != null
|
||||
|
||||
|
||||
|
||||
/datum/netdata
|
||||
//this requires some thought later on but for now it's fine. (WarlockD) ARRRRG
|
||||
// Packets are kind of shaped like IPX. IPX had a network, a node (aka id) and a port.
|
||||
// Special case with receiver_id == null, that wil broadcast to the network_id
|
||||
// Also, if the network id is not the same for both sender and receiver the packet is dropped.
|
||||
var/sender_id
|
||||
var/receiver_id
|
||||
var/network_id
|
||||
var/passkey = null // sends auth data used to check if we can connect or send data to a device
|
||||
var/list/data = list()
|
||||
// Used for packet queuing
|
||||
var/datum/netdata/next = null
|
||||
var/mob/user = null // used for sending error messages
|
||||
|
||||
/datum/netdata/New(list/data = null)
|
||||
if(!data)
|
||||
data = list()
|
||||
src.data = data
|
||||
|
||||
/datum/netdata/Destroy()
|
||||
data = null
|
||||
passkey = null
|
||||
next = null
|
||||
user = null
|
||||
return ..()
|
||||
|
||||
/datum/netdata/proc/clone(deep_copy=FALSE)
|
||||
var/datum/netdata/C = new
|
||||
C.sender_id = sender_id
|
||||
C.receiver_id = receiver_id
|
||||
C.network_id = network_id
|
||||
C.passkey = passkey
|
||||
C.user = user
|
||||
C.next = null
|
||||
if(deep_copy)
|
||||
C.data = deep_copy_list(data)
|
||||
else
|
||||
C.data = data
|
||||
return C
|
||||
|
||||
|
||||
/datum/netdata/proc/json_to_data(json)
|
||||
data = json_decode(json)
|
||||
|
||||
/datum/netdata/proc/json_append_to_data(json)
|
||||
data |= json_decode(json)
|
||||
|
||||
/datum/netdata/proc/data_to_json()
|
||||
return json_encode(data)
|
||||
|
||||
/datum/netdata/proc/json_list_generation_admin() //for admin logs and such.
|
||||
. = list()
|
||||
. |= json_list_generation()
|
||||
|
||||
/datum/netdata/proc/json_list_generation()
|
||||
. = list()
|
||||
. |= json_list_generation_netlog()
|
||||
|
||||
/datum/netdata/proc/json_list_generation_netlog()
|
||||
. = list()
|
||||
.["network_id"] = network_id
|
||||
.["sender_id"] = sender_id
|
||||
.["receiver_id"] = receiver_id
|
||||
.["data_list"] = data
|
||||
|
||||
/datum/netdata/proc/generate_netlog()
|
||||
return "[json_encode(json_list_generation_netlog())]"
|
||||
@@ -1,211 +0,0 @@
|
||||
/*
|
||||
* # /datum/ntnet
|
||||
*
|
||||
* This class defines each network of the world. Each root network is accessible by any device
|
||||
* on the same network but NOT accessible to any other "root" networks. All normal devices only have
|
||||
* one network and one network_id.
|
||||
*
|
||||
* This thing replaces radio. Think of wifi but better, bigger and bolder! The idea is that any device
|
||||
* on a network can reach any other device on that same network if it knows the hardware_id. You can also
|
||||
* search or broadcast to devices if you know what branch you wish. That is to say you can broadcast to all
|
||||
* devices on "SS13.ATMOS.SCRUBBERS" to change the settings of all the scrubbers on the station or to
|
||||
* "SS13.AREA.FRED_HOME.SCRUBBERS" to all the scrubbers at one area. However devices CANNOT communicate cross
|
||||
* networks normality.
|
||||
*
|
||||
*/
|
||||
|
||||
/datum/ntnet
|
||||
/// The full network name for this network ex. SS13.ATMOS.SCRUBBERS
|
||||
var/network_id
|
||||
/// The network name part of this leaf ex ATMOS
|
||||
var/network_node_id
|
||||
/// All devices on this network. ALL devices on this network, not just this branch.
|
||||
/// This list is shared between all leaf networks so we don't have to keep going to the
|
||||
/// parents on lookups. It is an associated list of hardware_id AND tag_id's
|
||||
var/list/root_devices
|
||||
/// This lists has all the networks in this node. Each name is fully qualified
|
||||
/// ie. SS13.ATMOS.SCRUBBERS, SS13.ATMOS.VENTS, etc
|
||||
var/list/networks
|
||||
/// All the devices on this branch of the network
|
||||
var/list/linked_devices
|
||||
/// Network children. Associated list using the network_node_id of the child as the key
|
||||
var/list/children
|
||||
/// Parrnt of the network. If this is null, we are a oot network
|
||||
var/datum/ntnet/parent
|
||||
|
||||
/*
|
||||
* Creates a new network
|
||||
*
|
||||
* Used for /datum/controller/subsystem/networks/proc/create_network so do not
|
||||
* call yourself as new doesn't do any checking itself
|
||||
*
|
||||
* Arguments:
|
||||
* * net_id - Fully qualified network id for this network
|
||||
* * net_part_id - sub part of a network if this is a child of P
|
||||
* * P - Parent network, this will be attached to that network.
|
||||
*/
|
||||
/datum/ntnet/New(net_id, net_part_id, datum/ntnet/P = null)
|
||||
linked_devices = list()
|
||||
children = list()
|
||||
network_id = net_id
|
||||
|
||||
if(P)
|
||||
network_node_id = net_part_id
|
||||
parent = P
|
||||
parent.children[network_node_id] = src
|
||||
root_devices = parent.root_devices
|
||||
networks = parent.networks
|
||||
networks[network_id] = src
|
||||
else
|
||||
network_node_id = net_id
|
||||
parent = null
|
||||
networks = list()
|
||||
root_devices = linked_devices
|
||||
SSnetworks.root_networks[network_id] = src
|
||||
|
||||
SSnetworks.networks[network_id] = src
|
||||
|
||||
SSnetworks.add_log("Network was created: [network_id]")
|
||||
|
||||
return ..()
|
||||
|
||||
/// A network should NEVER be deleted. If you don't want to show it exists just check if its
|
||||
/// empty
|
||||
/datum/ntnet/Destroy(force)
|
||||
networks -= network_id
|
||||
if(children.len > 0 || linked_devices.len > 0)
|
||||
CRASH("Trying to delete a network with devices still in them")
|
||||
|
||||
if(parent)
|
||||
parent.children.Remove(network_id)
|
||||
parent = null
|
||||
else
|
||||
SSnetworks.root_networks.Remove(network_id)
|
||||
|
||||
SSnetworks.networks.Remove(network_id)
|
||||
|
||||
root_devices = null
|
||||
networks = null
|
||||
network_node_id = null
|
||||
SSnetworks.add_log("Network was destroyed: [network_id]")
|
||||
network_id = null
|
||||
|
||||
return ..()
|
||||
|
||||
/*
|
||||
* Collects all the devices on this branch of the network and maybe its
|
||||
* children
|
||||
*
|
||||
* Used for broadcasting, this will collect all the interfaces on this
|
||||
* network and by default everything below this branch. Will return an
|
||||
* empty list if no devices were found
|
||||
*
|
||||
* Arguments:
|
||||
* * include_children - Include the children of all branches below this
|
||||
*/
|
||||
/datum/ntnet/proc/collect_interfaces(include_children=TRUE)
|
||||
if(!include_children || children.len == 0)
|
||||
return linked_devices.Copy()
|
||||
else
|
||||
/// Please no recursion. Byond hates recursion
|
||||
var/list/devices = list()
|
||||
var/list/queue = list(src) // add ourselves
|
||||
while(queue.len)
|
||||
var/datum/ntnet/net = queue[queue.len--]
|
||||
if(net.children.len > 0)
|
||||
for(var/net_id in net.children)
|
||||
queue += networks[net_id]
|
||||
devices += net.linked_devices
|
||||
return devices
|
||||
|
||||
|
||||
/**
|
||||
* Add this interface to this branch of the network.
|
||||
*
|
||||
* This will add a network interface to this branch of the network.
|
||||
* If the interface already exists on the network it will add it and
|
||||
* give the alias list in the interface this branch name. If the interface
|
||||
* has an id_tag it will add that name to the root_devices for map lookup
|
||||
*
|
||||
* Arguments:
|
||||
* * interface - ntnet component of the device to add to the network
|
||||
*/
|
||||
/datum/ntnet/proc/add_interface(datum/component/ntnet_interface/interface)
|
||||
if(interface.network)
|
||||
/// 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]'")
|
||||
interface.network.remove_interface(interface, TRUE)
|
||||
interface.network ||= src
|
||||
interface.alias[network_id] = src // add to the alias just to make removing easier.
|
||||
linked_devices[interface.hardware_id] = interface
|
||||
root_devices[interface.hardware_id] = interface
|
||||
if(interface.id_tag != null) // could be a type, never know
|
||||
root_devices[interface.id_tag] = interface
|
||||
|
||||
/*
|
||||
* Remove this interface from the network
|
||||
*
|
||||
* This will remove an interface from this network and null the network field on the
|
||||
* interface. Be sure that add_interface is run as soon as posable as an interface MUST
|
||||
* have a network
|
||||
*
|
||||
* Arguments:
|
||||
* * interface - ntnet component of the device to remove to the network
|
||||
* * remove_all_alias - remove ALL references to this device on this network
|
||||
*/
|
||||
/datum/ntnet/proc/remove_interface(datum/component/ntnet_interface/interface, remove_all_alias=FALSE)
|
||||
if(!interface.alias[network_id])
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to leave a '[network_id]'' when its on '[interface.network.network_id]'")
|
||||
return
|
||||
// just cashing it
|
||||
var/hardware_id = interface.hardware_id
|
||||
// Handle the quick case
|
||||
interface.alias.Remove(network_id)
|
||||
linked_devices.Remove(hardware_id)
|
||||
if(remove_all_alias)
|
||||
var/datum/ntnet/net
|
||||
for(var/id in interface.alias)
|
||||
net = interface.alias[id]
|
||||
net.linked_devices.Remove(hardware_id)
|
||||
|
||||
// Now check if there are more than meets the eye
|
||||
if(interface.network == src || remove_all_alias)
|
||||
// Ok, so we got to remove this network, but if we have an alias we are still "on" the network
|
||||
// so we need to shift down to one of the other networks on the alias list. If the alias list
|
||||
// is empty, fuck it and remove it from the network.
|
||||
if(interface.alias.len > 0)
|
||||
interface.network = interface.alias[1] // ... whatever is there.
|
||||
else
|
||||
// ok, hard remove from everything then
|
||||
root_devices.Remove(interface.hardware_id)
|
||||
if(interface.id_tag != null) // could be a type, never know
|
||||
root_devices.Remove(interface.id_tag)
|
||||
interface.network = null
|
||||
|
||||
/*
|
||||
* Move interface to another branch of the network
|
||||
*
|
||||
* This function is a lightweight way of moving an interface from one branch to another like a gps
|
||||
* device going from one area to another. Target network MUST be this network or it will fail
|
||||
*
|
||||
* Arguments:
|
||||
* * interface - ntnet component of the device to move
|
||||
* * target_network - qualified network id to move to
|
||||
* * original_network - qualified network id from the original network if not this one
|
||||
*/
|
||||
/datum/ntnet/proc/move_interface(datum/component/ntnet_interface/interface, target_network, original_network = null)
|
||||
var/datum/ntnet/net = original_network == null ? src : networks[original_network]
|
||||
var/datum/ntnet/target = networks[target_network]
|
||||
if(!target || !net)
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to move to a network ([target_network]) that is not on ([network_id])")
|
||||
return
|
||||
if(target.linked_devices[interface.hardware_id])
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to move to a network ([target_network]) it is already on.")
|
||||
return
|
||||
if(!net.linked_devices[interface.hardware_id])
|
||||
log_telecomms("The device {[interface.hardware_id]} is trying to move to a network ([target_network]) but its not on ([net.network_id]) ")
|
||||
return
|
||||
net.linked_devices.Remove(interface.hardware_id)
|
||||
target.linked_devices[interface.hardware_id] = interface
|
||||
interface.alias.Remove(net.network_id)
|
||||
interface.alias[target.network_id] = target
|
||||
@@ -1,3 +1,14 @@
|
||||
GLOBAL_LIST_EMPTY(ntnet_relays)
|
||||
|
||||
///Checks whether NTNet is available by ensuring at least one relay exists and is operational.
|
||||
/proc/find_functional_ntnet_relay()
|
||||
// Check all relays. If we have at least one working relay, ntos is up.
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
|
||||
if(!relays.is_operational)
|
||||
continue
|
||||
return TRUE
|
||||
return FALSE
|
||||
|
||||
// Relays don't handle any actual communication. Global NTNet datum does that, relays only tell the datum if it should or shouldn't work.
|
||||
/obj/machinery/ntnet_relay
|
||||
name = "NTNet Quantum Relay"
|
||||
@@ -69,13 +80,13 @@
|
||||
if((dos_overload > dos_capacity) && !dos_failure)
|
||||
set_dos_failure(TRUE)
|
||||
update_appearance()
|
||||
SSnetworks.add_log("Quantum relay switched from normal operation mode to overload recovery mode.")
|
||||
SSmodular_computers.add_log("Quantum relay switched from normal operation mode to overload recovery mode.")
|
||||
// If the DoS buffer reaches 0 again, restart.
|
||||
if((dos_overload == 0) && dos_failure)
|
||||
set_dos_failure(FALSE)
|
||||
update_appearance()
|
||||
SSnetworks.add_log("Quantum relay switched from overload recovery mode to normal operation mode.")
|
||||
..()
|
||||
SSmodular_computers.add_log("Quantum relay switched from overload recovery mode to normal operation mode.")
|
||||
return ..()
|
||||
|
||||
/obj/machinery/ntnet_relay/ui_interact(mob/user, datum/tgui/ui)
|
||||
ui = SStgui.try_update_ui(user, src, ui)
|
||||
@@ -100,11 +111,11 @@
|
||||
dos_overload = 0
|
||||
set_dos_failure(FALSE)
|
||||
update_appearance()
|
||||
SSnetworks.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
|
||||
SSmodular_computers.add_log("Quantum relay manually restarted from overload recovery mode to normal operation mode.")
|
||||
return TRUE
|
||||
if("toggle")
|
||||
set_relay_enabled(!relay_enabled)
|
||||
SSnetworks.add_log("Quantum relay manually [relay_enabled ? "enabled" : "disabled"].")
|
||||
SSmodular_computers.add_log("Quantum relay manually [relay_enabled ? "enabled" : "disabled"].")
|
||||
update_appearance()
|
||||
return TRUE
|
||||
|
||||
@@ -112,13 +123,13 @@
|
||||
uid = gl_uid++
|
||||
component_parts = list()
|
||||
|
||||
SSmodular_computers.ntnet_relays.Add(src)
|
||||
SSnetworks.add_log("New quantum relay activated. Current amount of linked relays: [SSmodular_computers.ntnet_relays.len]")
|
||||
GLOB.ntnet_relays += src
|
||||
SSmodular_computers.add_log("New quantum relay activated. Current amount of linked relays: [GLOB.ntnet_relays.len]")
|
||||
return ..()
|
||||
|
||||
/obj/machinery/ntnet_relay/Destroy()
|
||||
SSmodular_computers.ntnet_relays.Remove(src)
|
||||
SSnetworks.add_log("Quantum relay connection severed. Current amount of linked relays: [SSmodular_computers.ntnet_relays.len]")
|
||||
GLOB.ntnet_relays -= src
|
||||
SSmodular_computers.add_log("Quantum relay connection severed. Current amount of linked relays: [GLOB.ntnet_relays.len]")
|
||||
|
||||
for(var/datum/computer_file/program/ntnet_dos/D in dos_sources)
|
||||
D.target = null
|
||||
|
||||
@@ -36,7 +36,7 @@
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/vent_pump/Initialize(mapload)
|
||||
if(!id_tag)
|
||||
id_tag = SSnetworks.assign_random_name()
|
||||
id_tag = assign_random_name()
|
||||
var/static/list/tool_screentips = list(
|
||||
TOOL_MULTITOOL = list(
|
||||
SCREENTIP_CONTEXT_LMB = "Log to link later with air sensor",
|
||||
|
||||
@@ -35,7 +35,7 @@
|
||||
|
||||
/obj/machinery/atmospherics/components/unary/vent_scrubber/Initialize(mapload)
|
||||
if(!id_tag)
|
||||
id_tag = SSnetworks.assign_random_name()
|
||||
id_tag = assign_random_name()
|
||||
. = ..()
|
||||
|
||||
for(var/to_filter in filter_types)
|
||||
|
||||
@@ -92,7 +92,6 @@
|
||||
// first or not. Its defined In Initialize yet its run first in templates
|
||||
// BEFORE so... hummm
|
||||
SSmapping.reg_in_areas_in_z(areas)
|
||||
SSnetworks.assign_areas_root_ids(areas, src)
|
||||
if(!SSatoms.initialized)
|
||||
return
|
||||
|
||||
|
||||
@@ -31,7 +31,6 @@
|
||||
bot_type = MULE_BOT
|
||||
path_image_color = "#7F5200"
|
||||
|
||||
var/network_id = NETWORK_BOTS_CARGO
|
||||
/// unique identifier in case there are multiple mulebots.
|
||||
var/id
|
||||
|
||||
@@ -85,10 +84,6 @@
|
||||
AddElement(/datum/element/ridable, /datum/component/riding/creature/mulebot)
|
||||
diag_hud_set_mulebotcell()
|
||||
|
||||
if(network_id)
|
||||
AddComponent(/datum/component/ntnet_interface, network_id)
|
||||
|
||||
|
||||
/mob/living/simple_animal/bot/mulebot/handle_atom_del(atom/A)
|
||||
if(A == load)
|
||||
unload(0)
|
||||
|
||||
@@ -621,14 +621,14 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
|
||||
|
||||
// Returns 0 for No Signal, 1 for Low Signal and 2 for Good Signal. 3 is for wired connection (always-on)
|
||||
/obj/item/modular_computer/proc/get_ntnet_status()
|
||||
// NTNet is down and we are not connected via wired connection. No signal.
|
||||
if(!SSmodular_computers.check_relay_operation())
|
||||
return NTNET_NO_SIGNAL
|
||||
|
||||
// computers are connected through ethernet
|
||||
if(hardware_flag & PROGRAM_CONSOLE)
|
||||
return NTNET_ETHERNET_SIGNAL
|
||||
|
||||
// NTNet is down and we are not connected via wired connection. No signal.
|
||||
if(!find_functional_ntnet_relay())
|
||||
return NTNET_NO_SIGNAL
|
||||
|
||||
var/turf/current_turf = get_turf(src)
|
||||
if(!current_turf || !istype(current_turf))
|
||||
return NTNET_NO_SIGNAL
|
||||
@@ -646,7 +646,7 @@ GLOBAL_LIST_EMPTY(TabletMessengers) // a list of all active messengers, similar
|
||||
if(!get_ntnet_status())
|
||||
return FALSE
|
||||
|
||||
return SSnetworks.add_log("[src]: [text]", network_id)
|
||||
return SSmodular_computers.add_log("[src]: [text]", network_id)
|
||||
|
||||
/obj/item/modular_computer/proc/shutdown_computer(loud = 1)
|
||||
kill_program(forced = TRUE)
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
return
|
||||
switch(action)
|
||||
if("PRG_target_relay")
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in SSmodular_computers.ntnet_relays)
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
|
||||
if(relays.uid == params["targid"])
|
||||
target = relays
|
||||
break
|
||||
@@ -63,7 +63,7 @@
|
||||
executed = TRUE
|
||||
target.dos_sources.Add(src)
|
||||
if(SSmodular_computers.intrusion_detection_enabled)
|
||||
SSnetworks.add_log("IDS WARNING - Excess traffic flood targeting relay [target.uid] detected from device: [computer.name]")
|
||||
SSmodular_computers.add_log("IDS WARNING - Excess traffic flood targeting relay [target.uid] detected from device: [computer.name]")
|
||||
SSmodular_computers.intrusion_detection_alarm = TRUE
|
||||
return TRUE
|
||||
|
||||
@@ -80,7 +80,7 @@
|
||||
else
|
||||
data["target"] = FALSE
|
||||
data["relays"] = list()
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in SSmodular_computers.ntnet_relays)
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
|
||||
data["relays"] += list(list("id" = relays.uid))
|
||||
data["focus"] = target ? target.uid : null
|
||||
|
||||
|
||||
@@ -23,17 +23,13 @@
|
||||
SSmodular_computers.intrusion_detection_enabled = !SSmodular_computers.intrusion_detection_enabled
|
||||
return TRUE
|
||||
if("toggle_relay")
|
||||
var/obj/machinery/ntnet_relay/target_relay = locate(params["ref"]) in SSmodular_computers.ntnet_relays
|
||||
var/obj/machinery/ntnet_relay/target_relay = locate(params["ref"]) in GLOB.ntnet_relays
|
||||
if(!istype(target_relay))
|
||||
return
|
||||
target_relay.set_relay_enabled(!target_relay.relay_enabled)
|
||||
return TRUE
|
||||
if("purgelogs")
|
||||
SSnetworks.purge_logs()
|
||||
return TRUE
|
||||
if("updatemaxlogs")
|
||||
var/logcount = params["new_number"]
|
||||
SSnetworks.update_max_log_count(logcount)
|
||||
SSmodular_computers.purge_logs()
|
||||
return TRUE
|
||||
if("toggle_mass_pda")
|
||||
var/obj/item/modular_computer/target_tablet = locate(params["ref"]) in GLOB.TabletMessengers
|
||||
@@ -47,7 +43,7 @@
|
||||
var/list/data = list()
|
||||
|
||||
data["ntnetrelays"] = list()
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in SSmodular_computers.ntnet_relays)
|
||||
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
|
||||
var/list/relay_data = list()
|
||||
relay_data["is_operational"] = !!relays.is_operational
|
||||
relay_data["name"] = relays.name
|
||||
@@ -59,9 +55,8 @@
|
||||
data["idsalarm"] = SSmodular_computers.intrusion_detection_alarm
|
||||
|
||||
data["ntnetlogs"] = list()
|
||||
for(var/i in SSnetworks.logs)
|
||||
for(var/i in SSmodular_computers.logs)
|
||||
data["ntnetlogs"] += list(list("entry" = i))
|
||||
data["ntnetmaxlogs"] = SSnetworks.setting_maxlogcount
|
||||
|
||||
data["tablets"] = list()
|
||||
for(var/obj/item/modular_computer/messenger as anything in GetViewableDevices())
|
||||
@@ -76,9 +71,3 @@
|
||||
data["tablets"] += list(tablet_data)
|
||||
|
||||
return data
|
||||
|
||||
/datum/computer_file/program/ntnetmonitor/ui_static_data(mob/user)
|
||||
var/list/data = ..()
|
||||
data["minlogs"] = MIN_NTNET_LOGS
|
||||
data["maxlogs"] = MAX_NTNET_LOGS
|
||||
return data
|
||||
|
||||
@@ -57,7 +57,7 @@ GLOBAL_VAR_INIT(nt_fax_department, pick("NT HR Department", "NT Legal Department
|
||||
/obj/machinery/fax/Initialize(mapload)
|
||||
. = ..()
|
||||
if (!fax_id)
|
||||
fax_id = SSnetworks.assign_random_name()
|
||||
fax_id = assign_random_name()
|
||||
if (!fax_name)
|
||||
fax_name = "Unregistered fax " + fax_id
|
||||
wires = new /datum/wires/fax(src)
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
var/pairing_code = ""
|
||||
|
||||
/datum/duel/New(new_gun_A, new_gun_B)
|
||||
pairing_code = SSnetworks.assign_random_name()
|
||||
pairing_code = assign_random_name()
|
||||
|
||||
gun_A = new_gun_A
|
||||
gun_B = new_gun_B
|
||||
|
||||
@@ -158,7 +158,6 @@
|
||||
#include "mutant_hands_consistency.dm"
|
||||
#include "mutant_organs.dm"
|
||||
#include "novaflower_burn.dm"
|
||||
#include "ntnetwork_tests.dm"
|
||||
#include "nuke_cinematic.dm"
|
||||
#include "objectives.dm"
|
||||
#include "orderable_items.dm"
|
||||
|
||||
@@ -1,93 +0,0 @@
|
||||
/datum/unit_test/ntnetwork
|
||||
var/number_of_names_to_test = 50
|
||||
var/length_of_test_network = 5
|
||||
|
||||
var/static/list/valid_network_names = list(
|
||||
"SS13.ATMOS.SCRUBBERS.SM",
|
||||
"DEEPSPACE.HYDRO.PLANT",
|
||||
"SINDIE.STINKS.BUTT",
|
||||
)
|
||||
|
||||
var/static/list/invalid_network_names = list(
|
||||
".SS13.BOB",
|
||||
"SS13.OHMAN.",
|
||||
"SS13.HAS A SPACE",
|
||||
)
|
||||
|
||||
var/static/list/valid_network_trees = list(
|
||||
list(
|
||||
"SS13",
|
||||
"ATMOS",
|
||||
"SCRUBBERS",
|
||||
"SM",
|
||||
),
|
||||
list(
|
||||
"DEEPSPACE",
|
||||
"HYDRO",
|
||||
"PLANT",
|
||||
),
|
||||
list(
|
||||
"SINDIE",
|
||||
"STINKS",
|
||||
"BUTT",
|
||||
),
|
||||
)
|
||||
|
||||
var/static/list/network_roots = list(
|
||||
HOLODECK_NETWORK_ROOT,
|
||||
STATION_NETWORK_ROOT,
|
||||
CENTCOM_NETWORK_ROOT,
|
||||
SYNDICATE_NETWORK_ROOT,
|
||||
LIMBO_NETWORK_ROOT,
|
||||
)
|
||||
|
||||
var/static/list/random_words_for_testing = list(
|
||||
__NETWORK_CARGO,
|
||||
__NETWORK_BOTS,
|
||||
)
|
||||
|
||||
/datum/unit_test/proc/mangle_word(word)
|
||||
var/len = length(word)
|
||||
var/space_pos = round(len/2)
|
||||
word = copytext(word,1,space_pos) + " " + copytext(word,space_pos,len)
|
||||
return word
|
||||
|
||||
/datum/unit_test/ntnetwork/Run()
|
||||
// First check if name checks work
|
||||
for(var/name in valid_network_names)
|
||||
TEST_ASSERT(verify_network_name(name), "Network name ([name]) marked as invalid but supposed to valid")
|
||||
|
||||
for(var/name in invalid_network_names)
|
||||
TEST_ASSERT(!verify_network_name(name), "Network name ([name]) marked as valid but supposed to be invalid")
|
||||
|
||||
// Next check if we can pack and unpack network names
|
||||
for(var/i in 1 to valid_network_names.len)
|
||||
var/name = valid_network_names[i]
|
||||
var/list/name_list = SSnetworks.network_string_to_list(name)
|
||||
TEST_ASSERT(compare_list(name_list, valid_network_trees[i]), "Network name ([name]) did not unpack into a proper list")
|
||||
for(var/i in 1 to valid_network_trees.len)
|
||||
var/list/name_list = valid_network_trees[i]
|
||||
var/name = SSnetworks.network_list_to_string(name_list)
|
||||
TEST_ASSERT_EQUAL(name, valid_network_names[i], "Network name ([name]) did not pack into a proper string")
|
||||
|
||||
// Ok, we know we can verify network names now, and that we can pack and unpack. Lets try making some random good names
|
||||
var/list/generated_network_names = list()
|
||||
var/test_string
|
||||
for(var/i in 1 to number_of_names_to_test)
|
||||
var/list/builder = list()
|
||||
builder += pick(network_roots)
|
||||
for(var/j in 1 to length_of_test_network)
|
||||
builder += pick(random_words_for_testing)
|
||||
test_string = SSnetworks.network_list_to_string(builder)
|
||||
var/name_fix = simple_network_name_fix(test_string)
|
||||
TEST_ASSERT_EQUAL(name_fix, test_string, "Network name ([test_string]) was not fixed correctly to ([name_fix])")
|
||||
generated_network_names += name_fix // save for future
|
||||
// test badly generated names
|
||||
for(var/i in 1 to number_of_names_to_test)
|
||||
var/list/builder = list()
|
||||
builder += mangle_word(pick(network_roots))
|
||||
for(var/j in 1 to length_of_test_network)
|
||||
builder += mangle_word(pick(random_words_for_testing))
|
||||
test_string = builder.Join(".")
|
||||
var/name_fix = simple_network_name_fix(test_string)
|
||||
TEST_ASSERT(verify_network_name(name_fix), "Network name ([test_string]) was not fixed correctly ([name_fix]) with bad name")
|
||||
@@ -19,17 +19,13 @@
|
||||
/// Encryption key
|
||||
var/datum/port/input/enc_key
|
||||
|
||||
/obj/item/circuit_component/ntnet_receive/Initialize(mapload)
|
||||
. = ..()
|
||||
init_network_id(__NETWORK_CIRCUITS)
|
||||
|
||||
/obj/item/circuit_component/ntnet_receive/populate_options()
|
||||
list_options = add_option_port("List Type", GLOB.wiremod_basic_types)
|
||||
|
||||
/obj/item/circuit_component/ntnet_receive/populate_ports()
|
||||
data_package = add_output_port("Data Package", PORT_TYPE_LIST(PORT_TYPE_ANY))
|
||||
enc_key = add_input_port("Encryption Key", PORT_TYPE_STRING)
|
||||
RegisterSignal(src, COMSIG_COMPONENT_NTNET_RECEIVE, PROC_REF(ntnet_receive))
|
||||
RegisterSignal(SSdcs, COMSIG_GLOB_CIRCUIT_NTNET_DATA_SENT, PROC_REF(ntnet_receive))
|
||||
|
||||
/obj/item/circuit_component/ntnet_receive/pre_input_received(datum/port/input/port)
|
||||
if(port == list_options)
|
||||
@@ -37,13 +33,15 @@
|
||||
data_package.set_datatype(PORT_TYPE_LIST(new_datatype))
|
||||
|
||||
|
||||
/obj/item/circuit_component/ntnet_receive/proc/ntnet_receive(datum/source, datum/netdata/data)
|
||||
/obj/item/circuit_component/ntnet_receive/proc/ntnet_receive(obj/item/circuit_component/ntnet_send/source, list/data)
|
||||
SIGNAL_HANDLER
|
||||
|
||||
if(data.data["enc_key"] != enc_key.value)
|
||||
if(!find_functional_ntnet_relay())
|
||||
return
|
||||
if(data["enc_key"] != enc_key.value)
|
||||
return
|
||||
|
||||
var/datum/weakref/ref = data.data["port"]
|
||||
var/datum/weakref/ref = data["port"]
|
||||
var/datum/port/input/port = ref?.resolve()
|
||||
if(!port)
|
||||
return
|
||||
@@ -52,5 +50,5 @@
|
||||
if(!datatype_handler?.can_receive_from_datatype(port.datatype))
|
||||
return
|
||||
|
||||
data_package.set_output(data.data["data"])
|
||||
data_package.set_output(data["data"])
|
||||
trigger_output.set_output(COMPONENT_SIGNAL)
|
||||
|
||||
@@ -20,10 +20,6 @@
|
||||
/// Encryption key
|
||||
var/datum/port/input/enc_key
|
||||
|
||||
/obj/item/circuit_component/ntnet_send/Initialize(mapload)
|
||||
. = ..()
|
||||
init_network_id(__NETWORK_CIRCUITS)
|
||||
|
||||
/obj/item/circuit_component/ntnet_send/populate_options()
|
||||
list_options = add_option_port("List Type", GLOB.wiremod_basic_types)
|
||||
|
||||
@@ -37,4 +33,6 @@
|
||||
data_package.set_datatype(PORT_TYPE_LIST(new_datatype))
|
||||
|
||||
/obj/item/circuit_component/ntnet_send/input_received(datum/port/input/port)
|
||||
ntnet_send(list("data" = data_package.value, "enc_key" = enc_key.value, "port" = WEAKREF(data_package)))
|
||||
if(!find_functional_ntnet_relay())
|
||||
return
|
||||
SEND_GLOBAL_SIGNAL(COMSIG_GLOB_CIRCUIT_NTNET_DATA_SENT, src, list("data" = data_package.value, "enc_key" = enc_key.value, "port" = WEAKREF(data_package)))
|
||||
|
||||
@@ -144,7 +144,6 @@
|
||||
#include "code\__DEFINES\move_force.dm"
|
||||
#include "code\__DEFINES\movement.dm"
|
||||
#include "code\__DEFINES\movespeed_modification.dm"
|
||||
#include "code\__DEFINES\networks.dm"
|
||||
#include "code\__DEFINES\nitrile.dm"
|
||||
#include "code\__DEFINES\nuclear_bomb.dm"
|
||||
#include "code\__DEFINES\obj_flags.dm"
|
||||
@@ -279,7 +278,6 @@
|
||||
#include "code\__DEFINES\dcs\signals\signals_moveloop.dm"
|
||||
#include "code\__DEFINES\dcs\signals\signals_movetype.dm"
|
||||
#include "code\__DEFINES\dcs\signals\signals_music.dm"
|
||||
#include "code\__DEFINES\dcs\signals\signals_NTNet.dm"
|
||||
#include "code\__DEFINES\dcs\signals\signals_object.dm"
|
||||
#include "code\__DEFINES\dcs\signals\signals_operating_computer.dm"
|
||||
#include "code\__DEFINES\dcs\signals\signals_painting.dm"
|
||||
@@ -705,7 +703,6 @@
|
||||
#include "code\controllers\subsystem\processing\fastprocess.dm"
|
||||
#include "code\controllers\subsystem\processing\greyscale.dm"
|
||||
#include "code\controllers\subsystem\processing\instruments.dm"
|
||||
#include "code\controllers\subsystem\processing\networks.dm"
|
||||
#include "code\controllers\subsystem\processing\obj.dm"
|
||||
#include "code\controllers\subsystem\processing\obj_tab_items.dm"
|
||||
#include "code\controllers\subsystem\processing\plumbing.dm"
|
||||
@@ -1006,7 +1003,6 @@
|
||||
#include "code\datums\components\mob_harvest.dm"
|
||||
#include "code\datums\components\multiple_lives.dm"
|
||||
#include "code\datums\components\mutant_hands.dm"
|
||||
#include "code\datums\components\ntnet_interface.dm"
|
||||
#include "code\datums\components\nuclear_bomb_operator.dm"
|
||||
#include "code\datums\components\omen.dm"
|
||||
#include "code\datums\components\onwear_mood.dm"
|
||||
@@ -4316,8 +4312,6 @@
|
||||
#include "code\modules\movespeed\modifiers\mobs.dm"
|
||||
#include "code\modules\movespeed\modifiers\reagent.dm"
|
||||
#include "code\modules\movespeed\modifiers\status_effects.dm"
|
||||
#include "code\modules\NTNet\netdata.dm"
|
||||
#include "code\modules\NTNet\network.dm"
|
||||
#include "code\modules\NTNet\relays.dm"
|
||||
#include "code\modules\pai\actions.dm"
|
||||
#include "code\modules\pai\camera.dm"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { useBackend, useSharedState } from '../backend';
|
||||
import { Box, Button, LabeledList, NoticeBox, NumberInput, Icon, Section, Stack, Tabs } from '../components';
|
||||
import { Box, Button, LabeledList, NoticeBox, Icon, Section, Stack, Tabs } from '../components';
|
||||
import { NtosWindow } from '../layouts';
|
||||
|
||||
export const NtosNetMonitor = (props, context) => {
|
||||
@@ -9,9 +9,6 @@ export const NtosNetMonitor = (props, context) => {
|
||||
ntnetrelays,
|
||||
idsalarm,
|
||||
idsstatus,
|
||||
ntnetmaxlogs,
|
||||
maxlogs,
|
||||
minlogs,
|
||||
ntnetlogs = [],
|
||||
tablets = [],
|
||||
} = data;
|
||||
@@ -42,9 +39,6 @@ export const NtosNetMonitor = (props, context) => {
|
||||
ntnetrelays={ntnetrelays}
|
||||
idsalarm={idsalarm}
|
||||
idsstatus={idsstatus}
|
||||
ntnetmaxlogs={ntnetmaxlogs}
|
||||
maxlogs={maxlogs}
|
||||
minlogs={minlogs}
|
||||
ntnetlogs={ntnetlogs}
|
||||
/>
|
||||
</Stack.Item>
|
||||
@@ -60,15 +54,7 @@ export const NtosNetMonitor = (props, context) => {
|
||||
};
|
||||
|
||||
const MainPage = (props, context) => {
|
||||
const {
|
||||
ntnetrelays,
|
||||
idsalarm,
|
||||
idsstatus,
|
||||
ntnetmaxlogs,
|
||||
maxlogs,
|
||||
minlogs,
|
||||
ntnetlogs = [],
|
||||
} = props;
|
||||
const { ntnetrelays, idsalarm, idsstatus, ntnetlogs = [] } = props;
|
||||
const { act, data } = useBackend(context);
|
||||
return (
|
||||
<Section>
|
||||
@@ -125,22 +111,6 @@ const MainPage = (props, context) => {
|
||||
</>
|
||||
}
|
||||
/>
|
||||
<LabeledList.Item
|
||||
label="Max Log Count"
|
||||
buttons={
|
||||
<NumberInput
|
||||
value={ntnetmaxlogs}
|
||||
minValue={minlogs}
|
||||
maxValue={maxlogs}
|
||||
width="39px"
|
||||
onChange={(e, value) =>
|
||||
act('updatemaxlogs', {
|
||||
new_number: value,
|
||||
})
|
||||
}
|
||||
/>
|
||||
}
|
||||
/>
|
||||
</LabeledList>
|
||||
<Section
|
||||
title="System Log"
|
||||
|
||||
Reference in New Issue
Block a user