mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-07-12 00:27:31 +01: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,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
|
||||
|
||||
Reference in New Issue
Block a user