diff --git a/code/modules/client/preference_setup/general/02_language.dm b/code/modules/client/preference_setup/general/02_language.dm index 0481affd17..2c9abecd67 100644 --- a/code/modules/client/preference_setup/general/02_language.dm +++ b/code/modules/client/preference_setup/general/02_language.dm @@ -14,8 +14,18 @@ if(!islist(pref.alternate_languages)) pref.alternate_languages = list() if(pref.species) var/datum/species/S = GLOB.all_species[pref.species] - if(S && pref.alternate_languages.len > S.num_alternate_languages) + if(!istype(S)) + return + + if(pref.alternate_languages.len > S.num_alternate_languages) pref.alternate_languages.len = S.num_alternate_languages // Truncate to allowed length + + // Sanitize illegal languages + for(var/language in pref.alternate_languages) + var/datum/language/L = GLOB.all_languages[language] + if((L.flags & RESTRICTED) || (!(language in S.secondary_langs) && !is_lang_whitelisted(pref.client, L))) + pref.alternate_languages -= language + if(isnull(pref.language_prefixes) || !pref.language_prefixes.len) pref.language_prefixes = config.language_prefixes.Copy() diff --git a/code/modules/client/preference_setup/general/03_body.dm b/code/modules/client/preference_setup/general/03_body.dm index 0144c752f4..d75fa4bf1b 100644 --- a/code/modules/client/preference_setup/general/03_body.dm +++ b/code/modules/client/preference_setup/general/03_body.dm @@ -229,21 +229,12 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O pref.r_wing3 = sanitize_integer(pref.r_wing3, 0, 255, initial(pref.r_wing3)) pref.g_wing3 = sanitize_integer(pref.g_wing3, 0, 255, initial(pref.g_wing3)) pref.b_wing3 = sanitize_integer(pref.b_wing3, 0, 255, initial(pref.b_wing3)) - if(pref.ear_style) - pref.ear_style = sanitize_inlist(pref.ear_style, ear_styles_list, initial(pref.ear_style)) - var/datum/sprite_accessory/temp_ear_style = ear_styles_list[pref.ear_style] - if(temp_ear_style.apply_restrictions && (!(pref.species in temp_ear_style.species_allowed))) - pref.ear_style = initial(pref.ear_style) - if(pref.tail_style) - pref.tail_style = sanitize_inlist(pref.tail_style, tail_styles_list, initial(pref.tail_style)) - var/datum/sprite_accessory/temp_tail_style = tail_styles_list[pref.tail_style] - if(temp_tail_style.apply_restrictions && (!(pref.species in temp_tail_style.species_allowed))) - pref.tail_style = initial(pref.tail_style) - if(pref.wing_style) - pref.wing_style = sanitize_inlist(pref.wing_style, wing_styles_list, initial(pref.wing_style)) - var/datum/sprite_accessory/temp_wing_style = wing_styles_list[pref.wing_style] - if(temp_wing_style.apply_restrictions && (!(pref.species in temp_wing_style.species_allowed))) - pref.wing_style = initial(pref.wing_style) + if(!(pref.ear_style in get_ear_styles())) + pref.ear_style = initial(pref.ear_style) + if(!(pref.wing_style in get_wing_styles())) + pref.wing_style = initial(pref.wing_style) + if(!(pref.tail_style in get_tail_styles())) + pref.tail_style = initial(pref.tail_style) // Moved from /datum/preferences/proc/copy_to() /datum/category_item/player_setup_item/general/body/copy_to_mob(var/mob/living/carbon/human/character) @@ -674,7 +665,15 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O reset_limbs() // Safety for species with incompatible manufacturers; easier than trying to do it case by case. pref.body_markings.Cut() // Basically same as above. - + + // Sanitize ear/wing/tail styles + if(!(pref.ear_style in get_ear_styles())) + pref.ear_style = initial(pref.ear_style) + if(!(pref.wing_style in get_wing_styles())) + pref.wing_style = initial(pref.wing_style) + if(!(pref.tail_style in get_tail_styles())) + pref.tail_style = initial(pref.tail_style) + var/min_age = get_min_age() var/max_age = get_max_age() pref.age = max(min(pref.age, max_age), min_age) @@ -1086,11 +1085,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O else if(href_list["ear_style"]) // Construct the list of names allowed for this user. - var/list/pretty_ear_styles = list("Normal" = null) - for(var/path in ear_styles_list) - var/datum/sprite_accessory/ears/instance = ear_styles_list[path] - if(((!instance.ckeys_allowed) || (usr.ckey in instance.ckeys_allowed)) && (/*(!instance.apply_restrictions) || */(pref.species in instance.species_allowed)) || check_rights(R_ADMIN | R_EVENT | R_FUN, 0, user)) - pretty_ear_styles[instance.name] = path + var/list/pretty_ear_styles = get_ear_styles() // Present choice to user var/new_ear_style = input(user, "Pick ears", "Character Preference", pref.ear_style) as null|anything in pretty_ear_styles @@ -1128,11 +1123,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O else if(href_list["tail_style"]) // Construct the list of names allowed for this user. - var/list/pretty_tail_styles = list("Normal" = null) - for(var/path in tail_styles_list) - var/datum/sprite_accessory/tail/instance = tail_styles_list[path] - if(((!instance.ckeys_allowed) || (usr.ckey in instance.ckeys_allowed)) && (/*(!instance.apply_restrictions) || */(pref.species in instance.species_allowed)) || check_rights(R_ADMIN | R_EVENT | R_FUN, 0, user)) - pretty_tail_styles[instance.name] = path + var/list/pretty_tail_styles = get_tail_styles() // Present choice to user var/new_tail_style = input(user, "Pick tails", "Character Preference", pref.tail_style) as null|anything in pretty_tail_styles @@ -1170,11 +1161,7 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O else if(href_list["wing_style"]) // Construct the list of names allowed for this user. - var/list/pretty_wing_styles = list("Normal" = null) - for(var/path in wing_styles_list) - var/datum/sprite_accessory/wing/instance = wing_styles_list[path] - if(((!instance.ckeys_allowed) || (usr.ckey in instance.ckeys_allowed)) && (/*(!instance.apply_restrictions) || */(pref.species in instance.species_allowed)) || check_rights(R_ADMIN | R_EVENT | R_FUN, 0, user)) - pretty_wing_styles[instance.name] = path + var/list/pretty_wing_styles = get_wing_styles() // Present choice to user var/new_wing_style = input(user, "Pick wings", "Character Preference", pref.wing_style) as null|anything in pretty_wing_styles @@ -1299,3 +1286,27 @@ var/global/list/valid_bloodtypes = list("A+", "A-", "B+", "B-", "AB+", "AB-", "O dat += "" user << browse(dat, "window=species;size=700x400") + +/datum/category_item/player_setup_item/general/body/proc/get_tail_styles() + var/list/pretty_tail_styles = list("Normal" = null) + for(var/path in tail_styles_list) + var/datum/sprite_accessory/tail/instance = tail_styles_list[path] + if(((!instance.ckeys_allowed) || (pref.client.ckey in instance.ckeys_allowed)) && (/*(!instance.apply_restrictions) || */(pref.species in instance.species_allowed)) || check_rights(R_ADMIN | R_EVENT | R_FUN, 0, pref.client)) + pretty_tail_styles[instance.name] = path + return pretty_tail_styles + +/datum/category_item/player_setup_item/general/body/proc/get_ear_styles() + var/list/pretty_ear_styles = list("Normal" = null) + for(var/path in ear_styles_list) + var/datum/sprite_accessory/ears/instance = ear_styles_list[path] + if(((!instance.ckeys_allowed) || (pref.client.ckey in instance.ckeys_allowed)) && (/*(!instance.apply_restrictions) || */(pref.species in instance.species_allowed)) || check_rights(R_ADMIN | R_EVENT | R_FUN, 0, pref.client)) + pretty_ear_styles[instance.name] = path + return pretty_ear_styles + +/datum/category_item/player_setup_item/general/body/proc/get_wing_styles() + var/list/pretty_wing_styles = list("Normal" = null) + for(var/path in wing_styles_list) + var/datum/sprite_accessory/wing/instance = wing_styles_list[path] + if(((!instance.ckeys_allowed) || (pref.client.ckey in instance.ckeys_allowed)) && (/*(!instance.apply_restrictions) || */(pref.species in instance.species_allowed)) || check_rights(R_ADMIN | R_EVENT | R_FUN, 0, pref.client)) + pretty_wing_styles[instance.name] = path + return pretty_wing_styles diff --git a/code/modules/client/preference_setup/preference_setup.dm b/code/modules/client/preference_setup/preference_setup.dm index 4e5b422deb..59732fe363 100644 --- a/code/modules/client/preference_setup/preference_setup.dm +++ b/code/modules/client/preference_setup/preference_setup.dm @@ -129,6 +129,7 @@ for(var/datum/category_item/player_setup_item/PI in items) PI.load_character(S) + /datum/category_group/player_setup_category/proc/save_character(var/savefile/S) // Sanitize all data, then save it for(var/datum/category_item/player_setup_item/PI in items) diff --git a/code/modules/client/preferences.dm b/code/modules/client/preferences.dm index 9bbe6633d6..da851e162e 100644 --- a/code/modules/client/preferences.dm +++ b/code/modules/client/preferences.dm @@ -162,8 +162,8 @@ datum/preferences if(!IsGuestKey(C.key)) load_path(C.ckey) if(load_preferences()) - if(load_character()) - return + load_character() + /datum/preferences/proc/ZeroSkills(var/forced = 0) for(var/V in SKILLS) for(var/datum/skill/S in SKILLS[V]) diff --git a/code/modules/client/preferences_savefile.dm b/code/modules/client/preferences_savefile.dm index 593d592187..ae2ac55f92 100644 --- a/code/modules/client/preferences_savefile.dm +++ b/code/modules/client/preferences_savefile.dm @@ -82,9 +82,7 @@ player_setup.load_character(S) S.cd = "/character[default_slot]" player_setup.save_character(S) - sanitize_preferences() - player_setup.load_character(S) return 1 /datum/preferences/proc/save_character()