Security camera console now also caches it' list of cameras.

FUCKING HUGE.
This commit is contained in:
ccomp5950
2015-01-25 07:15:58 -05:00
parent 89652ae5e3
commit c0469fc9b6
4 changed files with 52 additions and 23 deletions

View File

@@ -36,6 +36,9 @@
wires = new(src)
assembly = new(src)
assembly.state = 4
invalidateCameraCache()
/* // Use this to look for cameras that have the same c_tag.
for(var/obj/machinery/camera/C in cameranet.cameras)
var/list/tempnetwork = C.network&src.network
@@ -61,6 +64,7 @@
/obj/machinery/camera/emp_act(severity)
if(!isEmpProof())
if(prob(100/severity))
invalidateCameraCache()
stat |= EMPED
SetLuminosity(0)
kick_viewers()
@@ -71,7 +75,7 @@
stat &= ~EMPED
cancelCameraAlarm()
update_icon()
invalidateCameraCache()
..()
/obj/machinery/camera/bullet_act(var/obj/item/projectile/P)
@@ -118,7 +122,7 @@
destroy()
/obj/machinery/camera/attackby(obj/W as obj, mob/living/user as mob)
invalidateCameraCache()
// DECONSTRUCTION
if(isscrewdriver(W))
//user << "<span class='notice'>You start to [panel_open ? "close" : "open"] the camera's panel.</span>"
@@ -199,6 +203,7 @@
//legacy support, if choice is != 1 then just kick viewers without changing status
kick_viewers()
else
invalidateCameraCache()
set_status( !src.status )
if (!(src.status))
visible_message("\red [user] has deactivated [src]!")
@@ -218,6 +223,7 @@
//Used when someone breaks a camera
/obj/machinery/camera/proc/destroy()
invalidateCameraCache()
stat |= BROKEN
kick_viewers()
triggerCameraAlarm()
@@ -232,6 +238,7 @@
/obj/machinery/camera/proc/set_status(var/newstatus)
if (status != newstatus)
status = newstatus
invalidateCameraCache()
// now disconnect anyone using the camera
//Apparently, this will disconnect anyone even if the camera was re-activated.
//I guess that doesn't matter since they couldn't use it anyway?

View File

@@ -1,5 +1,8 @@
//This file was auto-corrected by findeclaration.exe on 25.5.2012 20:42:31
/proc/invalidateCameraCache()
for(var/obj/machinery/computer/security/s in world)
s.camera_cache = null
/obj/machinery/computer/security
name = "security camera monitor"
@@ -10,6 +13,7 @@
var/list/network = list("SS13")
var/mapping = 0//For the overview file, interesting bit of code.
circuit = /obj/item/weapon/circuitboard/security
var/camera_cache = null
attack_ai(var/mob/user as mob)
@@ -32,29 +36,46 @@
data["current"] = null
var/list/L = list()
for (var/obj/machinery/camera/C in cameranet.cameras)
if(can_access_camera(C))
L.Add(C)
if(isnull(camera_cache))
var/list/L = list()
for (var/obj/machinery/camera/C in cameranet.cameras)
if(can_access_camera(C))
L.Add(C)
camera_sort(L)
camera_sort(L)
var/cameras[0]
for(var/obj/machinery/camera/C in L)
var/cam[0]
cam["name"] = C.c_tag
cam["deact"] = !C.can_use()
cam["camera"] = "\ref[C]"
cam["x"] = C.x
cam["y"] = C.y
cam["z"] = C.z
var/cameras[0]
for(var/obj/machinery/camera/C in L)
var/cam[0]
cam["name"] = C.c_tag
cam["deact"] = !C.can_use()
cam["camera"] = "\ref[C]"
cam["x"] = C.x
cam["y"] = C.y
cam["z"] = C.z
cameras[++cameras.len] = cam
cameras[++cameras.len] = cam
if(C == current)
data["current"] = cam
var/list/camera_list = list("cameras" = cameras)
camera_cache=list2json(camera_list)
else
if(current)
var/cam[0]
cam["name"] = current.c_tag
cam["deact"] = !current.can_use()
cam["camera"] = "\ref[current]"
cam["x"] = current.x
cam["y"] = current.y
cam["z"] = current.z
if(C == current)
data["current"] = cam
data["cameras"] = cameras
if(ui)
ui.load_cached_data(camera_cache)
ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui)
@@ -65,6 +86,7 @@
// adding a template with the key "mapHeader" replaces the map header content
ui.add_template("mapHeader", "sec_camera_map_header.tmpl")
ui.load_cached_data(camera_cache)
ui.set_initial_data(data)
ui.open()
ui.set_auto_update(1)