From 0d3c813c679ed504673ae17f36afc79b1586f2bf Mon Sep 17 00:00:00 2001 From: MichiRecRoom <1008889+LikeLakers2@users.noreply.github.com> Date: Sat, 8 Feb 2025 18:19:53 -0500 Subject: [PATCH] [NO GBP] Fix-up a line I missed during refactoring in my `icon_exists` optimization PR (#89374) ## About The Pull Request While porting https://github.com/tgstation/tgstation/pull/89357 over to monkestation, I found that I missed refactoring a couple lines in `code\modules\asset_cache\assets\vending.dm`. This PR fixes that. The changed code is all behind `if (PERFORM_ALL_TESTS(focus_only/invalid_vending_machine_icon_states))`. This means the changed code will only be executed if unit tests are enabled *and* `invalid_vending_machine_icon_states` is a test that will be run. Despite that, I feel this code may be marginally faster, as the use of `icon_states()` is now behind `!icon_exists()`. ## Why It's Good For The Game Gotta go ever so slightly faster. --- code/__HELPERS/lighting.dm | 2 +- code/modules/asset_cache/assets/vending.dm | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/code/__HELPERS/lighting.dm b/code/__HELPERS/lighting.dm index a3d3522ebff..da6f4d1cee2 100644 --- a/code/__HELPERS/lighting.dm +++ b/code/__HELPERS/lighting.dm @@ -9,7 +9,7 @@ //Test to make sure emissives with broken or missing icon states are created if(PERFORM_ALL_TESTS(focus_only/invalid_emissives)) - if(icon_state && !icon_exists(icon, icon_state)) //Scream set to False so we can have a custom stack_trace + if(icon_state && !icon_exists(icon, icon_state)) stack_trace("An emissive appearance was added with non-existant icon_state \"[icon_state]\" in [icon]!") return appearance diff --git a/code/modules/asset_cache/assets/vending.dm b/code/modules/asset_cache/assets/vending.dm index caec9bb4f82..c898cc3eddc 100644 --- a/code/modules/asset_cache/assets/vending.dm +++ b/code/modules/asset_cache/assets/vending.dm @@ -30,10 +30,9 @@ continue if (PERFORM_ALL_TESTS(focus_only/invalid_vending_machine_icon_states)) - var/icon_states_list = icon_states(icon_file) - if (!(icon_state in icon_states_list)) + if (!icon_exists(icon_file, icon_state)) var/icon_states_string - for (var/an_icon_state in icon_states_list) + for (var/an_icon_state in icon_states(icon_file)) if (!icon_states_string) icon_states_string = "[json_encode(an_icon_state)]([text_ref(an_icon_state)])" else