Skip to content

Commit

Permalink
[MIRROR] System Programs
Browse files Browse the repository at this point in the history
  • Loading branch information
TheNightingale authored and SierraHelper committed Nov 27, 2023
1 parent b95ba52 commit 7f53bcd
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 8 deletions.
3 changes: 3 additions & 0 deletions code/modules/modular_computers/file_system/program.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = ""
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
20 changes: 13 additions & 7 deletions code/modules/modular_computers/ntos/ntos.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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)
Expand Down

0 comments on commit 7f53bcd

Please sign in to comment.