[MIRROR] Adds a modular computer subsystem to shift modPCs away from radios [MDB IGNORE] (#17942)

* Adds a modular computer subsystem to shift modPCs away from radios (#71732)

## About The Pull Request

Adds the modular computer subsystem which is meant to replace mod PC's
reliance on networks and radios, specifically the network subsystem, the
ntnet interface, and /datum/ntnet. This PR removes station_root ntnets
entirely, but I tried to keep it small.

This PR also removes a ton of unused vars and defines, such as NTNet
channels that were unused (peer2peer and systemcontrol), atmos networks
(as they were removed a while ago) and NTNet var on relays (its stated
purpose is so admins can see it through varedits, but that's useless now
that it's a subsystem)

I also removed ``setting_disabled`` as a thing the RD can do, it turned
off ALL ntnet systems. However, this was when there were 4 different
ones, now that there's only 2 I thought it was redundant and he could
just click 2 buttons to close them.

## Why It's Good For The Game

``/datum/ntnet``, ``/datum/component/ntnet_interface``, and
``/datum/controller/subsystem/networks`` are all old-code messes that
depend on eachother and is hard for people to understand what exactly it
adds to the game. 90% of its features is allowing the Wirecarp app to
see all the ruins that spawned in-game, which I don't think is something
that we even WANT (why does the RD need to know that oldstation spawned?
Why should they know this anyway??)

This hopefully starts to simplify networks/ntnet to make it easier to
remove in the future, because surely there are better alternatives than
**this**

## Changelog

🆑
refactor: Modular computers NTnet and applications run on its own
subsystem, please report any new bugs you may find.
/🆑

* Adds a modular computer subsystem to shift modPCs away from radios

* Fixed contractor uplink

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
Co-authored-by: tastyfish <crazychris32@gmail.com>
This commit is contained in:
SkyratBot
2022-12-13 00:36:54 +01:00
committed by GitHub
parent 919b1bc253
commit 86e811f782
18 changed files with 205 additions and 370 deletions
+1 -187
View File
@@ -33,7 +33,6 @@
/// Parrnt of the network. If this is null, we are a oot network
var/datum/ntnet/parent
/*
* Creates a new network
*
@@ -72,7 +71,7 @@
/// A network should NEVER be deleted. If you don't want to show it exists just check if its
/// empty
/datum/ntnet/Destroy()
/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")
@@ -120,17 +119,6 @@
return devices
/*
* Find if an interface exists on this network
*
* Used to look up a device on the network.
*
* Arguments:
* * tag_or_hid - Ither the hardware id or the id_tag
*/
/datum/ntnet/proc/find_interface(tag_or_hid)
return root_devices[tag_or_hid]
/**
* Add this interface to this branch of the network.
*
@@ -221,177 +209,3 @@
target.linked_devices[interface.hardware_id] = interface
interface.alias.Remove(net.network_id)
interface.alias[target.network_id] = target
/datum/ntnet/station_root
var/list/services_by_path = list() //type = datum/ntnet_service
var/list/services_by_id = list() //id = datum/ntnet_service
var/list/autoinit_service_paths = list() //typepaths
var/list/available_station_software = list()
var/list/available_antag_software = list()
var/list/chat_channels = list()
var/list/fileservers = list()
// These only affect wireless. LAN (consoles) are unaffected since it would be possible to create scenario where someone turns off NTNet, and is unable to turn it back on since it refuses connections
var/setting_softwaredownload = TRUE
var/setting_peertopeer = TRUE
var/setting_communication = TRUE
var/setting_systemcontrol = TRUE
var/setting_disabled = FALSE // Setting to 1 will disable all wireless, independently on relays status.
var/intrusion_detection_enabled = TRUE // Whether the IDS warning system is enabled
var/intrusion_detection_alarm = FALSE // Set when there is an IDS warning due to malicious (antag) software.
// If new NTNet datum is spawned, it replaces the old one.
/datum/ntnet/station_root/New(root_name)
. = ..()
SSnetworks.add_log("NTNet logging system activated for [root_name]")
#ifdef NTNET_SERVICE
/datum/ntnet/station_root/Destroy()
for(var/i in services_by_id)
var/S = i
S.disconnect(src, TRUE)
return ..()
/datum/ntnet/station_root/proc/find_service_id(id)
return services_by_id[id]
/datum/ntnet/station_root/proc/find_service_path(path)
return services_by_path[path]
/datum/ntnet/station_root/proc/register_service(datum/ntnet_service/S)
if(!istype(S))
return FALSE
if(services_by_path[S.type] || services_by_id[S.id])
return FALSE
services_by_path[S.type] = S
services_by_id[S.id] = S
return TRUE
/datum/ntnet/station_root/proc/unregister_service(datum/ntnet_service/S)
if(!istype(S))
return FALSE
services_by_path -= S.type
services_by_id -= S.id
return TRUE
/datum/ntnet/station_root/proc/create_service(type)
var/datum/ntnet_service/S = new type
if(!istype(S))
return FALSE
. = S.connect(src)
if(!.)
qdel(S)
/datum/ntnet/station_root/proc/destroy_service(type)
var/datum/ntnet_service/S = find_service_path(type)
if(!istype(S))
return FALSE
. = S.disconnect(src)
if(.)
qdel(src)
/datum/ntnet/station_root/proc/process_data_transmit(datum/component/ntnet_interface/sender, datum/netdata/data)
if(..())
for(var/i in services_by_id)
var/datum/ntnet_service/serv = services_by_id[i]
serv.ntnet_intercept(data, src, sender)
return TRUE
#endif
// Checks whether NTNet operates. If parameter is passed checks whether specific function is enabled.
/datum/ntnet/station_root/proc/check_function(specific_action = 0)
if(!SSnetworks.relays || !SSnetworks.relays.len) // No relays found. NTNet is down
return FALSE
// Check all relays. If we have at least one working relay, network is up.
if(!SSnetworks.check_relay_operation())
return FALSE
if(setting_disabled)
return FALSE
switch(specific_action)
if(NTNET_SOFTWAREDOWNLOAD)
return setting_softwaredownload
if(NTNET_PEERTOPEER)
return setting_peertopeer
if(NTNET_COMMUNICATION)
return setting_communication
if(NTNET_SYSTEMCONTROL)
return setting_systemcontrol
return TRUE
// Builds lists that contain downloadable software.
/datum/ntnet/station_root/proc/build_software_lists()
available_station_software = list()
available_antag_software = list()
for(var/F in typesof(/datum/computer_file/program))
var/datum/computer_file/program/prog = new F
// Invalid type (shouldn't be possible but just in case), invalid filetype (not executable program) or invalid filename (unset program)
if(!prog || prog.filename == "UnknownProgram" || prog.filetype != "PRG")
continue
// Check whether the program should be available for station/antag download, if yes, add it to lists.
if(prog.available_on_ntnet)
available_station_software.Add(prog)
if(prog.available_on_syndinet)
available_antag_software.Add(prog)
// Attempts to find a downloadable file according to filename var
/datum/ntnet/station_root/proc/find_ntnet_file_by_name(filename)
for(var/N in available_station_software)
var/datum/computer_file/program/P = N
if(filename == P.filename)
return P
for(var/N in available_antag_software)
var/datum/computer_file/program/P = N
if(filename == P.filename)
return P
/datum/ntnet/station_root/proc/get_chat_channel_by_id(id)
for(var/datum/ntnet_conversation/chan in chat_channels)
if(chan.id == id)
return chan
// Resets the IDS alarm
/datum/ntnet/station_root/proc/resetIDS()
intrusion_detection_alarm = FALSE
/datum/ntnet/station_root/proc/toggleIDS()
resetIDS()
intrusion_detection_enabled = !intrusion_detection_enabled
/datum/ntnet/station_root/proc/toggle_function(function)
if(!function)
return
function = text2num(function)
switch(function)
if(NTNET_SOFTWAREDOWNLOAD)
setting_softwaredownload = !setting_softwaredownload
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_softwaredownload ? "allows" : "disallows"] connection to software repositories.")
if(NTNET_PEERTOPEER)
setting_peertopeer = !setting_peertopeer
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_peertopeer ? "allows" : "disallows"] peer to peer network traffic.")
if(NTNET_COMMUNICATION)
setting_communication = !setting_communication
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_communication ? "allows" : "disallows"] instant messaging and similar communication services.")
if(NTNET_SYSTEMCONTROL)
setting_systemcontrol = !setting_systemcontrol
SSnetworks.add_log("Configuration Updated. Wireless network firewall now [setting_systemcontrol ? "allows" : "disallows"] remote control of station's systems.")
/datum/ntnet/station_root/proc/register_map_supremecy() //called at map init to make this what station networks use.
for(var/obj/machinery/ntnet_relay/R in GLOB.machines)
SSnetworks.relays.Add(R)
R.NTNet = src
+5 -10
View File
@@ -9,7 +9,6 @@
density = TRUE
circuit = /obj/item/circuitboard/machine/ntnet_relay
var/datum/ntnet/NTNet = null // This is mostly for backwards reference and to allow varedit modifications from ingame.
///On / off status for the relay machine, toggleable by the user.
var/relay_enabled = TRUE
///(D)DoS-attack-related failure causing it not to be operational any longer.
@@ -116,17 +115,13 @@
uid = gl_uid++
component_parts = list()
if(SSnetworks.station_network)
SSnetworks.relays.Add(src)
NTNet = SSnetworks.station_network
SSnetworks.add_log("New quantum relay activated. Current amount of linked relays: [SSnetworks.relays.len]")
. = ..()
SSmodular_computers.ntnet_relays.Add(src)
SSnetworks.add_log("New quantum relay activated. Current amount of linked relays: [SSmodular_computers.ntnet_relays.len]")
return ..()
/obj/machinery/ntnet_relay/Destroy()
if(SSnetworks.station_network)
SSnetworks.relays.Remove(src)
SSnetworks.add_log("Quantum relay connection severed. Current amount of linked relays: [SSnetworks.relays.len]")
NTNet = null
SSmodular_computers.ntnet_relays.Remove(src)
SSnetworks.add_log("Quantum relay connection severed. Current amount of linked relays: [SSmodular_computers.ntnet_relays.len]")
for(var/datum/computer_file/program/ntnet_dos/D in dos_sources)
D.target = null