From ecdc2ec507b29853906e74de30732db2c59e5c82 Mon Sep 17 00:00:00 2001 From: Seris02 Date: Thu, 26 Jan 2023 16:02:01 +0800 Subject: [PATCH 1/3] sanitizes selection of custom bases in prefs --- .../client/preference_setup/vore/07_traits.dm | 28 ++++++++++++------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/code/modules/client/preference_setup/vore/07_traits.dm b/code/modules/client/preference_setup/vore/07_traits.dm index 5a9922dd4f..337888e844 100644 --- a/code/modules/client/preference_setup/vore/07_traits.dm +++ b/code/modules/client/preference_setup/vore/07_traits.dm @@ -25,6 +25,19 @@ var/dirty_synth = 0 //Are you a synth var/gross_meatbag = 0 //Where'd I leave my Voight-Kampff test kit? +/datum/preferences/proc/get_custom_bases_for_species(var/new_species) + if (!new_species) + new_species = species + var/list/choices + var/datum/species/spec = GLOB.all_species[new_species] + if (spec.selects_bodytype == SELECTS_BODYTYPE_SHAPESHIFTER) + choices = spec.get_valid_shapeshifter_forms() + else if (spec.selects_bodytype == SELECTS_BODYTYPE_CUSTOM) + choices = GLOB.custom_species_bases + if(new_species != SPECIES_CUSTOM) + choices = (choices | new_species) + return choices + // Definition of the stuff for Ears /datum/category_item/player_setup_item/vore/traits name = "Traits" @@ -122,7 +135,9 @@ var/datum/species/selected_species = GLOB.all_species[pref.species] if(selected_species.selects_bodytype) - // Allowed! + if (!(pref.custom_base in pref.get_custom_bases_for_species())) + pref.custom_base = SPECIES_HUMAN + //otherwise, allowed! else if(!pref.custom_base || !(pref.custom_base in GLOB.custom_species_bases)) pref.custom_base = SPECIES_HUMAN @@ -131,6 +146,7 @@ pref.custom_ask = lowertext(trim(pref.custom_ask)) pref.custom_exclaim = lowertext(trim(pref.custom_exclaim)) + /datum/category_item/player_setup_item/vore/traits/copy_to_mob(var/mob/living/carbon/human/character) character.custom_species = pref.custom_species character.custom_say = lowertext(trim(pref.custom_say)) @@ -236,15 +252,7 @@ return TOPIC_REFRESH else if(href_list["custom_base"]) - var/list/choices - var/datum/species/spec = GLOB.all_species[pref.species] - if (spec.selects_bodytype == SELECTS_BODYTYPE_SHAPESHIFTER && istype(spec, /datum/species/shapeshifter)) - var/datum/species/spec_shifter = spec - choices = spec_shifter.get_valid_shapeshifter_forms() - else - choices = GLOB.custom_species_bases - if(pref.species != SPECIES_CUSTOM) - choices = (choices | pref.species) + var/list/choices = pref.get_custom_bases_for_species() var/text_choice = tgui_input_list(usr, "Pick an icon set for your species:","Icon Base", choices) if(text_choice in choices) pref.custom_base = text_choice From c33ca609ca721d51ebe8eeb6f5760e6b67056f08 Mon Sep 17 00:00:00 2001 From: Seris02 Date: Mon, 30 Jan 2023 07:10:31 +0800 Subject: [PATCH 2/3] copy list --- code/modules/client/preference_setup/vore/07_traits.dm | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/code/modules/client/preference_setup/vore/07_traits.dm b/code/modules/client/preference_setup/vore/07_traits.dm index 337888e844..4b611b6604 100644 --- a/code/modules/client/preference_setup/vore/07_traits.dm +++ b/code/modules/client/preference_setup/vore/07_traits.dm @@ -31,9 +31,9 @@ var/list/choices var/datum/species/spec = GLOB.all_species[new_species] if (spec.selects_bodytype == SELECTS_BODYTYPE_SHAPESHIFTER) - choices = spec.get_valid_shapeshifter_forms() + choices = spec.get_valid_shapeshifter_forms().Copy() else if (spec.selects_bodytype == SELECTS_BODYTYPE_CUSTOM) - choices = GLOB.custom_species_bases + choices = GLOB.custom_species_bases.Copy() if(new_species != SPECIES_CUSTOM) choices = (choices | new_species) return choices From e9264fb4bfc0138c71d6c76bad21021ae449a790 Mon Sep 17 00:00:00 2001 From: Seris02 Date: Mon, 30 Jan 2023 14:59:25 +0800 Subject: [PATCH 3/3] linters fix --- code/modules/client/preference_setup/vore/07_traits.dm | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/code/modules/client/preference_setup/vore/07_traits.dm b/code/modules/client/preference_setup/vore/07_traits.dm index 4b611b6604..eeb18d7256 100644 --- a/code/modules/client/preference_setup/vore/07_traits.dm +++ b/code/modules/client/preference_setup/vore/07_traits.dm @@ -31,7 +31,8 @@ var/list/choices var/datum/species/spec = GLOB.all_species[new_species] if (spec.selects_bodytype == SELECTS_BODYTYPE_SHAPESHIFTER) - choices = spec.get_valid_shapeshifter_forms().Copy() + choices = spec.get_valid_shapeshifter_forms() + choices = choices.Copy() else if (spec.selects_bodytype == SELECTS_BODYTYPE_CUSTOM) choices = GLOB.custom_species_bases.Copy() if(new_species != SPECIES_CUSTOM)