Moves camera update handling to background subsystem, (maybe) fixing lag (#92208)

## About The Pull Request

When a camera update is triggered, it is instead added to a queue on a
background subsystem

An AI entering a camera chunk which is queued to update will force the
update immediately (bypassing the queue)

While the root problem of this is, ultimately, not addressed...

<img width="554" height="58"
alt="467828777-eff3f0e5-49d6-4997-b4d7-05eff6432155"
src="https://github.com/user-attachments/assets/c2d6a5f5-d958-463e-959f-116bd0dab475"
/>

...the change will ultimately prevent update spam from consuming all of
the server's resources - instead allocating updates to the backburner in
times of high server stress (or on multi-z maps)

## Changelog

🆑 Melbert
refactor: Refactored the way camera updates are handled to hopefully
reduce some lag. Report any oddities
/🆑
This commit is contained in:
MrMelbert
2025-11-07 18:43:48 -06:00
committed by GitHub
parent ad7887064e
commit 5146cfd403
42 changed files with 472 additions and 426 deletions
@@ -129,7 +129,7 @@
data["network"] = network
data["mapRef"] = cam_screen.assigned_map
data["can_spy"] = !!spying
data["cameras"] = GLOB.cameranet.get_available_cameras_data(network)
data["cameras"] = SScameras.get_available_cameras_data(network)
return data
/datum/computer_file/program/secureye/ui_act(action, params, datum/tgui/ui, datum/ui_state/state)
@@ -145,7 +145,7 @@
if(!spying)
playsound(computer, SFX_TERMINAL_TYPE, 25, FALSE)
var/obj/machinery/camera/selected_camera = locate(params["camera"]) in GLOB.cameranet.cameras
var/obj/machinery/camera/selected_camera = locate(params["camera"]) in SScameras.cameras
if(selected_camera)
camera_ref = WEAKREF(selected_camera)
else
@@ -168,12 +168,13 @@
/datum/computer_file/program/secureye/proc/on_track_target(datum/trackable/source, mob/living/target)
SIGNAL_HANDLER
var/datum/camerachunk/target_camerachunk = GLOB.cameranet.getTurfVis(get_turf(target))
var/target_turf = get_turf(target)
var/datum/camerachunk/target_camerachunk = SScameras.get_turf_camera_chunk(target_turf)
if(!target_camerachunk)
CRASH("[src] was able to track [target] through /datum/trackable, but was not on a visible turf to cameras.")
for(var/obj/machinery/camera/cameras as anything in target_camerachunk.cameras["[target.z]"])
var/found_target = locate(target) in cameras.can_see()
if(!found_target)
for(var/obj/machinery/camera/cameras as anything in target_camerachunk.cameras[target.z])
// We need to find a particular camera that can see this turf
if(!(target_turf in cameras.can_see()))
continue
var/new_camera = WEAKREF(cameras)
if(camera_ref == new_camera)