diff --git a/code/modules/admin/verbs/anonymousnames.dm b/code/modules/admin/verbs/anonymousnames.dm index 6b049fe589e..2decae6ac38 100644 --- a/code/modules/admin/verbs/anonymousnames.dm +++ b/code/modules/admin/verbs/anonymousnames.dm @@ -129,7 +129,8 @@ GLOBAL_DATUM(current_anonymous_theme, /datum/anonymous_theme) * * target - mob for preferences and gender */ /datum/anonymous_theme/proc/anonymous_name(mob/target) - var/species_type = target.client.prefs.read_preference(/datum/preference/choiced/species) + var/datum/client_interface/client = GET_CLIENT(target) + var/species_type = client.prefs.read_preference(/datum/preference/choiced/species) var/datum/species/species = new species_type return species.random_name(target.gender,1) diff --git a/code/modules/client/preferences/random.dm b/code/modules/client/preferences/random.dm index 6ad675fcda2..da1f9b2062a 100644 --- a/code/modules/client/preferences/random.dm +++ b/code/modules/client/preferences/random.dm @@ -31,7 +31,7 @@ if (!..(preferences)) return FALSE - return preferences.parent.get_exp_living(pure_numeric = TRUE) >= PLAYTIME_HARDCORE_RANDOM + return preferences.parent?.get_exp_living(pure_numeric = TRUE) >= PLAYTIME_HARDCORE_RANDOM // SKYRAT EDIT - ORIGINAL: return preferences.parent.get_exp_living(pure_numeric = TRUE) >= PLAYTIME_HARDCORE_RANDOM /datum/preference/choiced/random_name category = PREFERENCE_CATEGORY_NON_CONTEXTUAL diff --git a/code/modules/jobs/job_types/_job.dm b/code/modules/jobs/job_types/_job.dm index d633f517e2d..ed04ff14088 100644 --- a/code/modules/jobs/job_types/_job.dm +++ b/code/modules/jobs/job_types/_job.dm @@ -412,13 +412,13 @@ src.job = job.title if(fully_randomize) - if(require_human) - player_client.prefs.randomise_appearance_prefs(~RANDOMIZE_SPECIES) - else - player_client.prefs.randomise_appearance_prefs() - player_client.prefs.apply_prefs_to(src) + if(require_human) + randomize_human_appearance(~RANDOMIZE_SPECIES) + else + randomize_human_appearance() + if (require_human) set_species(/datum/species/human) diff --git a/code/modules/mob/living/carbon/human/human_helpers.dm b/code/modules/mob/living/carbon/human/human_helpers.dm index 407debc860d..cf7f27af524 100644 --- a/code/modules/mob/living/carbon/human/human_helpers.dm +++ b/code/modules/mob/living/carbon/human/human_helpers.dm @@ -249,4 +249,4 @@ continue if (preference.is_randomizable()) - preferences.write_preference(preference, preference.create_random_value(preferences)) + preference.apply_to_human(src, preference.create_random_value(preferences)) diff --git a/code/modules/unit_tests/_unit_tests.dm b/code/modules/unit_tests/_unit_tests.dm index 77f968de405..a35e369d533 100644 --- a/code/modules/unit_tests/_unit_tests.dm +++ b/code/modules/unit_tests/_unit_tests.dm @@ -45,6 +45,7 @@ #include "achievements.dm" #include "anchored_mobs.dm" +#include "anonymous_themes.dm" #include "bespoke_id.dm" #include "binary_insert.dm" #include "bloody_footprints.dm" diff --git a/code/modules/unit_tests/anonymous_themes.dm b/code/modules/unit_tests/anonymous_themes.dm new file mode 100644 index 00000000000..910317c36aa --- /dev/null +++ b/code/modules/unit_tests/anonymous_themes.dm @@ -0,0 +1,23 @@ +/// Ensure that anonymous themes works without changing your preferences +/datum/unit_test/anonymous_themes + +/datum/unit_test/anonymous_themes/Run() + GLOB.current_anonymous_theme = new /datum/anonymous_theme + + var/mob/living/carbon/human/human = allocate(/mob/living/carbon/human) + + var/datum/client_interface/client = new + human.mock_client = client + + client.prefs = new + + client.prefs.write_preference(GLOB.preference_entries[/datum/preference/name/real_name], "Prefs Biddle") + + human.apply_prefs_job(client, SSjob.GetJobType(/datum/job/assistant)) + + TEST_ASSERT_NOTEQUAL(human.real_name, "Prefs Biddle", "apply_prefs_job didn't randomize human name with an anonymous theme") + TEST_ASSERT_EQUAL(client.prefs.read_preference(/datum/preference/name/real_name), "Prefs Biddle", "Anonymous theme overrode original prefs") + +/datum/unit_test/anonymous_themes/Destroy() + QDEL_NULL(GLOB.current_anonymous_theme) + return ..()