mirror of
https://github.com/Aurorastation/Aurora.3.git
synced 2026-08-25 05:51:56 +01:00
Misc Modular Computer Fixes/Cleanup (#21092)
Prompted by [this](https://github.com/Aurorastation/Aurora.3/issues/21090) (Atmos control app not reliably updating all alarms from SSmachinery.processing). Did what I could but barring a larger refactor of how computer programs are initialized, didn't want to burn Too much time so implemented a Refresh button in the application interface as an in-game fallback option. Also fixes the bug with Loadout-spawned laptops not booting; their hard drives were being initialized with default software due to accidental codeblock removal [here](https://github.com/Aurorastation/Aurora.3/pull/20660/files#diff-40a75a936400e3c347fd8c3d4c804190a63ac9be980912f6a9995efd1b296a1e). Restored the affecting code. Updated several other files I discovered in passing while working on this with proper DMdocs formatting.
This commit is contained in:
@@ -37,7 +37,7 @@
|
||||
icon_state = "hdd_cluster"
|
||||
hardware_size = 3
|
||||
|
||||
// For tablets, etc. - highly power efficient.
|
||||
/// For tablets, etc. - highly power efficient.
|
||||
/obj/item/computer_hardware/hard_drive/small
|
||||
name = "small hard drive"
|
||||
desc = "A small highly efficient solid state drive for portable devices."
|
||||
@@ -56,13 +56,19 @@
|
||||
icon_state = "hdd_micro"
|
||||
hardware_size = 1
|
||||
|
||||
|
||||
/**
|
||||
* Returns number of stored files and storage usage/capacity.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/diagnostics(var/mob/user)
|
||||
..()
|
||||
// 999 is a byond limit that is in place. It's unlikely someone will reach that many files anyway, since you would sooner run out of space.
|
||||
/// 999 is a byond limit that is in place. It's unlikely someone will reach that many files anyway, since you would sooner run out of space.
|
||||
to_chat(user, SPAN_NOTICE("NT-NFS File Table Status: [stored_files.len]/999"))
|
||||
to_chat(user, SPAN_NOTICE("Storage capacity: [used_capacity]/[max_capacity]GQ"))
|
||||
|
||||
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
/**
|
||||
* Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/store_file(var/datum/computer_file/F)
|
||||
if(!F || !istype(F))
|
||||
return FALSE
|
||||
@@ -82,14 +88,18 @@
|
||||
recalculate_size()
|
||||
return TRUE
|
||||
|
||||
// Use this proc to add file to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
/**
|
||||
* Use this proc to add all basic functionality software to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/install_default_programs()
|
||||
if(parent_computer)
|
||||
store_file(new /datum/computer_file/program/computerconfig(parent_computer)) // Computer configuration utility, allows hardware control and displays more info than status bar
|
||||
store_file(new /datum/computer_file/program/clientmanager(parent_computer)) // Client Manager to Enroll the Device
|
||||
store_file(new /datum/computer_file/program/pai_access_lock(parent_computer)) // pAI access control, to stop pesky pAI from messing with computers
|
||||
|
||||
// Use this proc to remove file from the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
/**
|
||||
* Use this proc to remove files to the drive. Returns 1 on success and 0 on failure. Contains necessary sanity checks.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/remove_file(var/datum/computer_file/F)
|
||||
if(!F || !istype(F))
|
||||
return FALSE
|
||||
@@ -104,14 +114,18 @@
|
||||
else
|
||||
return FALSE
|
||||
|
||||
// Loops through all stored files and recalculates used_capacity of this drive
|
||||
/**
|
||||
* Loops through all stored files and recalculates used_capacity of this drive
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/recalculate_size()
|
||||
var/total_size = 0
|
||||
for(var/datum/computer_file/F in stored_files)
|
||||
total_size += F.size
|
||||
used_capacity = total_size
|
||||
|
||||
// Checks whether file can be stored on the hard drive.
|
||||
/**
|
||||
* Checks whether file can be stored on the hard drive.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/can_store_file(var/size = TRUE)
|
||||
// In the unlikely event someone manages to create that many files.
|
||||
// BYOND is acting weird with numbers above 999 in loops (infinite loop prevention)
|
||||
@@ -124,7 +138,9 @@
|
||||
else
|
||||
return TRUE
|
||||
|
||||
// Checks whether we can store the file. We can only store unique files, so this checks whether we wouldn't get a duplicity by adding a file.
|
||||
/**
|
||||
* Checks whether we can store the file. We can only store unique files, so this checks whether we wouldn't get a duplicity by adding a file.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/try_store_file(var/datum/computer_file/F)
|
||||
if(!F || !istype(F))
|
||||
return FALSE
|
||||
@@ -134,7 +150,9 @@
|
||||
return FALSE
|
||||
return can_store_file(F.size)
|
||||
|
||||
// Tries to find the file by filename. Returns null on failure
|
||||
/**
|
||||
* Tries to find the file by filename. Returns null on failure.
|
||||
*/
|
||||
/obj/item/computer_hardware/hard_drive/proc/find_file_by_name(var/filename)
|
||||
if(!check_functionality())
|
||||
return null
|
||||
@@ -159,6 +177,10 @@
|
||||
QDEL_LIST(stored_files)
|
||||
return ..()
|
||||
|
||||
/obj/item/computer_hardware/hard_drive/Initialize(mapload)
|
||||
. = ..()
|
||||
install_default_programs()
|
||||
|
||||
/obj/item/computer_hardware/hard_drive/proc/reset_drive()
|
||||
for(var/datum/computer_file/F in stored_files)
|
||||
remove_file(F)
|
||||
|
||||
@@ -3,37 +3,53 @@
|
||||
desc = "Unknown Hardware."
|
||||
icon = 'icons/obj/modular_components.dmi'
|
||||
var/obj/item/modular_computer/parent_computer
|
||||
var/power_usage = 0 // If the hardware uses extra power, change this.
|
||||
var/enabled = TRUE // If the hardware is turned off set this to 0.
|
||||
var/critical = TRUE // Prevent disabling for important component, like the HDD.
|
||||
var/hardware_size = 1 // Limits which devices can contain this component. 1: Tablets/Laptops/Consoles, 2: Laptops/Consoles, 3: Consoles only
|
||||
var/damage = 0 // Current damage level
|
||||
var/max_damage = 100 // Maximal damage level.
|
||||
var/damage_malfunction = 20 // "Malfunction" threshold. When damage exceeds this value the hardware piece will semi-randomly fail and do !!FUN!! things
|
||||
var/damage_failure = 50 // "Failure" threshold. When damage exceeds this value the hardware piece will not work at all.
|
||||
var/malfunction_probability = 10 // Chance of malfunction when the component is damaged
|
||||
|
||||
// Default handling of hardware enable/disable. Override for specific functionality.
|
||||
/// If the hardware uses extra power, change this.
|
||||
var/power_usage = 0
|
||||
/// If the hardware is turned off set this to 0.
|
||||
var/enabled = TRUE
|
||||
/// Prevent disabling for important component, like the HDD.
|
||||
var/critical = TRUE
|
||||
/// Limits which devices can contain this component. 1: Tablets/Laptops/Consoles, 2: Laptops/Consoles, 3: Consoles only
|
||||
var/hardware_size = 1
|
||||
/// Current damage level
|
||||
var/damage = 0
|
||||
/// Maximal damage level.
|
||||
var/max_damage = 100
|
||||
/// "Malfunction" threshold. When damage exceeds this value the hardware piece will semi-randomly fail and do !!FUN!! things
|
||||
var/damage_malfunction = 20
|
||||
/// "Failure" threshold. When damage exceeds this value the hardware piece will not work at all.
|
||||
var/damage_failure = 50
|
||||
/// Chance of malfunction when the component is damaged
|
||||
var/malfunction_probability = 10
|
||||
|
||||
/**
|
||||
* Default handling of hardware enable/disable. Override for specific functionality.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/enable()
|
||||
. = enabled = TRUE
|
||||
|
||||
/**
|
||||
* Default handling of hardware enable/disable. Override for specific functionality.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/disable()
|
||||
. = enabled = FALSE
|
||||
|
||||
/**
|
||||
* Default handling of hardware enable/disable. Override for specific functionality.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/toggle()
|
||||
if(enabled)
|
||||
return disable()
|
||||
return enable()
|
||||
|
||||
/obj/item/computer_hardware/attackby(obj/item/attacking_item, mob/user)
|
||||
// Multitool. Runs diagnostics
|
||||
/// Multitool. Runs diagnostics
|
||||
if(attacking_item.ismultitool())
|
||||
to_chat(user, SPAN_NOTICE("***** DIAGNOSTICS REPORT *****"))
|
||||
diagnostics(user)
|
||||
to_chat(user, SPAN_NOTICE("******************************"))
|
||||
return 1
|
||||
// Nanopaste. Repair all damage if present for a single unit.
|
||||
/// Nanopaste. Repair all damage if present for a single unit.
|
||||
var/obj/item/stack/S = attacking_item
|
||||
if(istype(S, /obj/item/stack/nanopaste))
|
||||
if(!damage)
|
||||
@@ -43,7 +59,7 @@
|
||||
to_chat(user, SPAN_NOTICE("You apply a bit of \the [attacking_item] to \the [src], repairing it fully."))
|
||||
damage = 0
|
||||
return TRUE
|
||||
// Cable coil. Works as repair method, but will probably require multiple applications and more cable.
|
||||
/// Cable coil. Works as repair method, but will probably require multiple applications and more cable.
|
||||
if(S.iscoil())
|
||||
if(!damage)
|
||||
to_chat(user, SPAN_WARNING("\The [src] doesn't seem to require repairs."))
|
||||
@@ -54,7 +70,9 @@
|
||||
return TRUE
|
||||
return ..()
|
||||
|
||||
// Called on multitool click, prints diagnostic information to the user.
|
||||
/**
|
||||
* Called on multitool click, prints diagnostic information to the user.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/diagnostics(var/mob/user)
|
||||
to_chat(user, SPAN_NOTICE("Hardware Integrity Test... (Physical Damage: [damage]/[max_damage]) [damage > damage_failure ? "FAIL" : damage > damage_malfunction ? "WARN" : "PASS"]"))
|
||||
|
||||
@@ -69,19 +87,21 @@
|
||||
parent_computer = null
|
||||
return ..()
|
||||
|
||||
// Handles damage checks
|
||||
/**
|
||||
* Handles damage checks
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/check_functionality()
|
||||
// Turned off
|
||||
/// Turned off
|
||||
if(!enabled)
|
||||
return FALSE
|
||||
// Too damaged to work at all.
|
||||
/// Too damaged to work at all.
|
||||
if(damage > damage_failure)
|
||||
return FALSE
|
||||
// Still working. Well, sometimes...
|
||||
/// Still working. Well, sometimes...
|
||||
if(damage > damage_malfunction)
|
||||
if(prob(malfunction_probability))
|
||||
return FALSE
|
||||
// Good to go.
|
||||
/// Good to go.
|
||||
return TRUE
|
||||
|
||||
/obj/item/computer_hardware/get_examine_text(mob/user, distance, is_adjacent, infix, suffix)
|
||||
@@ -93,7 +113,9 @@
|
||||
else if(damage)
|
||||
. += SPAN_WARNING("It seems to be slightly damaged.")
|
||||
|
||||
// Damages the component. Contains necessary checks. Negative damage "heals" the component.
|
||||
/**
|
||||
* Damages the component. Contains necessary checks. Negative damage "heals" the component.
|
||||
*/
|
||||
/obj/item/computer_hardware/proc/take_damage(var/amount)
|
||||
damage += round(amount) // We want nice rounded numbers here.
|
||||
damage = between(0, damage, max_damage) // Clamp the value.
|
||||
damage += round(amount) /// We want nice rounded numbers here.
|
||||
damage = between(0, damage, max_damage) /// Clamp the value.
|
||||
|
||||
Reference in New Issue
Block a user