Harddel Fix Pack #42 + Better Live Reftracking Support (#63877)

* Hard Del Fixes, Ref Tracking Changes
This commit is contained in:
LemonInTheDark
2022-01-12 13:46:13 -08:00
committed by GitHub
parent f3f7720d7e
commit f8aad14ae8
109 changed files with 865 additions and 733 deletions
@@ -15,8 +15,8 @@
program_icon = "plug"
var/has_alert = 0
var/obj/structure/cable/attached_wire
var/obj/machinery/power/apc/local_apc
var/datum/weakref/attached_wire_ref
var/datum/weakref/local_apc_ref
var/list/history = list()
var/record_size = 60
var/record_interval = 50
@@ -38,19 +38,22 @@
/datum/computer_file/program/power_monitor/proc/search() //keep in sync with /obj/machinery/computer/monitor's version
var/turf/T = get_turf(computer)
attached_wire = locate(/obj/structure/cable) in T
if(attached_wire)
attached_wire_ref = WEAKREF(locate(/obj/structure/cable) in T)
if(attached_wire_ref)
return
var/area/A = get_area(computer) //if the computer isn't directly connected to a wire, attempt to find the APC powering it to pull it's powernet instead
if(!A)
return
local_apc = A.apc
var/obj/machinery/power/apc/local_apc = WEAKREF(A.apc)
if(!local_apc)
return
if(!local_apc.terminal) //this really shouldn't happen without badminnery.
local_apc = null
local_apc_ref = WEAKREF(local_apc)
/datum/computer_file/program/power_monitor/proc/get_powernet() //keep in sync with /obj/machinery/computer/monitor's version
var/obj/structure/cable/attached_wire = attached_wire_ref?.resolve()
var/obj/machinery/power/apc/local_apc = local_apc_ref?.resolve()
if(attached_wire || (local_apc?.terminal))
return attached_wire ? attached_wire.powernet : local_apc.terminal.powernet
return FALSE