mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-23 04:51:32 +01:00
First implementation of NTNet Software Downloads, Fixes
- As usual, fixes various issues through the code, but likely creates more as this is still WIP project. - Most importantly, NTNet software downloader program now exists and more or less works. - Your device's connectivity has effect on how quickly you can download. Right now, things with wired connection (consoles) download at 0,5GQ/s, mobile devices on station where signal is good at 0,1GQ/s and mobile devices off station where signal is bad are limited to 0,025GQ/s. This is all controlled by three defines.
This commit is contained in:
@@ -1,23 +1,27 @@
|
||||
// /program/ files are executable programs that do things.
|
||||
/datum/computer_file/program
|
||||
filetype = "PRG"
|
||||
filename = "UnknownProgram" // File name.
|
||||
filename = "UnknownProgram" // File name. FILE NAME MUST BE UNIQUE IF YOU WANT THE PROGRAM TO BE DOWNLOADABLE FROM NTNET!
|
||||
var/required_access = null // List of required accesses to *run* the program.
|
||||
var/datum/nano_module/NM = null // If the program uses NanoModule, put it here and it will be automagically opened. Otherwise implement ui_interact.
|
||||
var/nanomodule_path = null // Path to nanomodule, make sure to set this if implementing new program.
|
||||
var/running = 0 // Set to 1 when the program is run and back to 0 when it's stopped.
|
||||
var/atom/movable/computer = null // Device that runs this program.
|
||||
var/obj/item/modular_computer/computer // Device that runs this program.
|
||||
var/filedesc = "Unknown Program" // User-friendly name of this program.
|
||||
var/program_icon_state = null // Overlay for this program, selected by computer
|
||||
var/keyboard_icon_state = null // Program-specific keboard icon state
|
||||
var/program_icon_state = null // Program-specific screen icon state
|
||||
var/keyboard_icon_state = null // Program-specific keboard icon state, only supported on some devices.
|
||||
var/requires_ntnet = 0 // Set to 1 for program to require nonstop NTNet connection to run. If NTNet connection is lost program crashes.
|
||||
var/requires_ntnet_feature = 0 // Optional, if above is set to 1 checks for specific function of NTNet (currently NTNET_SOFTWAREDOWNLOAD, NTNET_PEERTOPEER, NTNET_SYSTEMCONTROL and NTNET_COMMUNICATION)
|
||||
var/ntnet_status = 1 // NTNet status, updated every tick by computer running this program. Don't use this for checks if NTNet works, computers do that. Use this for calculations, etc.
|
||||
var/usage_flags = PROGRAM_ALL // Bitflags (PROGRAM_CONSOLE, PROGRAM_LAPTOP, PROGRAM_TABLET combination) or PROGRAM_ALL
|
||||
var/network_destination = null // Optional string that describes what NTNet server/system this program connects to. Used in default logging.
|
||||
var/available_on_ntnet = 1 // Whether the program can be downloaded from NTNet. Set to 0 to disable.
|
||||
var/available_on_syndinet = 0 // Whether the program can be downloaded from SyndiNet (accessible via emagging the computer). Set to 1 to enable.
|
||||
var/computer_emagged = 0 // Set to 1 if computer that's running us was emagged. Computer updates this every Process() tick
|
||||
|
||||
/datum/computer_file/program/New(var/atom/movable/comp = null)
|
||||
/datum/computer_file/program/New(var/obj/item/modular_computer/comp = null)
|
||||
..()
|
||||
if(comp)
|
||||
if(comp && istype(comp))
|
||||
computer = comp
|
||||
|
||||
/datum/computer_file/program/clone()
|
||||
@@ -31,6 +35,12 @@
|
||||
temp.usage_flags = usage_flags
|
||||
return temp
|
||||
|
||||
// Attempts to create a log in global ntnet datum. Returns 1 on success, 0 on fail.
|
||||
/datum/computer_file/program/proc/generate_network_log(var/text)
|
||||
if(computer)
|
||||
return computer.add_log(text)
|
||||
return 0
|
||||
|
||||
/datum/computer_file/program/proc/is_supported_by_hardware(var/hardware_flag = 0, var/loud = 0, var/mob/user = null)
|
||||
if(!(hardware_flag & usage_flags))
|
||||
if(loud && computer && user)
|
||||
@@ -38,11 +48,17 @@
|
||||
return 0
|
||||
return 1
|
||||
|
||||
// Called by Process() on device that runs us, once every tick.
|
||||
/datum/computer_file/program/proc/process_tick()
|
||||
return 1
|
||||
|
||||
// Check if the user can run program. Only humans can operate computer. Automatically called in run_program()
|
||||
// User has to wear their ID or have it inhand for ID Scan to work.
|
||||
/datum/computer_file/program/proc/can_run(var/mob/living/user, var/loud = 0)
|
||||
if(!required_access) // No required_access, allow it.
|
||||
return 1
|
||||
if(istype(user, /mob/living/silicon)) // AI or robot. Allow it.
|
||||
return 1
|
||||
if(istype(user, /mob/living/carbon/human))
|
||||
var/mob/living/carbon/human/H = user
|
||||
var/obj/item/weapon/card/id/I = H.wear_id
|
||||
@@ -68,21 +84,20 @@
|
||||
// This attempts to retrieve header data for NanoUIs. If implementing completely new device of different type than existing ones
|
||||
// always include the device here in this proc. This proc basically relays the request to whatever is running the program.
|
||||
/datum/computer_file/program/proc/get_header_data()
|
||||
if(istype(computer, /obj/machinery/modular_computer))
|
||||
var/obj/machinery/modular_computer/L = computer
|
||||
return L.get_header_data()
|
||||
if(istype(computer, /obj/item/modular_computer))
|
||||
var/obj/item/modular_computer/L = computer
|
||||
return L.get_header_data()
|
||||
if(computer)
|
||||
return computer.get_header_data()
|
||||
return list()
|
||||
|
||||
// This is performed on program startup. May be overriden to add extra logic. Remember to include ..() call. Return 1 on success, 0 on failure.
|
||||
// When implementing new program based device, use this to run the program.
|
||||
/datum/computer_file/program/proc/run_program(var/mob/living/user)
|
||||
|
||||
if(can_run(user, 1))
|
||||
if(nanomodule_path)
|
||||
NM = new nanomodule_path(computer) // Computer is passed here as it's (probably!) physical object. Some UI's perform get_turf() and passing program datum wouldn't go well with this.
|
||||
NM.program = src // Set the program reference to separate variable, instead.
|
||||
if(requires_ntnet && network_destination)
|
||||
generate_network_log("Connection opened to [network_destination].")
|
||||
running = 1
|
||||
return 1
|
||||
return 0
|
||||
@@ -90,8 +105,11 @@
|
||||
// Use this proc to kill the program. Designed to be implemented by each program if it requires on-quit logic, such as the NTNRC client.
|
||||
/datum/computer_file/program/proc/kill_program(var/forced = 0)
|
||||
running = 0
|
||||
qdel(NM)
|
||||
NM = null
|
||||
if(network_destination)
|
||||
generate_network_log("Connection to [network_destination] closed.")
|
||||
if(NM)
|
||||
qdel(NM)
|
||||
NM = null
|
||||
return 1
|
||||
|
||||
// This is called every tick when the program is enabled. Ensure you do parent call if you override it. If parent returns 1 continue with UI initialisation.
|
||||
@@ -113,7 +131,6 @@
|
||||
// Calls beginning with "PC_" are reserved for computer handling (by whatever runs the program)
|
||||
// ALWAYS INCLUDE PARENT CALL ..() OR DIE IN FIRE.
|
||||
/datum/computer_file/program/Topic(href, href_list)
|
||||
|
||||
if(computer)
|
||||
computer.Topic(href, href_list)
|
||||
..()
|
||||
|
||||
Reference in New Issue
Block a user