Files
Bubberstation/code/modules/client/preferences/addict.dm
_0Steven eb0df12ea5 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
🆑
fix: Smoker quirk users can select a favourite brand again.
/🆑
2024-05-23 01:15:57 -04:00

69 lines
2.2 KiB
Plaintext

/proc/setup_junkie_addictions(list/possible_addictions)
. = possible_addictions
for(var/datum/reagent/addiction as anything in .)
. -= 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"
savefile_identifier = PREFERENCE_CHARACTER
/datum/preference/choiced/junkie/init_possible_values()
return list("Random") + assoc_to_keys(GLOB.possible_junkie_addictions)
/datum/preference/choiced/junkie/create_default_value()
return "Random"
/datum/preference/choiced/junkie/is_accessible(datum/preferences/preferences)
if (!..())
return FALSE
return "Junkie" in preferences.all_quirks
/datum/preference/choiced/junkie/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/choiced/smoker
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "smoker"
savefile_identifier = PREFERENCE_CHARACTER
/datum/preference/choiced/smoker/init_possible_values()
return list("Random") + assoc_to_keys(GLOB.possible_smoker_addictions)
/datum/preference/choiced/smoker/create_default_value()
return "Random"
/datum/preference/choiced/smoker/is_accessible(datum/preferences/preferences)
if (!..())
return FALSE
return "Smoker" in preferences.all_quirks
/datum/preference/choiced/smoker/apply_to_human(mob/living/carbon/human/target, value)
return
/datum/preference/choiced/alcoholic
category = PREFERENCE_CATEGORY_MANUALLY_RENDERED
savefile_key = "alcoholic"
savefile_identifier = PREFERENCE_CHARACTER
/datum/preference/choiced/alcoholic/init_possible_values()
return list("Random") + assoc_to_keys(GLOB.possible_alcoholic_addictions)
/datum/preference/choiced/alcoholic/create_default_value()
return "Random"
/datum/preference/choiced/alcoholic/is_accessible(datum/preferences/preferences)
if (!..())
return FALSE
return "Alcoholic" in preferences.all_quirks
/datum/preference/choiced/alcoholic/apply_to_human(mob/living/carbon/human/target, value)
return