From 7f53bcd89289c506ecee76847830fafeebd643e2 Mon Sep 17 00:00:00 2001 From: TheNightingale <137739943+TheNightingale@users.noreply.github.com> Date: Mon, 27 Nov 2023 12:49:16 +0300 Subject: [PATCH] [MIRROR] System Programs --- .../modular_computers/file_system/program.dm | 3 +++ .../programs/generic/configurator.dm | 1 + .../programs/generic/email_client.dm | 3 ++- .../programs/generic/file_browser.dm | 1 + .../programs/generic/ntdownloader.dm | 1 + code/modules/modular_computers/ntos/ntos.dm | 20 ++++++++++++------- 6 files changed, 21 insertions(+), 8 deletions(-) diff --git a/code/modules/modular_computers/file_system/program.dm b/code/modules/modular_computers/file_system/program.dm index 426c79677d583..c0f183595f3c2 100644 --- a/code/modules/modular_computers/file_system/program.dm +++ b/code/modules/modular_computers/file_system/program.dm @@ -51,6 +51,9 @@ /// Holder for skill value of current/recent operator for programs that tick. var/operator_skill = SKILL_MIN + /// How much processing size the program should take up. + var/processing_size = 1 + /datum/computer_file/program/Destroy() if(computer && computer.active_program == src) computer.kill_program(src) diff --git a/code/modules/modular_computers/file_system/programs/generic/configurator.dm b/code/modules/modular_computers/file_system/programs/generic/configurator.dm index 50b7abf49b11d..abebf5762a4cf 100644 --- a/code/modules/modular_computers/file_system/programs/generic/configurator.dm +++ b/code/modules/modular_computers/file_system/programs/generic/configurator.dm @@ -12,6 +12,7 @@ unsendable = 1 undeletable = 1 size = 4 + processing_size = 0.5 available_on_ntnet = FALSE requires_ntnet = FALSE nanomodule_path = /datum/nano_module/program/computer_configurator diff --git a/code/modules/modular_computers/file_system/programs/generic/email_client.dm b/code/modules/modular_computers/file_system/programs/generic/email_client.dm index badfcd97f100b..d6904ca8a7fa5 100644 --- a/code/modules/modular_computers/file_system/programs/generic/email_client.dm +++ b/code/modules/modular_computers/file_system/programs/generic/email_client.dm @@ -5,7 +5,8 @@ program_icon_state = "generic" program_key_state = "generic_key" program_menu_icon = "mail-closed" - size = 7 + size = 1 + processing_size = 0 //It's the only way to ensure people actually have it on. requires_ntnet = TRUE available_on_ntnet = TRUE var/stored_login = "" diff --git a/code/modules/modular_computers/file_system/programs/generic/file_browser.dm b/code/modules/modular_computers/file_system/programs/generic/file_browser.dm index aac088537fdca..eb3395399f5a4 100644 --- a/code/modules/modular_computers/file_system/programs/generic/file_browser.dm +++ b/code/modules/modular_computers/file_system/programs/generic/file_browser.dm @@ -6,6 +6,7 @@ program_key_state = "generic_key" program_menu_icon = "folder-collapsed" size = 8 + processing_size = 0.5 requires_ntnet = FALSE available_on_ntnet = FALSE undeletable = TRUE diff --git a/code/modules/modular_computers/file_system/programs/generic/ntdownloader.dm b/code/modules/modular_computers/file_system/programs/generic/ntdownloader.dm index 4928723295b11..79de2b0d5316c 100644 --- a/code/modules/modular_computers/file_system/programs/generic/ntdownloader.dm +++ b/code/modules/modular_computers/file_system/programs/generic/ntdownloader.dm @@ -8,6 +8,7 @@ unsendable = TRUE undeletable = TRUE size = 4 + processing_size = 0.5 requires_ntnet = TRUE requires_ntnet_feature = NTNET_SOFTWAREDOWNLOAD available_on_ntnet = FALSE diff --git a/code/modules/modular_computers/ntos/ntos.dm b/code/modules/modular_computers/ntos/ntos.dm index 5b7b94531d082..119b2ba403a01 100644 --- a/code/modules/modular_computers/ntos/ntos.dm +++ b/code/modules/modular_computers/ntos/ntos.dm @@ -7,8 +7,10 @@ var/on = FALSE /// A currently active program running on the computer. var/datum/computer_file/program/active_program = null - /// All programms currently running, background or active. + /// All programs currently running, background or active, including small programs. var/list/running_programs = list() + /// The processing size being used by all programs. + var/processing_size = 0 /// dmi where the screen overlays are kept, defaults to holder's icon if unset var/screen_icon_file @@ -140,22 +142,26 @@ /datum/extension/interactive/ntos/proc/run_program_remote(filename, mob/user = null, loud = 0) var/datum/computer_file/program/P = get_file(filename) - if(!istype(P)) + if (!istype(P)) loud && show_error(user, "I/O ERROR - Unable to run [filename]") return - if(!P.is_supported_by_hardware(get_hardware_flag())) + if (!P.is_supported_by_hardware(get_hardware_flag())) loud && show_error(user, "Hardware Error - Incompatible software") return - if(P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) + if (P.requires_ntnet && !get_ntnet_status(P.requires_ntnet_feature)) loud && show_error(user, "Unable to establish a working network connection. Please try again later. If problem persists, please contact your system administrator.") return - if(P in running_programs) + if (P in running_programs) return P - if(length(running_programs) >= get_program_capacity()) + + var/processing_total = 0 + for (var/datum/computer_file/program/program in running_programs) + processing_total += program.processing_size + if ((processing_total + P.processing_size) > get_program_capacity() && P.processing_size) loud && show_error(user, "Kernel Error - Insufficient CPU resources available to allocate.") return - if(!P.can_run(user, loud)) + if (!P.can_run(user, loud)) return P.on_startup(user, src)