Optimize cardboard cutouts saving 1.5s+ on init times (#73404)

New regression in init times. Closes
https://github.com/tgstation/dev-cycles-initiative/issues/32. CC @Fikou

- Instead of creating a human and icon for *every* cardboard cutout when
initialized, only creates the one we're actually using. When you're
about to use a crayon, creates all of them.
- Instead of using getFlatIcon, uses appearances directly.
This commit is contained in:
Mothblocks
2023-02-18 22:58:35 -07:00
committed by GitHub
parent 1191bce9b0
commit 09cfba5feb
23 changed files with 124 additions and 74 deletions
+1
View File
@@ -91,6 +91,7 @@
#include "breath.dm"
#include "cable_powernets.dm"
#include "card_mismatch.dm"
#include "cardboard_cutouts.dm"
#include "chain_pull_through_space.dm"
#include "chat_filter.dm"
#include "circuit_component_category.dm"
@@ -0,0 +1,27 @@
/// Validates that cardboard cutouts have the proper icons
/datum/unit_test/cardboard_cutouts
/datum/unit_test/cardboard_cutouts/Run()
var/obj/item/cardboard_cutout/normal_cutout = new
test_screenshot("normal_cutout", getFlatIcon(normal_cutout))
var/obj/item/cardboard_cutout/nuclear_operative/nukie_cutout = new
test_screenshot("nukie_cutout", getFlatIcon(nukie_cutout))
nukie_cutout.push_over()
test_screenshot("nukie_cutout_pushed", getFlatIcon(nukie_cutout))
#if DM_VERSION >= 515
// This is the only reason we're testing xenomorphs.
// Making a custom subtype with direct_icon is hacky.
ASSERT(!isnull(/datum/cardboard_cutout/xenomorph_maid::direct_icon))
#endif
var/obj/item/cardboard_cutout/xenomorph/xenomorph_cutout = new
test_screenshot("xenomorph_cutout", getFlatIcon(xenomorph_cutout))
/obj/item/cardboard_cutout/nuclear_operative
starting_cutout = "Nuclear Operative"
/obj/item/cardboard_cutout/xenomorph
starting_cutout = "Xenomorph"
@@ -3,5 +3,5 @@
/datum/unit_test/screenshot_dynamic_human_icons/Run()
// Complicated MODsuit setup
var/icon/icon = get_dynamic_human_icon(/datum/outfit/syndicatecommandocorpse)
test_screenshot("syndicate_commando", icon)
var/appearance = get_dynamic_human_appearance(/datum/outfit/syndicatecommandocorpse)
test_screenshot("syndicate_commando", get_flat_icon_for_all_directions(appearance))
Binary file not shown.

After

Width:  |  Height:  |  Size: 319 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 575 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 229 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 458 B