9e1ef0ffe2
* Add the system for managed global variables * Travis ban old globals * So you CAN inline proccall, that's neat * Fix that * master.dm * Remove the hack procs * Move InitGlobals to the proper spot * configuration.dm * Fix the missing pre-slash * clockcult.dm * This is probably for the best * Doy * Fix shit * Rest of the DEFINES tree * Fix * Use global. for access * Update find_references_in_globals Always hated that proc Whoever made it must've bee a r e a l idiot... * __HELPERS tree * Move global initialization to master. Fix the declaration * database.dm * Dat newline * I said DECLARATIVE order! * Here's something you can chew on @Iamgoofball * game_modes.dm * Fix this * genetics.dm * flavor_misc.dm * More stuff * Do it mso's way. Keep the controllers as global * Make master actually see it * Fix * Finish _globalvars/lists * Finish the rest of the _globalvars tree * This is weird * Migrate the controllers * SLOTH -> GLOB * Lighting globals * round_start_time -> ticker * PAI card list -> pai SS * record_id_num -> static * Diseases list -> SSdisease * More disease globals to the SS * More disease stuff * Emote list * Better and better * Bluh * So much stuff * Ahh * Wires * dview * station_areas * Teleportlocs * blood_splatter_icons * Stuff and such * More stuff * RAD IO * More stuff and such * Blob shit * Changeling stuff * Add "Balance" to changelogs * Balance for changelog compiler + Auto Tagging * Update the PR template * hivemind_bank * Bip * sacrificed * Good shit * Better define * More cult shit * Devil shit * Gang shit * > borers Fix shit * Rename the define * Nuke * Objectives * Sandbox * Multiverse sword * Announce systems * Stuff and such * TC con * Airlock * doppllllerrrrrr * holopads * Shut up byond you inconsistent fuck * Sneaky fuck * Burp * Bip * Fixnshit * Port without regard * askdlfjs; * asdfjasoidojfi * Protected globals and more * SO MANY * ajsimkvahsaoisd * akfdsiaopwimfeoiwafaw * gsdfigjosidjfgiosdg * AHHHHHHHHHHHHHHHHHHHHHHH!!!!! * facerolll * ASDFASDFASDF * Removes the unused parts of dmm_suite * WIP * Fix quote * asdfjauwfnkjs * afwlunhskjfda * asfjlaiwuefhaf * SO CLOSE * wwwweeeeeewwwww * agdgmoewranwg * HOLY MOTHER OF FUCK AND THATS JUST HALF THE JOB?!? * Fix syntax errors * 100 errors * Another 100 * So many... * Ugh * More shit * kilme * Stuuuuuufffff * ajrgmrlshio;djfa;sdkl * jkbhkhjbmjvjmh * soi soi soi * butt * TODAY WE LEARNED THAT GLOBAL AND STATIC ARE THE EXACT SAME FUCKING THING * lllllllllllllllllllllllllllllllllllllllllll * afsdijfiawhnflnjhnwsdfs * yugykihlugk,kj * time to go * STUFFF!!! * AAAAAAAAAAAAAAAAAHHHHHHHHHHHHHHHHHHHHHHHHHHH!!!!!!!!!!!!!!!!!!!!!!! * ngoaijdjlfkamsdlkf * Break time * aufjsdklfalsjfi * CONTROL KAY AND PRAY * IT COMPILEELEELELAKLJFKLDAFJLKFDJLADKJHFLJKAJGAHIEJALDFJ!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! * Goteem * Fix testing mode * This does not belong in this PR * Convert it to a controller * Eh, fuck this option * Revert controllerization Ill do it some other time * Fix * Working controllerization * FOR THE LOVE OF CHRIST PROTECT THE LOGS * Protect admins and deadmins * Use the inbuilt proc
178 lines
6.4 KiB
Plaintext
178 lines
6.4 KiB
Plaintext
/datum/computer_file/program/ntnetdownload
|
|
filename = "ntndownloader"
|
|
filedesc = "NTNet Software Download Tool"
|
|
program_icon_state = "generic"
|
|
extended_desc = "This program allows downloads of software from official NT repositories"
|
|
unsendable = 1
|
|
undeletable = 1
|
|
size = 4
|
|
requires_ntnet = 1
|
|
requires_ntnet_feature = NTNET_SOFTWAREDOWNLOAD
|
|
available_on_ntnet = 0
|
|
ui_header = "downloader_finished.gif"
|
|
var/datum/computer_file/program/downloaded_file = null
|
|
var/hacked_download = 0
|
|
var/download_completion = 0 //GQ of downloaded data.
|
|
var/download_netspeed = 0
|
|
var/downloaderror = ""
|
|
var/obj/item/device/modular_computer/my_computer = null
|
|
|
|
/datum/computer_file/program/ntnetdownload/proc/begin_file_download(filename)
|
|
if(downloaded_file)
|
|
return 0
|
|
|
|
var/datum/computer_file/program/PRG = GLOB.ntnet_global.find_ntnet_file_by_name(filename)
|
|
|
|
if(!PRG || !istype(PRG))
|
|
return 0
|
|
|
|
// Attempting to download antag only program, but without having emagged computer. No.
|
|
if(PRG.available_on_syndinet && !computer.emagged)
|
|
return 0
|
|
|
|
var/obj/item/weapon/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD]
|
|
|
|
if(!computer || !hard_drive || !hard_drive.can_store_file(PRG))
|
|
return 0
|
|
|
|
ui_header = "downloader_running.gif"
|
|
|
|
if(PRG in GLOB.ntnet_global.available_station_software)
|
|
generate_network_log("Began downloading file [PRG.filename].[PRG.filetype] from NTNet Software Repository.")
|
|
hacked_download = 0
|
|
else if(PRG in GLOB.ntnet_global.available_antag_software)
|
|
generate_network_log("Began downloading file **ENCRYPTED**.[PRG.filetype] from unspecified server.")
|
|
hacked_download = 1
|
|
else
|
|
generate_network_log("Began downloading file [PRG.filename].[PRG.filetype] from unspecified server.")
|
|
hacked_download = 0
|
|
|
|
downloaded_file = PRG.clone()
|
|
|
|
/datum/computer_file/program/ntnetdownload/proc/abort_file_download()
|
|
if(!downloaded_file)
|
|
return
|
|
generate_network_log("Aborted download of file [hacked_download ? "**ENCRYPTED**" : "[downloaded_file.filename].[downloaded_file.filetype]"].")
|
|
downloaded_file = null
|
|
download_completion = 0
|
|
ui_header = "downloader_finished.gif"
|
|
|
|
/datum/computer_file/program/ntnetdownload/proc/complete_file_download()
|
|
if(!downloaded_file)
|
|
return
|
|
generate_network_log("Completed download of file [hacked_download ? "**ENCRYPTED**" : "[downloaded_file.filename].[downloaded_file.filetype]"].")
|
|
var/obj/item/weapon/computer_hardware/hard_drive/hard_drive = computer.all_components[MC_HDD]
|
|
if(!computer || !hard_drive || !hard_drive.store_file(downloaded_file))
|
|
// The download failed
|
|
downloaderror = "I/O ERROR - Unable to save file. Check whether you have enough free space on your hard drive and whether your hard drive is properly connected. If the issue persists contact your system administrator for assistance."
|
|
downloaded_file = null
|
|
download_completion = 0
|
|
ui_header = "downloader_finished.gif"
|
|
|
|
/datum/computer_file/program/ntnetdownload/process_tick()
|
|
if(!downloaded_file)
|
|
return
|
|
if(download_completion >= downloaded_file.size)
|
|
complete_file_download()
|
|
// Download speed according to connectivity state. NTNet server is assumed to be on unlimited speed so we're limited by our local connectivity
|
|
download_netspeed = 0
|
|
// Speed defines are found in misc.dm
|
|
switch(ntnet_status)
|
|
if(1)
|
|
download_netspeed = NTNETSPEED_LOWSIGNAL
|
|
if(2)
|
|
download_netspeed = NTNETSPEED_HIGHSIGNAL
|
|
if(3)
|
|
download_netspeed = NTNETSPEED_ETHERNET
|
|
download_completion += download_netspeed
|
|
|
|
/datum/computer_file/program/ntnetdownload/ui_act(action, params)
|
|
if(..())
|
|
return 1
|
|
switch(action)
|
|
if("PRG_downloadfile")
|
|
if(!downloaded_file)
|
|
begin_file_download(params["filename"])
|
|
return 1
|
|
if("PRG_reseterror")
|
|
if(downloaderror)
|
|
download_completion = 0
|
|
download_netspeed = 0
|
|
downloaded_file = null
|
|
downloaderror = ""
|
|
return 1
|
|
return 0
|
|
|
|
/datum/computer_file/program/ntnetdownload/ui_interact(mob/user, ui_key = "main", datum/tgui/ui = null, force_open = 0, datum/tgui/master_ui = null, datum/ui_state/state = GLOB.default_state)
|
|
ui = SStgui.try_update_ui(user, src, ui_key, ui, force_open)
|
|
if (!ui)
|
|
|
|
var/datum/asset/assets = get_asset_datum(/datum/asset/simple/headers)
|
|
assets.send(user)
|
|
|
|
ui = new(user, src, ui_key, "ntnet_downloader", "NTNet Download Program", 575, 700, state = state)
|
|
ui.open()
|
|
ui.set_autoupdate(state = 1)
|
|
|
|
/datum/computer_file/program/ntnetdownload/ui_data(mob/user)
|
|
my_computer = computer
|
|
|
|
if(!istype(my_computer))
|
|
return
|
|
|
|
var/list/data = get_header_data()
|
|
|
|
// This IF cuts on data transferred to client, so i guess it's worth it.
|
|
if(downloaderror) // Download errored. Wait until user resets the program.
|
|
data["error"] = downloaderror
|
|
else if(downloaded_file) // Download running. Wait please..
|
|
data["downloadname"] = downloaded_file.filename
|
|
data["downloaddesc"] = downloaded_file.filedesc
|
|
data["downloadsize"] = downloaded_file.size
|
|
data["downloadspeed"] = download_netspeed
|
|
data["downloadcompletion"] = round(download_completion, 0.1)
|
|
else // No download running, pick file.
|
|
var/obj/item/weapon/computer_hardware/hard_drive/hard_drive = my_computer.all_components[MC_HDD]
|
|
data["disk_size"] = hard_drive.max_capacity
|
|
data["disk_used"] = hard_drive.used_capacity
|
|
var/list/all_entries[0]
|
|
for(var/A in GLOB.ntnet_global.available_station_software)
|
|
var/datum/computer_file/program/P = A
|
|
// Only those programs our user can run will show in the list
|
|
if(!P.can_run(user,transfer = 1))
|
|
continue
|
|
all_entries.Add(list(list(
|
|
"filename" = P.filename,
|
|
"filedesc" = P.filedesc,
|
|
"fileinfo" = P.extended_desc,
|
|
"compatibility" = check_compatibility(P),
|
|
"size" = P.size
|
|
)))
|
|
data["hackedavailable"] = 0
|
|
if(computer.emagged) // If we are running on emagged computer we have access to some "bonus" software
|
|
var/list/hacked_programs[0]
|
|
for(var/S in GLOB.ntnet_global.available_antag_software)
|
|
var/datum/computer_file/program/P = S
|
|
data["hackedavailable"] = 1
|
|
hacked_programs.Add(list(list(
|
|
"filename" = P.filename,
|
|
"filedesc" = P.filedesc,
|
|
"fileinfo" = P.extended_desc,
|
|
"size" = P.size
|
|
)))
|
|
data["hacked_programs"] = hacked_programs
|
|
|
|
data["downloadable_programs"] = all_entries
|
|
|
|
return data
|
|
|
|
/datum/computer_file/program/ntnetdownload/proc/check_compatibility(datum/computer_file/program/P)
|
|
var/hardflag = computer.hardware_flag
|
|
|
|
if(P && P.is_supported_by_hardware(hardflag,0))
|
|
return "Compatible"
|
|
return "Incompatible!"
|
|
|
|
/datum/computer_file/program/ntnetdownload/kill_program(forced)
|
|
abort_file_download()
|
|
return ..(forced) |