From 8b224ea275ada96fe7cfdb4623756ea7c52c6dd8 Mon Sep 17 00:00:00 2001 From: forest2001 Date: Fri, 12 Jan 2024 09:18:11 +0000 Subject: [PATCH 1/2] x --- code/game/machinery/camera/camera.dm | 17 +++++++++++++++++ code/game/machinery/camera/presets.dm | 16 +--------------- 2 files changed, 18 insertions(+), 15 deletions(-) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 1a440d41bbed..1bfc7710d53b 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -38,6 +38,10 @@ /// If this camera should have innate EMP-proofing var/emp_proof = FALSE + ///Autonaming + var/autoname = FALSE + var/autonumber = 0 //camera number in area + /obj/structure/machinery/camera/Initialize(mapload, ...) . = ..() WireColorToFlag = randomCameraWires() @@ -58,6 +62,19 @@ set_pixel_location() update_icon() + //This camera automatically sets it's name to whatever the area that it's in is called. + if(autoname) + autonumber = 1 + var/area/A = get_area(src) + if(A) + for(var/obj/structure/machinery/camera/autoname/C in GLOB.machines) + if(C == src) continue + var/area/CA = get_area(C) + if(CA.type == A.type) + if(C.autonumber) + autonumber = max(autonumber, C.autonumber+1) + c_tag = "[A.name] #[autonumber]" + /obj/structure/machinery/camera/Destroy() . = ..() QDEL_NULL(assembly) diff --git a/code/game/machinery/camera/presets.dm b/code/game/machinery/camera/presets.dm index 1f680ad76712..103e3f709afe 100644 --- a/code/game/machinery/camera/presets.dm +++ b/code/game/machinery/camera/presets.dm @@ -70,21 +70,7 @@ // AUTONAME /obj/structure/machinery/camera/autoname - var/number = 0 //camera number in area - -//This camera type automatically sets it's name to whatever the area that it's in is called. -/obj/structure/machinery/camera/autoname/Initialize(mapload, ...) - . = ..() - number = 1 - var/area/A = get_area(src) - if(A) - for(var/obj/structure/machinery/camera/autoname/C in GLOB.machines) - if(C == src) continue - var/area/CA = get_area(C) - if(CA.type == A.type) - if(C.number) - number = max(number, C.number+1) - c_tag = "[A.name] #[number]" + autoname = TRUE //cameras installed inside the dropships, accessible via both cockpit monitor and Almayer camera computers /obj/structure/machinery/camera/autoname/almayer/dropship_one From 22bd62789668384621a91088351568f7b9c7112f Mon Sep 17 00:00:00 2001 From: forest2001 <41653574+realforest2001@users.noreply.github.com> Date: Mon, 22 Jan 2024 11:31:46 +0000 Subject: [PATCH 2/2] Apply suggestions from code review Co-authored-by: harryob --- code/game/machinery/camera/camera.dm | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/code/game/machinery/camera/camera.dm b/code/game/machinery/camera/camera.dm index 4155520f0452..d8919967dd65 100644 --- a/code/game/machinery/camera/camera.dm +++ b/code/game/machinery/camera/camera.dm @@ -67,15 +67,20 @@ GLOBAL_LIST_EMPTY_TYPED(all_cameras, /obj/structure/machinery/camera) //This camera automatically sets it's name to whatever the area that it's in is called. if(autoname) autonumber = 1 - var/area/A = get_area(src) - if(A) - for(var/obj/structure/machinery/camera/autoname/C in GLOB.machines) - if(C == src) continue - var/area/CA = get_area(C) - if(CA.type == A.type) - if(C.autonumber) - autonumber = max(autonumber, C.autonumber+1) - c_tag = "[A.name] #[autonumber]" + var/area/my_area = get_area(src) + if(my_area) + for(var/obj/structure/machinery/camera/autoname/current_camera in GLOB.machines) + if(current_camera == src) + continue + var/area/current_camera_area = get_area(current_camera) + if(current_camera_area.type != my_area.type) + continue + + if(!current_camera.autonumber) + continue + + autonumber = max(autonumber, current_camera.autonumber + 1) + c_tag = "[my_area.name] #[autonumber]" /obj/structure/machinery/camera/Destroy() GLOB.all_cameras -= src