mirror of
https://github.com/Bubberstation/Bubberstation.git
synced 2026-06-22 14:44:12 +01:00
21b4095dfd
Upstream 04/17/2026 fixes https://github.com/Bubberstation/Bubberstation/issues/5549 --------- Signed-off-by: dependabot[bot] <support@github.com> Co-authored-by: tgstation-ci[bot] <179393467+tgstation-ci[bot]@users.noreply.github.com> Co-authored-by: ArcaneMusic <41715314+ArcaneMusic@users.noreply.github.com> Co-authored-by: MrMelbert <51863163+MrMelbert@users.noreply.github.com> Co-authored-by: Rhials <28870487+Rhials@users.noreply.github.com> Co-authored-by: rageguy505 <54517726+rageguy505@users.noreply.github.com> Co-authored-by: LemonInTheDark <58055496+LemonInTheDark@users.noreply.github.com> Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com> Co-authored-by: Aliceee2ch <160794176+Aliceee2ch@users.noreply.github.com> Co-authored-by: Time-Green <7501474+Time-Green@users.noreply.github.com> Co-authored-by: Tsar-Salat <62388554+Tsar-Salat@users.noreply.github.com> Co-authored-by: SmArtKar <44720187+SmArtKar@users.noreply.github.com> Co-authored-by: Maxipat <108554989+Maxipat112@users.noreply.github.com> Co-authored-by: SyncIt21 <110812394+SyncIt21@users.noreply.github.com> Co-authored-by: deltanedas <39013340+deltanedas@users.noreply.github.com> Co-authored-by: SimplyLogan <47579821+loganuk@users.noreply.github.com> Co-authored-by: loganuk <fakeemail123@aol.com> Co-authored-by: Leland Kemble <70413276+lelandkemble@users.noreply.github.com> Co-authored-by: FalloutFalcon <86381784+FalloutFalcon@users.noreply.github.com> Co-authored-by: Roxy <75404941+TealSeer@users.noreply.github.com> Co-authored-by: Lucy <lucy@absolucy.moe> Co-authored-by: siliconOpossum <138069572+siliconOpossum@users.noreply.github.com> Co-authored-by: Isratosh <Isratosh@hotmail.com> Co-authored-by: TheRyeGuyWhoWillNowDie <70169560+TheRyeGuyWhoWillNowDie@users.noreply.github.com> Co-authored-by: Neocloudy <88008002+Neocloudy@users.noreply.github.com> Co-authored-by: Alexander V. <volas@ya.ru> Co-authored-by: ElGitificador <168473461+ElGitificador@users.noreply.github.com> Co-authored-by: Twaticus <46540570+Twaticus@users.noreply.github.com> Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: Bloop <13398309+vinylspiders@users.noreply.github.com> Co-authored-by: Cameron Lennox <killer65311@gmail.com> Co-authored-by: Tim <timothymtorres@gmail.com> Co-authored-by: Iamgoofball <iamgoofball@gmail.com> Co-authored-by: Layzu666 <121319428+Layzu666@users.noreply.github.com> Co-authored-by: Arturlang <24881678+Arturlang@users.noreply.github.com> Co-authored-by: _0Steven <42909981+00-Steven@users.noreply.github.com> Co-authored-by: mrmanlikesbt <99309552+mrmanlikesbt@users.noreply.github.com> Co-authored-by: Ben10Omintrix <138636438+Ben10Omintrix@users.noreply.github.com> Co-authored-by: John F. Kennedy <54908920+MacaroniCritter@users.noreply.github.com> Co-authored-by: Cursor <102828457+theselfish@users.noreply.github.com> Co-authored-by: Josh <josh.adam.powell@gmail.com> Co-authored-by: Josh Powell <josh.powell@softwire.com> Co-authored-by: Yobrocharlie <Charliemiller5617@gmail.com> Co-authored-by: Hardly3D <66234359+Hardly3D@users.noreply.github.com> Co-authored-by: shayoki <96078776+shayoki@users.noreply.github.com> Co-authored-by: LT3 <83487515+lessthnthree@users.noreply.github.com>
96 lines
4.1 KiB
Plaintext
96 lines
4.1 KiB
Plaintext
/**
|
|
* Circuit components of modular programs are special.
|
|
* They're added to the unremovable components of the shell when the prog is installed and deleted if uninstalled.
|
|
* This means they don't work like normal unremovable comps that live and die along with their shell.
|
|
*/
|
|
/obj/item/circuit_component/mod_program
|
|
display_name = "Abstract Modular Program"
|
|
desc = "I've spent lot of time thinking how to get this to work. If you see this, I either failed or someone else did, so report it."
|
|
/**
|
|
* The program that installed us into the shell/usb_port comp. Needed to avoid having too many signals for every program.
|
|
* This is also the program we need to install on the modular computer if the circuit is admin-loaded.
|
|
* Just make sure each of these components is associated to one and only type of program, no subtypes of anything.
|
|
*/
|
|
var/datum/computer_file/program/associated_program
|
|
|
|
///Starts the program if possible, placing it in the background if another's active.
|
|
var/datum/port/input/start
|
|
///kills the program.
|
|
var/datum/port/input/kill
|
|
///binary for whether the program is running or not
|
|
var/datum/port/output/running
|
|
|
|
/obj/item/circuit_component/mod_program/Initialize(mapload)
|
|
if(associated_program)
|
|
display_name = initial(associated_program.filedesc)
|
|
desc = initial(associated_program.extended_desc)
|
|
return ..() // Set the name correctly
|
|
|
|
/obj/item/circuit_component/mod_program/register_shell(atom/movable/shell)
|
|
. = ..()
|
|
var/obj/item/modular_computer/computer
|
|
if(istype(shell, /obj/item/modular_computer))
|
|
computer = shell
|
|
else if(istype(shell, /obj/machinery/modular_computer))
|
|
var/obj/machinery/modular_computer/console = shell
|
|
computer = console.cpu
|
|
|
|
///Find the associated program in the computer's stored_files (install it otherwise) and store a reference to it.
|
|
var/datum/computer_file/program/found_program = locate(associated_program) in computer.stored_files
|
|
///The integrated circuit was loaded/duplicated
|
|
if(isnull(found_program))
|
|
associated_program = new associated_program()
|
|
computer.store_file(associated_program)
|
|
else
|
|
associated_program = found_program
|
|
|
|
RegisterSignal(associated_program, COMSIG_COMPUTER_PROGRAM_START, PROC_REF(on_start))
|
|
RegisterSignal(associated_program, COMSIG_COMPUTER_PROGRAM_KILL, PROC_REF(on_kill))
|
|
|
|
/obj/item/circuit_component/mod_program/unregister_shell()
|
|
UnregisterSignal(associated_program, list(COMSIG_COMPUTER_PROGRAM_START, COMSIG_COMPUTER_PROGRAM_KILL))
|
|
associated_program = initial(associated_program)
|
|
return ..()
|
|
|
|
/obj/item/circuit_component/mod_program/populate_ports()
|
|
SHOULD_CALL_PARENT(TRUE)
|
|
. = ..()
|
|
start = add_input_port("Start", PORT_TYPE_SIGNAL, trigger = PROC_REF(start_prog))
|
|
kill = add_input_port("Kill", PORT_TYPE_SIGNAL, trigger = PROC_REF(kill_prog))
|
|
running = add_output_port("Running", PORT_TYPE_BOOLEAN)
|
|
|
|
///For most programs, triggers only work if they're open (either active or idle).
|
|
/obj/item/circuit_component/mod_program/should_receive_input(datum/port/input/port)
|
|
. = ..()
|
|
if(!.)
|
|
return FALSE
|
|
if(isnull(associated_program))
|
|
return FALSE
|
|
if(!associated_program.computer.enabled)
|
|
return FALSE
|
|
if(associated_program.program_flags & PROGRAM_CIRCUITS_RUN_WHEN_CLOSED || COMPONENT_TRIGGERED_BY(start, port))
|
|
return TRUE
|
|
var/obj/item/modular_computer/computer = associated_program.computer
|
|
if(computer.active_program == associated_program || (associated_program in computer.idle_threads))
|
|
return TRUE
|
|
return FALSE
|
|
|
|
/obj/item/circuit_component/mod_program/proc/start_prog(datum/port/input/port)
|
|
associated_program.computer.open_program(program = associated_program)
|
|
|
|
/obj/item/circuit_component/mod_program/proc/on_start(mob/living/user)
|
|
SIGNAL_HANDLER
|
|
running.set_output(TRUE)
|
|
|
|
/obj/item/circuit_component/mod_program/proc/kill_prog(datum/port/input/port)
|
|
associated_program.kill_program()
|
|
|
|
/obj/item/circuit_component/mod_program/proc/on_kill(mob/living/user)
|
|
SIGNAL_HANDLER
|
|
running.set_output(FALSE)
|
|
|
|
/obj/item/circuit_component/mod_program/get_ui_notices()
|
|
. = ..()
|
|
if(!(associated_program.program_flags & PROGRAM_CIRCUITS_RUN_WHEN_CLOSED))
|
|
. += create_ui_notice("Requires open program for inputs", "purple")
|