[MIRROR] Camera consoles no longer constantly check camera list [MDB IGNORE] (#24185)

* Camera consoles no longer constantly check camera list (#78822)

## About The Pull Request

I would like camera sorting to be handled without having to constantly
get the entire list of cameras and sorting itself, but this occasion it
isn't even necessary, and was only added because I wanted to keep it
consistent with old behavior. This wasn't the best idea, and this is
trying to make amends with that.

Instead of getting the entire list of cameras when swapping cameras, it
instead gets that specific camera from the list and sets your active
camera to that. To do so, camera consoles now have a ref to the camera,
rather than going by name alone.

## Why It's Good For The Game

Explained in the about section mostly, we're no longer checking through
and sorting the entire list of cameras every single time you swap from
one camera to another.

## Changelog

Nothing player-facing.

* Camera consoles no longer constantly check camera list

---------

Co-authored-by: John Willard <53777086+JohnFulpWillard@users.noreply.github.com>
This commit is contained in:
SkyratBot
2023-10-08 02:53:54 +02:00
committed by GitHub
parent c8486617af
commit 645a0031c1
3 changed files with 28 additions and 29 deletions
@@ -100,18 +100,19 @@
/datum/computer_file/program/secureye/ui_data()
var/list/data = list()
data["network"] = network
data["activeCamera"] = null
var/obj/machinery/camera/active_camera = camera_ref?.resolve()
if(active_camera)
data["activeCamera"] = list(
name = active_camera.c_tag,
ref = REF(active_camera),
status = active_camera.status,
)
return data
/datum/computer_file/program/secureye/ui_static_data(mob/user)
var/list/data = list()
data["network"] = network
data["mapRef"] = cam_screen.assigned_map
data["can_spy"] = !!spying
var/list/cameras = get_camera_list(network)
@@ -120,6 +121,7 @@
var/obj/machinery/camera/C = cameras[i]
data["cameras"] += list(list(
name = C.c_tag,
ref = REF(C),
))
return data
@@ -130,13 +132,14 @@
return
switch(action)
if("switch_camera")
var/c_tag = format_text(params["name"])
var/list/cameras = get_camera_list(network)
var/obj/machinery/camera/selected_camera = cameras[c_tag]
camera_ref = WEAKREF(selected_camera)
var/obj/machinery/camera/selected_camera = locate(params["camera"]) in GLOB.cameranet.cameras
if(selected_camera)
camera_ref = WEAKREF(selected_camera)
else
camera_ref = null
if(!spying)
playsound(computer, get_sfx(SFX_TERMINAL_TYPE), 25, FALSE)
if(!selected_camera)
if(isnull(camera_ref))
return TRUE
if(internal_tracker && internal_tracker.tracking)
internal_tracker.set_tracking(FALSE)