From e5a3a6bb8119c9dd02d2f830c4230c896edcf9cd Mon Sep 17 00:00:00 2001 From: _0Steven <42909981+00-Steven@users.noreply.github.com> Date: Thu, 23 May 2024 07:13:05 +0200 Subject: [PATCH] Fix smoker quirk preferences (#83378) ## About The Pull Request So the smoker quirk would always reset back to "Random" whichever preferences you selected, just in the menu. Looking into why this was happening, it seemed to be failing at the point where it deserializes and sanitizes your selected value, specifically at the point where it'd compare it to the list of possible preferences. This seemed to be because the value it got back from tgui had removed the `\improper` text macro, while the value in the list was saved with that text macro. It's not actually useful here, so we remove it using `format_text(...)` when setting up the list, and this makes it work again. We also split it off from the previous used proc used for setting up the list: ```dm /proc/setup_junkie_addictions(list/possible_addictions) . = possible_addictions for(var/datum/reagent/addiction as anything in .) . -= addiction .[addiction::name] = addiction ``` Because the smoker list doesn't actually use reagents. I'm surprised this successfully got the name values for the non-reagents in the first place. ## Why It's Good For The Game Fixes #83277. Fixes #82538. ## Changelog :cl: fix: Smoker quirk users can select a favourite brand again. /:cl: --- code/_globalvars/lists/quirks.dm | 2 +- code/modules/client/preferences/addict.dm | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/code/_globalvars/lists/quirks.dm b/code/_globalvars/lists/quirks.dm index 4ce15f2e09e..882e556a801 100644 --- a/code/_globalvars/lists/quirks.dm +++ b/code/_globalvars/lists/quirks.dm @@ -45,7 +45,7 @@ GLOBAL_LIST_INIT(possible_junkie_addictions, setup_junkie_addictions(list( ))) ///Options for the Smoker quirk to choose from -GLOBAL_LIST_INIT(possible_smoker_addictions, setup_junkie_addictions(list( +GLOBAL_LIST_INIT(possible_smoker_addictions, setup_smoker_addictions(list( /obj/item/storage/fancy/cigarettes, /obj/item/storage/fancy/cigarettes/cigpack_midori, /obj/item/storage/fancy/cigarettes/cigpack_uplift, diff --git a/code/modules/client/preferences/addict.dm b/code/modules/client/preferences/addict.dm index 3c63b5ea867..8d70a6ccbfa 100644 --- a/code/modules/client/preferences/addict.dm +++ b/code/modules/client/preferences/addict.dm @@ -4,6 +4,12 @@ . -= addiction .[addiction::name] = addiction +/proc/setup_smoker_addictions(list/possible_addictions) + . = possible_addictions + for(var/obj/item/storage/addiction as anything in .) + . -= addiction + .[format_text(addiction::name)] = addiction // Format text to remove \improper used in cigarette packs + /datum/preference/choiced/junkie category = PREFERENCE_CATEGORY_MANUALLY_RENDERED savefile_key = "junkie"