Fixes cell-less APC causing TGUI BSOD on Power Monitor (#15196)

* Fixes cell-less APC causing TGUI BSOD on Power Monitor

* Clean code ™
This commit is contained in:
dearmochi
2020-12-28 10:20:37 +00:00
committed by GitHub
parent 62c0e5e038
commit 6be5468342
3 changed files with 12 additions and 2 deletions
+9 -1
View File
@@ -21,7 +21,15 @@ GLOBAL_DATUM_INIT(apc_repository, /datum/repository/apc, new())
var/list/Status = list("Off","AOff","On","AOn") // Status: off, auto-off, on, auto-on
var/list/chg = list("N","C","F") // Charging: no, charging, full
for(var/obj/machinery/power/apc/A in L)
apcData[++apcData.len] = list("Name" = html_encode(A.area.name), "Equipment" = Status[A.equipment+1], "Lights" = Status[A.lighting+1], "Environment" = Status[A.environ+1], "CellPct" = A.cell ? round(A.cell.percent(),1) : "M", "CellStatus" = A.cell ? chg[A.charging+1] : "M", "Load" = round(A.lastused_total,1))
apcData[++apcData.len] = list(
"Name" = html_encode(A.area.name),
"Equipment" = Status[A.equipment + 1],
"Lights" = Status[A.lighting + 1],
"Environment" = Status[A.environ + 1],
"CellPct" = A.cell ? round(A.cell.percent(), 1) : 0,
"CellStatus" = A.cell ? chg[A.charging + 1] : "M",
"Load" = round(A.lastused_total, 1)
)
cache_entry.timestamp = world.time + 5 SECONDS
cache_entry.data = apcData