Skip to content

Commit

Permalink
Fix vending_products register continue check (#4962)
Browse files Browse the repository at this point in the history
# About the pull request

This PR cherry picks cmss13-devs/cmss13-pve#68
but removes the extra logging. That PR was attempting to resolve server
hitching, but the hitching seems to have gone away with it and a TGS
update.

I am not currently able to discern any noticeable differences from this
change, however the change looks correct for the continue check to ever
work correctly. See Testing Notes below.

Let me know if you do find a change this does improve, or maybe
somewhere else we should expect superfluous calls to getFlatIcon.

# Explain why it's good for the game

The continue check as written looks like it would never work, whereas
now the string that will be used for inserting into the list sprites is
the same string we check before creating new icons.

# Testing Photographs and Procedure
<details>
<summary>Testing Notes</summary>

Debugging only:

Lobby (LV-624): 
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.124 total cpu)

Game Start: 
No changes

After opening CO vendors and cig vendor:
No changes

Alt+click self:
77 getFlatIcon calls (.353 total cpu)

Alt+click self again:
No changes

-----

After continue change:

Lobby (LV-624): 
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.117 total cpu)

Game Start: 
No changes

After opening CO vendors and cig vendor:
No changes

Alt+click self:
77 getFlatIcon calls (.346 total cpu)

Alt+click self again:
No changes

------

Debugging only w/ SVN:

Lobby (LV-624): 
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.124 total cpu)

Game Start: 
No changes

After opening CO vendors and cig vendor:
a GET was performed for first CO vendor and first cig vendor opened
(never again)

Alt+click self:
77 getFlatIcon calls (.351 total cpu)
A GET is performed for every item listed

Alt+click self again:
A GET is performed for every item listed

-----

After continue change w/ SVN:

Lobby (LV-624): 
One event of registering (master -> init Assets -> vending_products)
55 getFlatIcon calls (.120 total cpu)

Game Start: 
No changes

After opening CO vendors and cig vendor:
a GET was performed for first CO vendor and first cig vendor opened
(never again)

Alt+click self:
77 getFlatIcon calls (.347 total cpu)
A GET is performed for every item listed

Alt+click self again:
A GET is performed for every item listed

</details>


# Changelog
:cl: Morrow
code: Corrected a check to avoid repeat work in
/datum/asset/spritesheet/vending_products/register()
/:cl:

---------

Co-authored-by: Morrow <[email protected]>
  • Loading branch information
Drulikar and morrowwolf committed Dec 1, 2023
1 parent 08f28b6 commit 0772939
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions code/modules/asset_cache/asset_list_items.dm
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,9 @@
log_debug("not atom! [item]")
continue

if (sprites[icon_file])
var/imgid = replacetext(replacetext("[k]", "/obj/item/", ""), "/", "-")

if(sprites[imgid])
continue

if(icon_state in icon_states(icon_file))
Expand All @@ -339,7 +341,6 @@
item = new k()
I = icon(item.icon, item.icon_state, SOUTH)
qdel(item)
var/imgid = replacetext(replacetext("[k]", "/obj/item/", ""), "/", "-")

Insert(imgid, I)
return ..()
Expand Down

0 comments on commit 0772939

Please sign in to comment.