From f1f9d604dc948e2fc68ceba1c2590cfb189b611e Mon Sep 17 00:00:00 2001 From: Tad Hardesty Date: Sat, 3 Aug 2019 13:28:29 -0700 Subject: [PATCH] Remove atom creation in vending machine icon generation --- code/game/objects/items/cigs_lighters.dm | 11 +++++----- code/modules/client/asset_cache.dm | 24 ++++++++-------------- code/modules/clothing/head/misc_special.dm | 23 ++++++++++----------- 3 files changed, 25 insertions(+), 33 deletions(-) diff --git a/code/game/objects/items/cigs_lighters.dm b/code/game/objects/items/cigs_lighters.dm index cd15b76868a..fc6de859274 100644 --- a/code/game/objects/items/cigs_lighters.dm +++ b/code/game/objects/items/cigs_lighters.dm @@ -747,7 +747,7 @@ CIGARETTE PACKETS ARE IN FANCY.DM name = "\improper E-Cigarette" desc = "A classy and highly sophisticated electronic cigarette, for classy and dignified gentlemen. A warning label reads \"Warning: Do not fill with flammable materials.\""//<<< i'd vape to that. icon = 'icons/obj/clothing/masks.dmi' - icon_state = null + icon_state = "red_vape" item_state = null w_class = WEIGHT_CLASS_TINY var/chem_volume = 100 @@ -764,11 +764,10 @@ CIGARETTE PACKETS ARE IN FANCY.DM . = ..() create_reagents(chem_volume, NO_REACT) reagents.add_reagent(/datum/reagent/drug/nicotine, 50) - if(!icon_state) - if(!param_color) - param_color = pick("red","blue","black","white","green","purple","yellow","orange") - icon_state = "[param_color]_vape" - item_state = "[param_color]_vape" + if(!param_color) + param_color = pick("red","blue","black","white","green","purple","yellow","orange") + icon_state = "[param_color]_vape" + item_state = "[param_color]_vape" /obj/item/clothing/mask/vape/attackby(obj/item/O, mob/user, params) if(O.tool_behaviour == TOOL_SCREWDRIVER) diff --git a/code/modules/client/asset_cache.dm b/code/modules/client/asset_cache.dm index 47b5ee1d769..3a218672b23 100644 --- a/code/modules/client/asset_cache.dm +++ b/code/modules/client/asset_cache.dm @@ -676,28 +676,22 @@ GLOBAL_LIST_EMPTY(asset_datums) /datum/asset/spritesheet/vending/register() for (var/k in GLOB.vending_products) var/atom/item = k - - - var/icon_file - var/icon_state - var/icon/I - - if (!ispath(item, /atom)) continue - icon_file = initial(item.icon) - icon_state = initial(item.icon_state) + var/icon_file = initial(item.icon) + var/icon_state = initial(item.icon_state) + var/icon/I - if(icon_state in icon_states(icon_file)) + var/icon_states_list = icon_states(icon_file) + if(icon_state in icon_states_list) I = icon(icon_file, icon_state, SOUTH) var/c = initial(item.color) if (!isnull(c) && c != "#FFFFFF") - I.Blend(initial(c), ICON_MULTIPLY) + I.Blend(c, ICON_MULTIPLY) else - item = new item() - I = icon(item.icon, item.icon_state, SOUTH) - qdel(item) + stack_trace("[item] does not have a valid icon state, icon=[icon_file], icon_state=[json_encode(icon_state)], icon_states=[json_encode(icon_states_list)]") + I = icon('icons/turf/floors.dmi', "", SOUTH) var/imgid = replacetext(replacetext("[item]", "/obj/item/", ""), "/", "-") @@ -709,4 +703,4 @@ GLOBAL_LIST_EMPTY(asset_datums) "dna_discovered.png" = 'html/dna_discovered.png', "dna_undiscovered.png" = 'html/dna_undiscovered.png', "dna_extra.png" = 'html/dna_extra.png' -) + ) diff --git a/code/modules/clothing/head/misc_special.dm b/code/modules/clothing/head/misc_special.dm index d1d99826545..850ddaccad1 100644 --- a/code/modules/clothing/head/misc_special.dm +++ b/code/modules/clothing/head/misc_special.dm @@ -187,11 +187,12 @@ /obj/item/clothing/head/wig name = "wig" desc = "A bunch of hair without a head attached." - icon_state = "" + icon = 'icons/mob/human_face.dmi' // default icon for all hairs + icon_state = "hair_vlong" item_state = "pwig" flags_inv = HIDEHAIR + color = "#000" var/hair_style = "Very Long Hair" - var/hair_color = "#000" var/adjustablecolor = TRUE //can color be changed manually? /obj/item/clothing/head/wig/Initialize(mapload) @@ -199,15 +200,13 @@ update_icon() /obj/item/clothing/head/wig/update_icon() - cut_overlays() var/datum/sprite_accessory/S = GLOB.hair_styles_list[hair_style] if(!S) + icon = 'icons/obj/clothing/hats.dmi' icon_state = "pwig" else - var/mutable_appearance/M = mutable_appearance(S.icon,S.icon_state) - M.appearance_flags |= RESET_COLOR - M.color = hair_color - add_overlay(M) + icon = S.icon + icon_state = S.icon_state /obj/item/clothing/head/wig/worn_overlays(isinhands = FALSE, file2use) . = list() @@ -217,7 +216,7 @@ return var/mutable_appearance/M = mutable_appearance(S.icon, S.icon_state,layer = -HAIR_LAYER) M.appearance_flags |= RESET_COLOR - M.color = hair_color + M.color = color . += M /obj/item/clothing/head/wig/attack_self(mob/user) @@ -228,18 +227,18 @@ hair_style = new_style user.visible_message("[user] changes \the [src]'s hairstyle to [new_style].", "You change \the [src]'s hairstyle to [new_style].") if(adjustablecolor) - hair_color = input(usr,"","Choose Color",hair_color) as color|null + color = input(usr,"","Choose Color",color) as color|null update_icon() /obj/item/clothing/head/wig/random/Initialize(mapload) hair_style = pick(GLOB.hair_styles_list - "Bald") //Don't want invisible wig - hair_color = "#[random_short_color()]" + color = "#[random_short_color()]" . = ..() /obj/item/clothing/head/wig/natural name = "natural wig" desc = "A bunch of hair without a head attached. This one changes color to match the hair of the wearer. Nothing natural about that." - hair_color = "#FFF" + color = "#FFF" adjustablecolor = FALSE custom_price = 25 @@ -249,7 +248,7 @@ /obj/item/clothing/head/wig/natural/equipped(mob/living/carbon/human/user, slot) if(ishuman(user) && slot == SLOT_HEAD) - hair_color = "#[user.hair_color]" + color = "#[user.hair_color]" update_icon() user.update_inv_head()