Skip to content

Commit

Permalink
Camera Autoname change (#5456)
Browse files Browse the repository at this point in the history
# About the pull request
Makes autonaming cameras happen based on a preset variable rather than
hardcode.
<!-- Remove this text and explain what the purpose of your PR is.

Mention if you have tested your changes. If you changed a map, make sure
you used the mapmerge tool.
If this is an Issue Correction, you can type "Fixes Issue #169420" to
link the PR to the corresponding Issue number #169420.

Remember: something that is self-evident to you might not be to others.
Explain your rationale fully, even if you feel it goes without saying.
-->

# Explain why it's good for the game
# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
code: Security camera autoname is now determined by a variable rather
than hardcode.
/:cl:

---------

Co-authored-by: harryob <[email protected]>
  • Loading branch information
realforest2001 and harryob committed Jan 28, 2024
1 parent 3c63057 commit e143889
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
22 changes: 22 additions & 0 deletions code/game/machinery/camera/camera.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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

GLOBAL_LIST_EMPTY_TYPED(all_cameras, /obj/structure/machinery/camera)
/obj/structure/machinery/camera/Initialize(mapload, ...)
. = ..()
Expand All @@ -60,6 +64,24 @@ GLOBAL_LIST_EMPTY_TYPED(all_cameras, /obj/structure/machinery/camera)
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/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
. = ..()
Expand Down
16 changes: 1 addition & 15 deletions code/game/machinery/camera/presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit e143889

Please sign in to comment.