Skip to content

Commit

Permalink
camera/autoname/LateInitialize() optimization (#3001)
Browse files Browse the repository at this point in the history
<!-- Write **BELOW** The Headers and **ABOVE** The comments else it may
not be viewable. -->
<!-- You can view Contributing.MD for a detailed description of the pull
request process. -->

## About The Pull Request
copys tgstation/tgstation#70969 
<!-- Describe The Pull Request. Please be sure every change is
documented or this can delay review and even discourage maintainers from
merging your PR! -->

## Why It's Good For The Game
I noticed we search glob.machines for every autoname camera which cannot
be better then a static list
<!-- Please add a short description of why you think these changes would
benefit the game. If you can't justify it in words, it might not be
worth adding. -->

## Changelog

:cl:
code: camera/autoname/LateInitialize() optimization
/:cl:

<!-- Both :cl:'s are required for the changelog to work! You can put
your name to the right of the first :cl: if you want to overwrite your
GitHub username as author ingame. -->
<!-- You can use multiple of the same prefix (they're only used for the
icon ingame) and delete the unneeded ones. Despite some of the tags,
changelogs should generally represent how a player might be affected by
the changes rather than a summary of the PR's contents. -->
  • Loading branch information
FalloutFalcon authored Jun 2, 2024
1 parent 55874dc commit 2395e99
Showing 1 changed file with 5 additions and 12 deletions.
17 changes: 5 additions & 12 deletions code/game/machinery/camera/presets.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,18 +56,11 @@

/obj/machinery/camera/autoname/LateInitialize()
. = ..()
number = 1
var/area/A = get_area(src)
if(A)
for(var/obj/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]"

var/static/list/autonames_in_areas = list()
var/area/camera_area = get_area(src)
number = autonames_in_areas[camera_area] + 1
autonames_in_areas[camera_area] = number
c_tag = "[format_text(camera_area.name)] #[number]"

// UPGRADE PROCS

Expand Down

0 comments on commit 2395e99

Please sign in to comment.