Renames vars on pdas and removes ntnet_relays glob (#79595)

## About The Pull Request

- replaces the ntnet_relays global list with ``get_machines_by_type``
- renames ``transfer_access`` var on PDA to ``download_access`` &
``required_access`` to ``run_access`` to better describe what they do,
because on more than one ocassion I've confused myself with the two
terms and ended up doing something unintentional (see:
https://github.com/tgstation/tgstation/pull/74269)

## Why It's Good For The Game

Kills a useless global list and makes pda code a little less confusing.

## Changelog

Nothing player-facing.
This commit is contained in:
John Willard
2023-11-12 19:35:58 -05:00
committed by GitHub
parent 67ad491337
commit 78f04be9f8
21 changed files with 66 additions and 73 deletions
@@ -31,13 +31,12 @@ This is how the base program is setup. the rest is mostly tgui stuff. I'll use t
/// programs.
requires_ntnet = 1
/// This is access required to run the program itself. ONLY SET THIS FOR
/// SUPER SECURE SHIT. This also acts as transfer_access as well.
required_access = access_network
/// This is access required to run the program itself.
run_access = access_network
/// This is the access needed to download from ntnet or host on the ptp
/// program. This is what you want to use most of the time.
transfer_access = access_change_ids
download_access = access_change_ids
/// If it's available to download on ntnet. pretty self explanatory.
available_on_ntnet = 1
@@ -9,10 +9,11 @@
///How much power running this program costs.
var/power_cell_use = PROGRAM_BASIC_CELL_USE
/// List of required accesses to *run* the program. Any match will do.
var/list/required_access = list()
/// List of required access to download or file host the program. Any match will do.
var/list/transfer_access = list()
///List of required accesses to *run* the program. Any match will do.
///This also acts as download_access if that is not set, making this more draconic and restrictive.
var/list/run_access = list()
///List of required access to download or file host the program. Any match will do.
var/list/download_access = list()
/// User-friendly name of this program.
var/filedesc = "Unknown Program"
/// Short description of this program's function.
@@ -52,7 +53,7 @@
/datum/computer_file/program/clone()
var/datum/computer_file/program/temp = ..()
temp.required_access = required_access
temp.run_access = run_access
temp.filedesc = filedesc
temp.program_icon_state = program_icon_state
temp.requires_ntnet = requires_ntnet
@@ -115,33 +116,32 @@
return TRUE
/**
*Check if the user can run program. Only humans and silicons can operate computer. Automatically called in on_start()
*ID must be inserted into a card slot to be read. If the program is not currently installed (as is the case when
*NT Software Hub is checking available software), a list can be given to be used instead.
*Arguments:
*user is a ref of the mob using the device.
*loud is a bool deciding if this proc should use to_chats
*access_to_check is an access level that will be checked against the ID
*transfer, if TRUE and access_to_check is null, will tell this proc to use the program's transfer_access in place of access_to_check
*access can contain a list of access numbers to check against. If access is not empty, it will be used istead of checking any inserted ID.
*/
/datum/computer_file/program/proc/can_run(mob/user, loud = FALSE, access_to_check, transfer = FALSE, list/access)
* Checks if the user can run program. Only humans and silicons can operate computer. Automatically called in on_start()
* ID must be inserted into a card slot to be read. If the program is not currently installed (as is the case when
* NT Software Hub is checking available software), a list can be given to be used instead.
* Args:
* user is a ref of the mob using the device.
* loud is a bool deciding if this proc should use to_chats
* access_to_check is an access level that will be checked against the ID
* downloading: Boolean on whether it's downloading the app or not. If it is, it will check download_access instead of run_access.
* access can contain a list of access numbers to check against. If access is not empty, it will be used istead of checking any inserted ID.
*/
/datum/computer_file/program/proc/can_run(mob/user, loud = FALSE, access_to_check, downloading = FALSE, list/access)
if(issilicon(user) && !ispAI(user))
return TRUE
if(isAdminGhostAI(user))
return TRUE
if(computer && (computer.obj_flags & EMAGGED) && (available_on_syndinet || !transfer)) //emagged can run anything on syndinet, and can bypass execution locks, but not download.
if(computer && (computer.obj_flags & EMAGGED) && (available_on_syndinet || !downloading)) //emagged can run anything on syndinet, and can bypass execution locks, but not download.
return TRUE
// Defaults to required_access
if(!access_to_check)
if(transfer && length(transfer_access))
access_to_check = transfer_access
if(downloading && length(download_access))
access_to_check = download_access
else
access_to_check = required_access
if(!length(access_to_check)) // No required_access, allow it.
access_to_check = run_access
if(!length(access_to_check)) // No access requirements, allow it.
return TRUE
if(!length(access))
@@ -7,7 +7,7 @@
size = 12
requires_ntnet = FALSE
usage_flags = PROGRAM_CONSOLE | PROGRAM_LAPTOP
transfer_access = list(ACCESS_RD)
download_access = list(ACCESS_RD)
available_on_ntnet = TRUE
tgui_id = "NtosAiRestorer"
program_icon = "laptop-code"
@@ -42,7 +42,7 @@
/datum/computer_file/program/ntnet_dos/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
switch(action)
if("PRG_target_relay")
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
for(var/obj/machinery/ntnet_relay/relays as anything in SSmachines.get_machines_by_type(/obj/machinery/ntnet_relay))
if(relays.uid == params["targid"])
target = relays
break
@@ -76,7 +76,7 @@
else
data["target"] = FALSE
data["relays"] = list()
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
for(var/obj/machinery/ntnet_relay/relays as anything in SSmachines.get_machines_by_type(/obj/machinery/ntnet_relay))
data["relays"] += list(list("id" = relays.uid))
data["focus"] = target ? target.uid : null
@@ -6,7 +6,7 @@
program_icon_state = "generic"
extended_desc = "This program allows for remote monitoring of station cyborgs."
requires_ntnet = TRUE
transfer_access = list(ACCESS_ROBOTICS)
download_access = list(ACCESS_ROBOTICS)
size = 5
tgui_id = "NtosCyborgRemoteMonitor"
program_icon = "project-diagram"
@@ -155,7 +155,7 @@
requires_ntnet = FALSE
available_on_ntnet = FALSE
available_on_syndinet = TRUE
transfer_access = list()
download_access = list()
/datum/computer_file/program/borg_monitor/syndicate/evaluate_borg(mob/living/silicon/robot/R)
if(!is_valid_z_level(get_turf(computer), get_turf(R)))
@@ -4,7 +4,7 @@
category = PROGRAM_CATEGORY_CREW
program_icon_state = "id"
extended_desc = "Program for programming employee ID cards to access parts of the station."
transfer_access = list(ACCESS_COMMAND)
download_access = list(ACCESS_COMMAND)
requires_ntnet = 0
size = 8
tgui_id = "NtosCard"
@@ -4,7 +4,7 @@
category = PROGRAM_CATEGORY_CREW
program_icon_state = "id"
extended_desc = "Program for viewing and printing the current crew manifest"
transfer_access = list(ACCESS_SECURITY, ACCESS_COMMAND)
download_access = list(ACCESS_SECURITY, ACCESS_COMMAND)
requires_ntnet = TRUE
size = 4
tgui_id = "NtosCrewManifest"
@@ -8,7 +8,7 @@
program_icon_state = "research"
tgui_id = "NtosScipaper"
program_icon = "paper-plane"
transfer_access = list(ACCESS_ORDNANCE)
download_access = list(ACCESS_ORDNANCE)
var/datum/techweb/linked_techweb
/// Unpublished, temporary paper datum.
@@ -7,7 +7,7 @@ GLOBAL_VAR_INIT(time_last_changed_position, 0)
category = PROGRAM_CATEGORY_CREW
program_icon_state = "id"
extended_desc = "Program for viewing and changing job slot availability."
transfer_access = list(ACCESS_COMMAND)
download_access = list(ACCESS_COMMAND)
requires_ntnet = TRUE
size = 4
tgui_id = "NtosJobManager"
@@ -1,7 +1,7 @@
/datum/computer_file/program/newscaster
filename = "newscasterapp"
filedesc = "Newscaster"
transfer_access = list(ACCESS_LIBRARY)
download_access = list(ACCESS_LIBRARY)
category = PROGRAM_CATEGORY_CREW
program_icon_state = "bountyboard"
extended_desc = "This program allows any user to access the Newscaster network from anywhere."
@@ -143,7 +143,7 @@
"installed" = !!computer.find_file_by_name(programs.filename),
"compatible" = check_compatibility(programs),
"size" = programs.size,
"access" = programs.can_run(user, transfer = TRUE, access = access),
"access" = programs.can_run(user, downloading = TRUE, access = access),
"verifiedsource" = programs.available_on_ntnet,
))
@@ -15,7 +15,7 @@
category = PROGRAM_CATEGORY_CREW
program_icon_state = "dummy"
extended_desc = "This program connects to a Spinward Sector community art site for viewing and printing art."
transfer_access = list(ACCESS_LIBRARY)
download_access = list(ACCESS_LIBRARY)
usage_flags = PROGRAM_CONSOLE
requires_ntnet = TRUE
size = 9
@@ -7,7 +7,7 @@
program_icon_state = "power_monitor"
extended_desc = "This program connects to sensors around the station to provide information about electrical systems"
ui_header = "power_norm.gif"
transfer_access = list(ACCESS_ENGINEERING)
download_access = list(ACCESS_ENGINEERING)
usage_flags = PROGRAM_CONSOLE
requires_ntnet = FALSE
size = 8
@@ -220,7 +220,7 @@
filedesc = "Lifeline"
extended_desc = "This program allows for tracking of crew members via their suit sensors."
requires_ntnet = TRUE
transfer_access = list(ACCESS_MEDICAL)
download_access = list(ACCESS_MEDICAL)
available_on_ntnet = TRUE
program_icon = "heartbeat"
@@ -260,7 +260,7 @@
filedesc = "Custodial Locator"
extended_desc = "This program allows for tracking of custodial equipment."
requires_ntnet = TRUE
transfer_access = list(ACCESS_JANITOR)
download_access = list(ACCESS_JANITOR)
available_on_ntnet = TRUE
program_icon = "broom"
size = 2
@@ -18,7 +18,7 @@
filename = "medrecords"
program_icon = "book-medical"
extended_desc = "Allows the user to view several basic medical records from the crew."
transfer_access = list(ACCESS_MEDICAL, ACCESS_FLAG_COMMAND)
download_access = list(ACCESS_MEDICAL, ACCESS_FLAG_COMMAND)
available_on_ntnet = TRUE
mode = "medical"
@@ -26,7 +26,7 @@
filedesc = "Security Records"
filename = "secrecords"
extended_desc = "Allows the user to view several basic security records from the crew."
transfer_access = list(ACCESS_SECURITY, ACCESS_FLAG_COMMAND)
download_access = list(ACCESS_SECURITY, ACCESS_FLAG_COMMAND)
available_on_ntnet = TRUE
mode = "security"
@@ -8,7 +8,7 @@
program_icon_state = "generic"
extended_desc = "This program allows access to standard security camera networks."
requires_ntnet = TRUE
transfer_access = list(ACCESS_SECURITY)
download_access = list(ACCESS_SECURITY)
usage_flags = PROGRAM_CONSOLE | PROGRAM_LAPTOP
size = 5
tgui_id = "NtosSecurEye"
@@ -39,7 +39,7 @@
filename = "syndeye"
filedesc = "SyndEye"
extended_desc = "This program allows for illegal access to security camera networks."
transfer_access = list()
download_access = list()
available_on_ntnet = FALSE
available_on_syndinet = TRUE
requires_ntnet = FALSE
@@ -6,7 +6,7 @@
program_icon_state = "smmon_0"
extended_desc = "Crystal Integrity Monitoring System, connects to specially calibrated supermatter sensors to provide information on the status of supermatter-based engines."
requires_ntnet = TRUE
transfer_access = list(ACCESS_CONSTRUCTION)
download_access = list(ACCESS_CONSTRUCTION)
size = 5
tgui_id = "NtosSupermatter"
program_icon = "radiation"
@@ -8,8 +8,8 @@
size = 10
tgui_id = "NtosTechweb"
program_icon = "atom"
required_access = list(ACCESS_COMMAND, ACCESS_RESEARCH)
transfer_access = list(ACCESS_RESEARCH)
run_access = list(ACCESS_COMMAND, ACCESS_RESEARCH)
download_access = list(ACCESS_RESEARCH)
/// Reference to global science techweb
var/datum/techweb/stored_research
/// Access needed to lock/unlock the console
@@ -6,7 +6,7 @@
extended_desc = "This program monitors stationwide NTNet network, provides access to logging systems, and allows for configuration changes"
size = 12
requires_ntnet = TRUE
required_access = list(ACCESS_NETWORK) //NETWORK CONTROL IS A MORE SECURE PROGRAM.
run_access = list(ACCESS_NETWORK) //NETWORK CONTROL IS A MORE SECURE PROGRAM.
available_on_ntnet = TRUE
tgui_id = "NtosNetMonitor"
program_icon = "network-wired"
@@ -20,7 +20,7 @@
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 GLOB.ntnet_relays
var/obj/machinery/ntnet_relay/target_relay = locate(params["ref"]) in SSmachines.get_machines_by_type(/obj/machinery/ntnet_relay)
if(!istype(target_relay))
return
target_relay.set_relay_enabled(!target_relay.relay_enabled)
@@ -39,7 +39,7 @@
var/list/data = list()
data["ntnetrelays"] = list()
for(var/obj/machinery/ntnet_relay/relays as anything in GLOB.ntnet_relays)
for(var/obj/machinery/ntnet_relay/relays as anything in SSmachines.get_machines_by_type(/obj/machinery/ntnet_relay))
var/list/relay_data = list()
relay_data["is_operational"] = !!relays.is_operational
relay_data["name"] = relays.name