diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 8fe3387467..d631ca46df 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -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 << "You start to [panel_open ? "close" : "open"] the camera's panel." @@ -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? diff --git a/code/game/machinery/computer/camera.dm b/code/game/machinery/computer/camera.dm index 0a7f27d701..7ffd7d1599 100644 --- a/code/game/machinery/computer/camera.dm +++ b/code/game/machinery/computer/camera.dm @@ -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) diff --git a/nano/templates/sec_camera.tmpl b/nano/templates/sec_camera.tmpl index ea18fb2047..886cb0f87c 100644 --- a/nano/templates/sec_camera.tmpl +++ b/nano/templates/sec_camera.tmpl @@ -12,7 +12,7 @@ Used In File(s): \code\game\machinery\computer\camera.dm
None
{{/if}} -{{for data.cameras}} +{{for data.cached.cameras}} {{if data.current && value.name == data.current.name}} {{:helper.link(value.name, '', {'switchTo' : value.camera}, 'selected')}} {{else value.deact}} @@ -20,4 +20,4 @@ Used In File(s): \code\game\machinery\computer\camera.dm {{else}} {{:helper.link(value.name, '', {'switchTo' : value.camera})}} {{/if}} -{{/for}} \ No newline at end of file +{{/for}} diff --git a/nano/templates/sec_camera_map_content.tmpl b/nano/templates/sec_camera_map_content.tmpl index 52dc8aeadd..55d9e05d4d 100644 --- a/nano/templates/sec_camera_map_content.tmpl +++ b/nano/templates/sec_camera_map_content.tmpl @@ -2,7 +2,7 @@ Title: Security Camera Console (Map content) Used In File(s): \code\game\machinery\computer\camera.dm --> -{{for data.cameras}} +{{for data.cached.cameras}} {{if value.z == 1}}
{{if data.current && value.name == data.current.name}} @@ -17,4 +17,4 @@ Used In File(s): \code\game\machinery\computer\camera.dm
{{/if}} -{{/for}} \ No newline at end of file +{{/for}}