Skip to content

Commit af4c29a

Browse files
Merge pull request #1053 from NataKilar/network-fixes
Fixes network bugs and adjusts program access
2 parents 0b23850 + d35d90d commit af4c29a

29 files changed

+241
-122
lines changed

code/game/machinery/_machines_base/stock_parts/network_lock.dm

+3-3
Original file line numberDiff line numberDiff line change
@@ -83,15 +83,15 @@
8383
return
8484
data["connected"] = TRUE
8585
data["default_state"] = auto_deny_all
86-
var/list/grants = list()
86+
var/list/grants_data = list()
8787
if(!network.access_controller)
8888
return
8989
for(var/datum/computer_file/data/grant_record/GR in network.access_controller.get_all_grants())
90-
grants.Add(list(list(
90+
grants_data.Add(list(list(
9191
"grant_name" = GR.stored_data,
9292
"assigned" = (GR.stored_data in grants)
9393
)))
94-
data["grants"] = grants
94+
data["grants"] = grants_data
9595

9696
/obj/item/stock_parts/network_lock/OnTopic(mob/user, href_list, datum/topic_state/state)
9797
. = ..()

code/game/objects/items/weapons/cards_ids.dm

+5
Original file line numberDiff line numberDiff line change
@@ -462,6 +462,11 @@ var/const/NO_EMAG_ACT = -50
462462
to_chat(usr, SPAN_WARNING("Pressing the synchronization button on the card causes a red LED to flash three times."))
463463

464464
/obj/item/card/id/network/proc/refresh_access_record(var/datum/computer_network/network)
465+
if(!network)
466+
var/datum/extension/network_device/D = get_extension(src, /datum/extension/network_device)
467+
network = D.get_network()
468+
if(!network)
469+
return
465470
for(var/datum/extension/network_device/mainframe/mainframe in network.get_mainframes_by_role(MF_ROLE_CREW_RECORDS))
466471
for(var/datum/computer_file/report/crew_record/ar in mainframe.get_all_files())
467472
if(ar.user_id != user_id)

code/modules/merchant/merchant_programs.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
nanomodule_path = /datum/nano_module/program/merchant
88
size = 12
99
usage_flags = PROGRAM_CONSOLE
10-
required_access = access_merchant
10+
required_access = list(access_merchant)
1111
var/obj/machinery/merchant_pad/pad = null
1212
var/current_merchant = 0
1313
var/show_trades = 0

code/modules/modular_computers/file_system/program.dm

+25-17
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/datum/computer_file/program
33
filetype = "PRG"
44
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NETWORK!
5-
var/required_access = null // List of required accesses to run/download the program.
5+
var/list/required_access = list() // List of required accesses to run/download the program.
66
var/requires_access_to_run = 1 // Whether the program checks for required_access when run.
77
var/requires_access_to_download = 1 // Whether the program checks for required_access when downloading.
88
var/datum/nano_module/NM = null // If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
@@ -83,32 +83,40 @@
8383
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
8484
// User has to wear their ID or have it inhand for ID Scan to work.
8585
// Can also be called manually, with optional parameter being access_to_check to scan the user's ID
86-
/datum/computer_file/program/proc/can_run(var/mob/living/user, var/loud = 0, var/access_to_check)
86+
/datum/computer_file/program/proc/can_run(var/mob/living/user, var/loud = 0, var/list/accesses_to_check, var/datum/computer_network/network)
8787
if(!requires_access_to_run)
88-
return 1
89-
// Defaults to required_access
90-
if(!access_to_check)
91-
access_to_check = required_access
92-
if(!access_to_check) // No required_access, allow it.
93-
return 1
88+
return TRUE
89+
// Checks to see if network access is enabled, and then defaults to required_access if not.
90+
if(!accesses_to_check)
91+
if(network)
92+
var/datum/extension/network_device/acl/access_controller = network.access_controller
93+
if(access_controller && access_controller.program_control)
94+
accesses_to_check = access_controller.get_program_access(filename)
95+
96+
if(!length(accesses_to_check))
97+
accesses_to_check = required_access
98+
99+
if(!length(accesses_to_check)) // No required_access, allow it.
100+
return TRUE
94101

95102
// Admin override - allows operation of any computer as aghosted admin, as if you had any required access.
96103
if(isghost(user) && check_rights(R_ADMIN, 0, user))
97-
return 1
104+
return TRUE
98105

99106
if(!istype(user))
100-
return 0
107+
return FALSE
101108

102109
var/obj/item/card/id/I = user.GetIdCard()
103110
if(!I)
104111
if(loud)
105-
to_chat(user, "<span class='notice'>\The [computer] flashes an \"RFID Error - Unable to scan ID\" warning.</span>")
106-
return 0
107-
108-
if(access_to_check in I.access)
109-
return 1
110-
else if(loud)
111-
to_chat(user, "<span class='notice'>\The [computer] flashes an \"Access Denied\" warning.</span>")
112+
to_chat(user, SPAN_WARNING("The OS flashes an \"RFID Error - Unable to scan ID\" warning."))
113+
return FALSE
114+
115+
if(has_access(accesses_to_check, I.access))
116+
return TRUE
117+
if(loud)
118+
to_chat(user, SPAN_WARNING("The OS flashes an \"Access Denied\" warning."))
119+
return FALSE
112120

113121
// This attempts to retrieve header data for NanoUIs. If implementing completely new device of different type than existing ones
114122
// always include the device here in this proc. This proc basically relays the request to whatever is running the program.

code/modules/modular_computers/file_system/programs/command/comm.dm

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
program_menu_icon = "flag"
1212
nanomodule_path = /datum/nano_module/program/comm
1313
extended_desc = "Used to command and control. Can relay long-range communications. This program can not be run on tablet computers."
14-
required_access = access_bridge
14+
required_access = list(access_bridge)
1515
requires_network = 1
1616
size = 12
1717
usage_flags = PROGRAM_CONSOLE | PROGRAM_LAPTOP
@@ -109,7 +109,7 @@
109109

110110
/datum/nano_module/program/comm/proc/is_autenthicated(var/mob/user)
111111
if(program)
112-
return program.can_run(user)
112+
return program.can_run(user, program.computer.get_network())
113113
return 1
114114

115115
/datum/nano_module/program/comm/proc/obtain_message_listener()

code/modules/modular_computers/file_system/programs/engineering/atmos_control.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
program_key_state = "atmos_key"
77
program_menu_icon = "shuffle"
88
extended_desc = "This program allows remote control of air alarms. This program can not be run on tablet computers."
9-
required_access = access_atmospherics
9+
required_access = list(access_atmospherics)
1010
requires_network = 1
1111
network_destination = "atmospheric control system"
1212
requires_network_feature = NETWORK_SYSTEMCONTROL

code/modules/modular_computers/file_system/programs/engineering/power_monitor.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
program_menu_icon = "battery-3"
88
extended_desc = "This program connects to sensors to provide information about electrical systems"
99
ui_header = "power_norm.gif"
10-
required_access = access_engine
10+
required_access = list(access_engine)
1111
requires_network = 1
1212
network_destination = "power monitoring system"
1313
size = 9

code/modules/modular_computers/file_system/programs/engineering/rcon_console.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
program_key_state = "rd_key"
77
program_menu_icon = "power"
88
extended_desc = "This program allows remote control of power distribution systems. This program can not be run on tablet computers."
9-
required_access = access_engine
9+
required_access = list(access_engine)
1010
network_destination = "RCON remote control system"
1111
requires_network_feature = NETWORK_SYSTEMCONTROL
1212
usage_flags = PROGRAM_LAPTOP | PROGRAM_CONSOLE

code/modules/modular_computers/file_system/programs/engineering/supermatter_monitor.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
program_menu_icon = "notice"
1212
extended_desc = "This program connects to specially calibrated supermatter sensors to provide information on the status of supermatter-based engines."
1313
ui_header = "smmon_0.gif"
14-
required_access = access_engine
14+
required_access = list(access_engine)
1515
network_destination = "supermatter monitoring system"
1616
size = 5
1717
category = PROG_ENG

code/modules/modular_computers/file_system/programs/generic/deck_management.dm

+1-10
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77
filename = "deckmngr"
88
filedesc = "Deck Management"
99
nanomodule_path = /datum/nano_module/deck_management
10+
required_access = list(list(access_cargo, access_bridge))
1011
program_icon_state = "request"
1112
program_key_state = "rd_key"
1213
program_menu_icon = "clock"
@@ -25,8 +26,6 @@
2526
var/datum/computer_file/report/selected_report //A report being viewed/edited.
2627
var/list/report_prototypes = list() //Stores report prototypes to use for UI purposes.
2728
var/datum/shuttle/prototype_shuttle //The shuttle for which the prototypes were built (to avoid excessive prototype rebuilding)
28-
//The default access needed to properly use. Should be set in map files.
29-
var/default_access = list(access_cargo, access_bridge) //The format is (needs one of list(these access constants or lists of access constants))
3029

3130
/datum/nano_module/deck_management/New()
3231
..()
@@ -45,7 +44,6 @@
4544
var/logs = SSshuttle.shuttle_logs
4645

4746
data["prog_state"] = prog_state
48-
data["default_access"] = get_default_access(user)
4947

5048
switch(prog_state)
5149
if(DECK_HOME)
@@ -171,11 +169,6 @@
171169
mission_data["queued"] = 1
172170
return mission_data
173171

174-
/datum/nano_module/deck_management/proc/get_default_access(mob/user)
175-
for(var/access_pattern in default_access)
176-
if(check_access(user, access_pattern))
177-
return 1
178-
179172
/datum/nano_module/deck_management/proc/get_shuttle_access(mob/user, datum/shuttle/shuttle)
180173
return shuttle.logging_access ? (check_access(user, shuttle.logging_access) || check_access(user, access_bridge)) : 0
181174

@@ -211,8 +204,6 @@
211204
if(..())
212205
return 1
213206

214-
if(!get_default_access(user))
215-
return 1 //No program access if you don't have the right access.
216207
if(text2num(href_list["warning"])) //Gives the user a chance to avoid losing unsaved reports.
217208
if(alert(user, "Are you sure you want to do this? Data may be lost.",, "Yes.", "No.") == "No.")
218209
return 1 //If yes, proceed to the actual action instead.

code/modules/modular_computers/file_system/programs/generic/docks.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/datum/computer_file/program/docking
22
filename = "docking"
33
filedesc = "Docking Control"
4-
required_access = access_bridge
4+
required_access = list(access_bridge)
55
nanomodule_path = /datum/nano_module/program/docking
66
program_icon_state = "supply"
77
program_key_state = "rd_key"

code/modules/modular_computers/file_system/programs/generic/file_browser.dm

+14-12
Original file line numberDiff line numberDiff line change
@@ -60,10 +60,11 @@
6060
if(!network)
6161
return TOPIC_REFRESH
6262
// Helper for some user-friendliness. Try to select the first available mainframe.
63-
var/list/file_servers = network.get_file_server_tags()
63+
var/list/file_servers = network.get_file_server_tags(MF_ROLE_FILESERVER, user)
64+
var/datum/file_storage/network/N = current_filesource
6465
if(!file_servers.len)
66+
N.server = null // Don't allow players to see files on mainframes they cannot access.
6567
return TOPIC_REFRESH
66-
var/datum/file_storage/network/N = current_filesource
6768
N.server = file_servers[1]
6869
return TOPIC_REFRESH
6970

@@ -163,26 +164,26 @@
163164
ui_header = null
164165
return TOPIC_REFRESH
165166

166-
if(href_list["PRG_copyto"])
167+
if(href_list["PRG_transferto"])
167168
. = TOPIC_REFRESH
168-
var/datum/computer_file/F = current_filesource.get_file(href_list["PRG_copyto"])
169-
if(!F || !istype(F))
170-
error = "I/O ERROR: Unable to open file."
169+
var/datum/computer_file/F = current_filesource.get_file(href_list["PRG_transferto"])
170+
if(!F || !istype(F) || F.unsendable)
171+
error = "I/O ERROR: Unable to transfer file."
171172
return
172173
var/list/choices = list()
173174
for(var/T in file_sources)
174175
var/datum/file_storage/FS = file_sources[T]
175176
if(FS == current_filesource)
176177
continue
177178
choices[FS.name] = FS
178-
var/file_source = input(usr, "Choose a destination storage medium:", "Copy To Another Medium") as null|anything in choices
179+
var/file_source = input(usr, "Choose a destination storage medium:", "Transfer To Another Medium") as null|anything in choices
179180
if(file_source)
180181
var/datum/file_storage/dst = choices[file_source]
181182
var/nope = dst.check_errors()
182183
if(nope)
183-
to_chat(user, SPAN_WARNING("Cannot copy file to [dst] for following reason: [nope]"))
184+
to_chat(user, SPAN_WARNING("Cannot transfer file to [dst] for following reason: [nope]"))
184185
return
185-
current_transfer = new(current_filesource, dst, F)
186+
current_transfer = new(current_filesource, dst, F, FALSE)
186187
ui_header = "downloader_running.gif"
187188

188189
/datum/computer_file/program/filemanager/ui_interact(mob/user, ui_key = "main", var/datum/nanoui/ui = null, var/force_open = 1, var/datum/topic_state/state = GLOB.default_state)
@@ -215,7 +216,8 @@
215216
"name" = F.filename,
216217
"type" = F.filetype,
217218
"size" = F.size,
218-
"undeletable" = F.undeletable
219+
"undeletable" = F.undeletable,
220+
"unsendable" = F.unsendable
219221
)))
220222
data["files"] = files
221223

@@ -239,12 +241,12 @@
239241
if(QDELETED(current_transfer)) //either completely
240242
error = "I/O ERROR: Unknown error during the file transfer."
241243
else //or during the saving at the destination
242-
error = "I/O ERROR: Unable to store '[current_transfer.copying.filename]' at [current_transfer.copying_to]"
244+
error = "I/O ERROR: Unable to store '[current_transfer.transferring.filename]' at [current_transfer.transfer_to]"
243245
qdel(current_transfer)
244246
current_transfer = null
245247
ui_header = null
246248
return
247-
else if(!current_transfer.left_to_copy) //done
249+
else if(!current_transfer.left_to_transfer) //done
248250
QDEL_NULL(current_transfer)
249251
ui_header = null
250252

code/modules/modular_computers/file_system/programs/generic/ntdownloader.dm

+5-5
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@
4242
source.server = net.find_file_location(filename, MF_ROLE_SOFTWARE)
4343
if(source.check_errors() || destination.check_errors())
4444
return 0
45-
current_transfer = new(source, destination, PRG)
45+
current_transfer = new(source, destination, PRG, TRUE)
4646

4747
ui_header = "downloader_running.gif"
4848
generate_network_log("Downloading file [filename] from [source.server].")
@@ -77,11 +77,11 @@
7777
if(QDELETED(current_transfer)) //either completely
7878
downloaderror = "I/O ERROR: Unknown error during the file transfer."
7979
else //or during the saving at the destination
80-
downloaderror = "I/O ERROR: Unable to store '[current_transfer.copying.filename]' at [current_transfer.copying_to]"
80+
downloaderror = "I/O ERROR: Unable to store '[current_transfer.transferring.filename]' at [current_transfer.transfer_to]"
8181
qdel(current_transfer)
8282
current_transfer = null
8383
ui_header = "downloader_finished.gif"
84-
else if(!current_transfer.left_to_copy) //done
84+
else if(!current_transfer.left_to_transfer) //done
8585
QDEL_NULL(current_transfer)
8686
ui_header = "downloader_finished.gif"
8787
if(!current_transfer && downloads_queue.len > 0)
@@ -94,7 +94,7 @@
9494
if(href_list["PRG_downloadfile"])
9595
if(!current_transfer)
9696
begin_file_download(href_list["PRG_downloadfile"])
97-
else if(check_file_download(href_list["PRG_downloadfile"]) && !downloads_queue.Find(href_list["PRG_downloadfile"]) && current_transfer.copying.filename != href_list["PRG_downloadfile"])
97+
else if(check_file_download(href_list["PRG_downloadfile"]) && !downloads_queue.Find(href_list["PRG_downloadfile"]) && current_transfer.transferring.filename != href_list["PRG_downloadfile"])
9898
downloads_queue |= href_list["PRG_downloadfile"]
9999
return 1
100100
if(href_list["PRG_removequeued"])
@@ -123,7 +123,7 @@
123123
if(prog.current_transfer) // Download running. Wait please..
124124
data |= prog.current_transfer.get_ui_data()
125125
data["downloadspeed"] = prog.current_transfer.get_transfer_speed()
126-
var/datum/computer_file/program/P = prog.current_transfer.copying
126+
var/datum/computer_file/program/P = prog.current_transfer.transferring
127127
if(istype(P))
128128
data["transfer_desc"] = P.extended_desc
129129

code/modules/modular_computers/file_system/programs/generic/ntnrc_client.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,7 @@
8787
channel = null
8888
return 1
8989
var/mob/living/user = usr
90-
if(can_run(usr, 1, access_network))
90+
if(can_run(usr, 1, list(access_network)))
9191
if(channel)
9292
var/response = alert(user, "Really engage admin-mode? You will be disconnected from your current channel!", "NTNRC Admin mode", "Yes", "No")
9393
if(response == "Yes")

code/modules/modular_computers/file_system/programs/medical/suit_sensors.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
program_key_state = "med_key"
88
program_menu_icon = "heart"
99
extended_desc = "This program connects to life signs monitoring system to provide basic information on crew health."
10-
required_access = access_medical
10+
required_access = list(access_medical)
1111
network_destination = "crew lifesigns monitoring system"
1212
size = 11
1313
category = PROG_MONITOR

code/modules/modular_computers/file_system/programs/research/ai_restorer.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
program_menu_icon = "person"
77
extended_desc = "This program is capable of reconstructing damaged AI systems. It can also be used to upload basic laws to the AI. Requires direct AI connection via inteliCard slot."
88
size = 12
9-
required_access = access_bridge
9+
required_access = list(access_bridge)
1010
requires_access_to_run = 0
1111
available_on_network = 1
1212
nanomodule_path = /datum/nano_module/program/computer_aidiag/

code/modules/modular_computers/file_system/programs/research/email_administration.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
requires_network = 1
1010
available_on_network = 1
1111
nanomodule_path = /datum/nano_module/program/email_administration
12-
required_access = access_network
12+
required_access = list(access_network)
1313
category = PROG_ADMIN
1414

1515
/datum/nano_module/program/email_administration

code/modules/modular_computers/file_system/programs/security/digitalwarrant.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ GLOBAL_LIST(all_warrants)
1010
program_menu_icon = "star"
1111
requires_network = 1
1212
available_on_network = 1
13-
required_access = access_security
13+
required_access = list(access_security)
1414
nanomodule_path = /datum/nano_module/program/digitalwarrant/
1515
category = PROG_SEC
1616

code/modules/modular_computers/file_system/programs/security/forceauthorization.dm

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
program_menu_icon = "locked"
99
requires_network = 1
1010
available_on_network = 1
11-
required_access = access_armory
11+
required_access = list(access_armory)
1212
nanomodule_path = /datum/nano_module/program/forceauthorization/
1313
category = PROG_SEC
1414

code/modules/modular_computers/file_system/reports/crew_record.dm

+2-2
Original file line numberDiff line numberDiff line change
@@ -32,10 +32,10 @@ GLOBAL_VAR_INIT(arrest_security_status, "Arrest")
3232
for(var/weakref/grant in grants)
3333
var/datum/computer_file/data/grant_record/GR = grant.resolve()
3434
if(!GR)
35-
grants -= GR
35+
grants -= grant
3636
continue
3737
if(GR.stored_data == grant_name)
38-
grants -= GR
38+
grants -= grant
3939
return
4040

4141
/datum/computer_file/report/crew_record/proc/calculate_size()

0 commit comments

Comments
 (0)