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) wires = new(src)
assembly = new(src) assembly = new(src)
assembly.state = 4 assembly.state = 4
invalidateCameraCache()
/* // Use this to look for cameras that have the same c_tag. /* // Use this to look for cameras that have the same c_tag.
for(var/obj/machinery/camera/C in cameranet.cameras) for(var/obj/machinery/camera/C in cameranet.cameras)
var/list/tempnetwork = C.network&src.network var/list/tempnetwork = C.network&src.network
@@ -61,6 +64,7 @@
/obj/machinery/camera/emp_act(severity) /obj/machinery/camera/emp_act(severity)
if(!isEmpProof()) if(!isEmpProof())
if(prob(100/severity)) if(prob(100/severity))
invalidateCameraCache()
stat |= EMPED stat |= EMPED
SetLuminosity(0) SetLuminosity(0)
kick_viewers() kick_viewers()
@@ -71,7 +75,7 @@
stat &= ~EMPED stat &= ~EMPED
cancelCameraAlarm() cancelCameraAlarm()
update_icon() update_icon()
invalidateCameraCache()
..() ..()
/obj/machinery/camera/bullet_act(var/obj/item/projectile/P) /obj/machinery/camera/bullet_act(var/obj/item/projectile/P)
@@ -118,7 +122,7 @@
destroy() destroy()
/obj/machinery/camera/attackby(obj/W as obj, mob/living/user as mob) /obj/machinery/camera/attackby(obj/W as obj, mob/living/user as mob)
invalidateCameraCache()
// DECONSTRUCTION // DECONSTRUCTION
if(isscrewdriver(W)) if(isscrewdriver(W))
//user << "<span class='notice'>You start to [panel_open ? "close" : "open"] the camera's panel.</span>" //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 //legacy support, if choice is != 1 then just kick viewers without changing status
kick_viewers() kick_viewers()
else else
invalidateCameraCache()
set_status( !src.status ) set_status( !src.status )
if (!(src.status)) if (!(src.status))
visible_message("\red [user] has deactivated [src]!") visible_message("\red [user] has deactivated [src]!")
@@ -218,6 +223,7 @@
//Used when someone breaks a camera //Used when someone breaks a camera
/obj/machinery/camera/proc/destroy() /obj/machinery/camera/proc/destroy()
invalidateCameraCache()
stat |= BROKEN stat |= BROKEN
kick_viewers() kick_viewers()
triggerCameraAlarm() triggerCameraAlarm()
@@ -232,6 +238,7 @@
/obj/machinery/camera/proc/set_status(var/newstatus) /obj/machinery/camera/proc/set_status(var/newstatus)
if (status != newstatus) if (status != newstatus)
status = newstatus status = newstatus
invalidateCameraCache()
// now disconnect anyone using the camera // now disconnect anyone using the camera
//Apparently, this will disconnect anyone even if the camera was re-activated. //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? //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 //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 /obj/machinery/computer/security
name = "security camera monitor" name = "security camera monitor"
@@ -10,6 +13,7 @@
var/list/network = list("SS13") var/list/network = list("SS13")
var/mapping = 0//For the overview file, interesting bit of code. var/mapping = 0//For the overview file, interesting bit of code.
circuit = /obj/item/weapon/circuitboard/security circuit = /obj/item/weapon/circuitboard/security
var/camera_cache = null
attack_ai(var/mob/user as mob) attack_ai(var/mob/user as mob)
@@ -32,29 +36,46 @@
data["current"] = null data["current"] = null
var/list/L = list() if(isnull(camera_cache))
for (var/obj/machinery/camera/C in cameranet.cameras) var/list/L = list()
if(can_access_camera(C)) for (var/obj/machinery/camera/C in cameranet.cameras)
L.Add(C) 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] cameras[++cameras.len] = cam
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 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["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) ui = nanomanager.try_update_ui(user, src, ui_key, ui, data, force_open)
if (!ui) if (!ui)
@@ -65,6 +86,7 @@
// adding a template with the key "mapHeader" replaces the map header content // adding a template with the key "mapHeader" replaces the map header content
ui.add_template("mapHeader", "sec_camera_map_header.tmpl") ui.add_template("mapHeader", "sec_camera_map_header.tmpl")
ui.load_cached_data(camera_cache)
ui.set_initial_data(data) ui.set_initial_data(data)
ui.open() ui.open()
ui.set_auto_update(1) ui.set_auto_update(1)

View File

@@ -12,7 +12,7 @@ Used In File(s): \code\game\machinery\computer\camera.dm
<div class='itemContent'>None</div> <div class='itemContent'>None</div>
{{/if}} {{/if}}
</div> </div>
{{for data.cameras}} {{for data.cached.cameras}}
{{if data.current && value.name == data.current.name}} {{if data.current && value.name == data.current.name}}
{{:helper.link(value.name, '', {'switchTo' : value.camera}, 'selected')}} {{:helper.link(value.name, '', {'switchTo' : value.camera}, 'selected')}}
{{else value.deact}} {{else value.deact}}
@@ -20,4 +20,4 @@ Used In File(s): \code\game\machinery\computer\camera.dm
{{else}} {{else}}
{{:helper.link(value.name, '', {'switchTo' : value.camera})}} {{:helper.link(value.name, '', {'switchTo' : value.camera})}}
{{/if}} {{/if}}
{{/for}} {{/for}}

View File

@@ -2,7 +2,7 @@
Title: Security Camera Console (Map content) Title: Security Camera Console (Map content)
Used In File(s): \code\game\machinery\computer\camera.dm Used In File(s): \code\game\machinery\computer\camera.dm
--> -->
{{for data.cameras}} {{for data.cached.cameras}}
{{if value.z == 1}} {{if value.z == 1}}
<div class="mapIcon mapIcon16" style="left: {{:(value.x)}}px; bottom: {{:(value.y - 1)}}px;"> <div class="mapIcon mapIcon16" style="left: {{:(value.x)}}px; bottom: {{:(value.y - 1)}}px;">
{{if data.current && value.name == data.current.name}} {{if data.current && value.name == data.current.name}}
@@ -17,4 +17,4 @@ Used In File(s): \code\game\machinery\computer\camera.dm
</div> </div>
</div> </div>
{{/if}} {{/if}}
{{/for}} {{/for}}