From 72b5d11f3ce563e1d7c9b2b7370e7fedbc504252 Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Sat, 1 Apr 2017 21:23:39 -0400 Subject: [PATCH 1/5] Turns Auto-Accent into a by-character Preference Required SQL Change: ALTER TABLE `characters` ADD `autohiss` TINYINT(1) NOT NULL AFTER `gear`; Ingame changing of auto-accent level is no different. This peference can be different on each of your characters. --- SQL/paradise_schema.sql | 1 + SQL/paradise_schema_prefixed.sql | 1 + code/__DEFINES/language.dm | 7 ++++++- code/modules/client/preference/preferences.dm | 12 ++++++++++++ .../client/preference/preferences_mysql.dm | 12 ++++++++---- code/modules/mob/living/autohiss.dm | 18 +++++------------- .../mob/living/carbon/human/species/station.dm | 2 +- 7 files changed, 34 insertions(+), 19 deletions(-) diff --git a/SQL/paradise_schema.sql b/SQL/paradise_schema.sql index a5991c9bcb9..bd90e0be9f0 100644 --- a/SQL/paradise_schema.sql +++ b/SQL/paradise_schema.sql @@ -88,6 +88,7 @@ CREATE TABLE `characters` ( `socks` mediumtext NOT NULL, `body_accessory` mediumtext NOT NULL, `gear` mediumtext NOT NULL, + `autohiss` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=18747 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/SQL/paradise_schema_prefixed.sql b/SQL/paradise_schema_prefixed.sql index 845b8702fcd..94010ad1b74 100644 --- a/SQL/paradise_schema_prefixed.sql +++ b/SQL/paradise_schema_prefixed.sql @@ -88,6 +88,7 @@ CREATE TABLE `SS13_characters` ( `socks` mediumtext NOT NULL, `body_accessory` mediumtext NOT NULL, `gear` mediumtext NOT NULL, + `autohiss` tinyint(1) NOT NULL, PRIMARY KEY (`id`) ) ENGINE=InnoDB AUTO_INCREMENT=18747 DEFAULT CHARSET=utf8; /*!40101 SET character_set_client = @saved_cs_client */; diff --git a/code/__DEFINES/language.dm b/code/__DEFINES/language.dm index b1781de3314..87a8805ca7e 100644 --- a/code/__DEFINES/language.dm +++ b/code/__DEFINES/language.dm @@ -17,4 +17,9 @@ #define NONGLOBAL 32 // Do not add to general languages list #define INNATE 64 // All mobs can be assumed to speak and understand this language (audible emotes) #define NO_TALK_MSG 128 // Do not show the "\The [speaker] talks into \the [radio]" message -#define NO_STUTTER 256 // No stuttering, slurring, or other speech problems \ No newline at end of file +#define NO_STUTTER 256 // No stuttering, slurring, or other speech problems + +//Auto-accent level defines. +#define AUTOHISS_OFF 0 +#define AUTOHISS_BASIC 1 +#define AUTOHISS_FULL 2 diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index 700b5e0f542..bf5eedb2075 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -147,6 +147,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts var/alt_head = "None" //Alt head style. var/species = "Human" var/language = "None" //Secondary language + var/autohiss_mode = AUTOHISS_OFF //Species autohiss level. OFF, BASIC, FULL. var/body_accessory = null @@ -289,6 +290,8 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(species == "Grey") dat += "Voice: [speciesprefs ? "Wingdings" : "Normal"]
" dat += "Secondary Language: [language]
" + if(species in list("Unathi", "Tajaran", "Plasmaman", "Kidan")) + dat += "Auto-accent: [autohiss_mode == 2 ? "Full" : (autohiss_mode == 1 ? "Basic" : "Off")]
" dat += "Blood Type: [b_type]
" if(species in list("Human", "Drask", "Vox")) dat += "Skin Tone: [species == "Vox" ? "[s_tone]" : "[-s_tone + 35]/220"]
" @@ -1342,6 +1345,9 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts //Reset prosthetics. organ_data = list() rlimb_data = list() + + if(!(species in list("Unathi", "Tajaran", "Plasmaman", "Kidan"))) + autohiss_mode = 0 if("speciesprefs") speciesprefs = !speciesprefs //Starts 0, so if someone clicks the button up top there, this won't be 0 anymore. If they click it again, it'll go back to 0. if("language") @@ -1366,6 +1372,12 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts language = input("Please select a secondary language", "Character Generation", null) in new_languages + if("autohiss_mode") + if(species in list("Unathi", "Tajaran", "Plasmaman", "Kidan")) + var/list/autohiss_choice = list("Off" = 0, "Basic" = 1, "Full" = 2) + var/new_autohiss_pref = input(user, "Choose your character's auto-accent level:", "Character Preference") as null|anything in autohiss_choice + autohiss_mode = autohiss_choice[new_autohiss_pref] + if("metadata") var/new_metadata = input(user, "Enter any information you'd like others to see, such as Roleplay-preferences:", "Game Preference" , metadata) as message|null if(new_metadata) diff --git a/code/modules/client/preference/preferences_mysql.dm b/code/modules/client/preference/preferences_mysql.dm index 02d246b4f70..579699a9414 100644 --- a/code/modules/client/preference/preferences_mysql.dm +++ b/code/modules/client/preference/preferences_mysql.dm @@ -175,7 +175,8 @@ speciesprefs, socks, body_accessory, - gear + gear, + autohiss FROM [format_table_name("characters")] WHERE ckey='[C.ckey]' AND slot='[slot]'"}) if(!query.Execute()) var/err = query.ErrorMsg() @@ -268,6 +269,7 @@ socks = query.item[63] body_accessory = query.item[64] gear = params2list(query.item[65]) + autohiss_mode = text2num(query.item[66]) //Sanitize var/datum/species/SP = all_species[species] @@ -315,6 +317,7 @@ undershirt = sanitize_text(undershirt, initial(undershirt)) backbag = sanitize_text(backbag, initial(backbag)) b_type = sanitize_text(b_type, initial(b_type)) + autohiss_mode = sanitize_integer(autohiss_mode, 0, 2, initial(autohiss_mode)) alternate_option = sanitize_integer(alternate_option, 0, 2, initial(alternate_option)) job_support_high = sanitize_integer(job_support_high, 0, 65535, initial(job_support_high)) @@ -427,7 +430,8 @@ speciesprefs='[speciesprefs]', socks='[socks]', body_accessory='[body_accessory]', - gear='[gearlist]' + gear='[gearlist]', + autohiss='[autohiss_mode]' WHERE ckey='[C.ckey]' AND slot='[default_slot]'"} ) @@ -467,7 +471,7 @@ gen_record, player_alt_titles, disabilities, organ_data, rlimb_data, nanotrasen_relation, speciesprefs, - socks, body_accessory, gear) + socks, body_accessory, gear, autohiss) VALUES ('[C.ckey]', '[default_slot]', '[sanitizeSQL(metadata)]', '[sanitizeSQL(real_name)]', '[be_random_name]','[gender]', @@ -497,7 +501,7 @@ '[sanitizeSQL(gen_record)]', '[playertitlelist]', '[disabilities]', '[organlist]', '[rlimblist]', '[nanotrasen_relation]', '[speciesprefs]', - '[socks]', '[body_accessory]', '[gearlist]') + '[socks]', '[body_accessory]', '[gearlist]', '[autohiss_mode]') "} ) diff --git a/code/modules/mob/living/autohiss.dm b/code/modules/mob/living/autohiss.dm index 4506ce50cfb..0c2c6defeb8 100644 --- a/code/modules/mob/living/autohiss.dm +++ b/code/modules/mob/living/autohiss.dm @@ -1,8 +1,3 @@ - -#define AUTOHISS_OFF 0 -#define AUTOHISS_BASIC 1 -#define AUTOHISS_FULL 2 - #define AUTOHISS_NUM 3 @@ -10,20 +5,17 @@ return message // no autohiss at this level /mob/living/carbon/human/handle_autohiss(message, datum/language/L) - if(!client || client.autohiss_mode == AUTOHISS_OFF) // no need to process if there's no client or they have autohiss off + if(!client || client.prefs.autohiss_mode == AUTOHISS_OFF) // no need to process if there's no client or they have autohiss off return message - return species.handle_autohiss(message, L, client.autohiss_mode) - -/client - var/autohiss_mode = AUTOHISS_OFF + return species.handle_autohiss(message, L, client.prefs.autohiss_mode) /client/verb/toggle_autohiss() set name = "Toggle Auto-Accent" set desc = "Toggle automatic accents for your species" set category = "OOC" - autohiss_mode = (autohiss_mode + 1) % AUTOHISS_NUM - switch(autohiss_mode) + prefs.autohiss_mode = (prefs.autohiss_mode + 1) % AUTOHISS_NUM + switch(prefs.autohiss_mode) if(AUTOHISS_OFF) to_chat(src, "Auto-hiss is now OFF.") if(AUTOHISS_BASIC) @@ -31,7 +23,7 @@ if(AUTOHISS_FULL) to_chat(src, "Auto-hiss is now FULL.") else - autohiss_mode = AUTOHISS_OFF + prefs.autohiss_mode = AUTOHISS_OFF to_chat(src, "Auto-hiss is now OFF.") /datum/species diff --git a/code/modules/mob/living/carbon/human/species/station.dm b/code/modules/mob/living/carbon/human/species/station.dm index 04cbbe653ba..dffadb528c3 100644 --- a/code/modules/mob/living/carbon/human/species/station.dm +++ b/code/modules/mob/living/carbon/human/species/station.dm @@ -897,7 +897,7 @@ oxy_mod = 0 death_message = "gives one shrill beep before falling limp, their monitor flashing blue before completely shutting off..." - flags = IS_WHITELISTED | NO_BREATHE | NO_SCAN | NO_BLOOD | NO_PAIN | NO_DNA | RADIMMUNE | ALL_RPARTS| NOTRANSSTING + flags = IS_WHITELISTED | NO_BREATHE | NO_SCAN | NO_BLOOD | NO_PAIN | NO_DNA | RADIMMUNE | ALL_RPARTS | NOTRANSSTING clothing_flags = HAS_UNDERWEAR | HAS_UNDERSHIRT | HAS_SOCKS bodyflags = HAS_SKIN_COLOR | HAS_HEAD_MARKINGS | HAS_HEAD_ACCESSORY dietflags = 0 //IPCs can't eat, so no diet From 5c356f829970da8473b235bad958a8e7c3301469 Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Sat, 1 Apr 2017 23:33:06 -0400 Subject: [PATCH 2/5] Melts Snowflakes Turned as many of these species name checks into species datum flag checks as possible. Everything still works the same. --- code/modules/client/preference/preferences.dm | 123 ++++++++++-------- 1 file changed, 68 insertions(+), 55 deletions(-) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index bf5eedb2075..bdf0c15b813 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -260,6 +260,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts switch(current_tab) if(TAB_CHAR) // Character Settings + var/datum/species/S = all_species[species] dat += "
" dat += "
" dat += "Name: " @@ -290,10 +291,10 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(species == "Grey") dat += "Voice: [speciesprefs ? "Wingdings" : "Normal"]
" dat += "Secondary Language: [language]
" - if(species in list("Unathi", "Tajaran", "Plasmaman", "Kidan")) + if(istype(S) && S.autohiss_basic_map) dat += "Auto-accent: [autohiss_mode == 2 ? "Full" : (autohiss_mode == 1 ? "Basic" : "Off")]
" dat += "Blood Type: [b_type]
" - if(species in list("Human", "Drask", "Vox")) + if(istype(S) && S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) dat += "Skin Tone: [species == "Vox" ? "[s_tone]" : "[-s_tone + 35]/220"]
" dat += "Disabilities: \[Set\]
" dat += "Nanotrasen Relation: [nanotrasen_relation]
" @@ -305,7 +306,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "

Hair & Accessories

" - if(species in list("Unathi", "Vulpkanin", "Tajaran", "Machine", "Kidan")) //Species that have head accessories. + if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. var/headaccessoryname = "Head Accessory: " if(species == "Unathi") headaccessoryname = "Horns: " @@ -313,15 +314,15 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "[ha_style] " dat += "Color [color_square(r_headacc, g_headacc, b_headacc)]
" - if(species in list("Machine", "Tajaran", "Unathi", "Vulpkanin")) //Species with head markings. + if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. dat += "Head Markings: " dat += "[m_styles["head"]]" dat += "Color [color_square(color2R(m_colours["head"]), color2G(m_colours["head"]), color2B(m_colours["head"]))]
" - if(species in list("Human", "Unathi", "Grey", "Vulpkanin", "Tajaran", "Skrell", "Vox", "Drask")) //Species with body markings/tattoos. + if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. dat += "Body Markings: " dat += "[m_styles["body"]]" dat += "Color [color_square(color2R(m_colours["body"]), color2G(m_colours["body"]), color2B(m_colours["body"]))]
" - if(species in list("Vox", "Vulpkanin")) //Species with tail markings. + if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. dat += "Tail Markings: " dat += "[m_styles["tail"]]" dat += "Color [color_square(color2R(m_colours["tail"]), color2G(m_colours["tail"]), color2B(m_colours["tail"]))]
" @@ -347,7 +348,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "Eyes: " dat += "Color [color_square(r_eyes, g_eyes, b_eyes)]
" - if((species in list("Unathi", "Tajaran", "Skrell", "Slime People", "Vulpkanin", "Machine")) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) //admins can always fuck with this, because they are admins + if((istype(S) && S.bodyflags & HAS_SKIN_COLOR) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) //admins can always fuck with this, because they are admins dat += "Body Color: " dat += "Color [color_square(r_skin, g_skin, b_skin)]
" @@ -364,7 +365,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "Character Records
" dat += "

Limbs

" - if(species in list("Unathi")) //Species with alt heads. + if(istype(S) && S.bodyflags & HAS_ALT_HEADS) //Species with alt heads. dat += "Alternate Head: " dat += "[alt_head]
" dat += "Limbs and Parts: Adjust
" @@ -415,9 +416,12 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts else dat += "
" dat += "

Clothing

" - dat += "Underwear: [underwear]
" - dat += "Undershirt: [undershirt]
" - dat += "Socks: [socks]
" + if(istype(S) && S.clothing_flags & HAS_UNDERWEAR) + dat += "Underwear: [underwear]
" + if(istype(S) && S.clothing_flags & HAS_UNDERSHIRT) + dat += "Undershirt: [undershirt]
" + if(istype(S) && S.clothing_flags & HAS_SOCKS) + dat += "Socks: [socks]
" dat += "Backpack Type: [backbag]
" dat += "
" @@ -1071,7 +1075,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("input") var/dflag=text2num(href_list["disability"]) if(dflag >= 0) - if(!(dflag==DISABILITY_FLAG_FAT && species!=("Human" || "Tajaran" || "Grey"))) + if(dflag==DISABILITY_FLAG_FAT && (istype(S) && S.flags & CAN_BE_FAT)) disabilities ^= text2num(href_list["disability"]) //MAGIC SetDisabilities(user) else @@ -1157,7 +1161,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts switch(href_list["task"]) if("random") var/datum/robolimb/robohead - if(species == "Machine") + if(istype(S) && S.flags & ALL_RPARTS) var/head_model = "[!rlimb_data["head"] ? "Morpheus Cyberkinetics" : rlimb_data["head"]]" robohead = all_robolimbs[head_model] switch(href_list["preference"]) @@ -1190,30 +1194,30 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("f_style") f_style = random_facial_hair_style(gender, species, robohead) if("headaccessory") - if(species in list("Unathi", "Vulpkanin", "Tajaran", "Machine")) //Species that have head accessories. + if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. r_headacc = rand(0,255) g_headacc = rand(0,255) b_headacc = rand(0,255) if("ha_style") - if(species in list("Unathi", "Vulpkanin", "Tajaran", "Machine")) //Species that have head accessories. + if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. ha_style = random_head_accessory(species) if("m_style_head") - if(species in list("Machine", "Tajaran", "Unathi", "Vulpkanin")) //Species with head markings. + if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. m_styles["head"] = random_marking_style("head", species, robohead, null, alt_head) if("m_head_colour") - if(species in list("Machine", "Tajaran", "Unathi", "Vulpkanin")) //Species with head markings. + if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. m_colours["head"] = rgb(rand(0,255), rand(0,255), rand(0,255)) if("m_style_body") - if(species in list("Human", "Unathi", "Grey", "Vulpkanin", "Tajaran", "Skrell", "Vox", "Drask")) //Species with body markings. + if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings. m_styles["body"] = random_marking_style("body", species) if("m_body_colour") - if(species in list("Human", "Unathi", "Grey", "Vulpkanin", "Tajaran", "Skrell", "Vox", "Drask")) //Species with body markings. + if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings. m_colours["body"] = rgb(rand(0,255), rand(0,255), rand(0,255)) if("m_style_tail") - if(species in list("Vox", "Vulpkanin")) //Species with tail markings. + if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. m_styles["tail"] = random_marking_style("tail", species, null, body_accessory) if("m_tail_colour") - if(species in list("Vox", "Vulpkanin")) //Species with tail markings. + if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. m_colours["tail"] = rgb(rand(0,255), rand(0,255), rand(0,255)) if("underwear") underwear = random_underwear(gender, species) @@ -1229,10 +1233,10 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts g_eyes = rand(0,255) b_eyes = rand(0,255) if("s_tone") - if(species in list("Human", "Drask", "Vox")) + if(istype(S) && S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) s_tone = random_skin_tone() if("s_color") - if(species in list("Unathi", "Tajaran", "Skrell", "Slime People", "Wryn", "Vulpkanin", "Machine")) + if(istype(S) && S.bodyflags & HAS_SKIN_COLOR) r_skin = rand(0,255) g_skin = rand(0,255) b_skin = rand(0,255) @@ -1278,7 +1282,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(NS.has_gender && gender == PLURAL) gender = pick(MALE,FEMALE) var/datum/robolimb/robohead - if(species == "Machine") + if(istype(NS) && NS.flags & ALL_RPARTS) var/head_model = "[!rlimb_data["head"] ? "Morpheus Cyberkinetics" : rlimb_data["head"]]" robohead = all_robolimbs[head_model] //grab one of the valid hair styles for the newly chosen species @@ -1287,7 +1291,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts //grab one of the valid facial hair styles for the newly chosen species f_style = random_facial_hair_style(gender, species, robohead) - if(species in list("Unathi", "Vulpkanin", "Tajaran", "Machine")) //Species that have head accessories. + if(istype(NS) && NS.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. ha_style = random_head_accessory(species) else ha_style = "None" // No Vulp ears on Unathi @@ -1295,19 +1299,19 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts g_headacc = 0 b_headacc = 0 - if(species in list("Machine", "Tajaran", "Unathi", "Vulpkanin")) //Species with head markings. + if(istype(NS) && NS.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. m_styles["head"] = random_marking_style("head", species, robohead, null, alt_head) else m_styles["head"] = "None" m_colours["head"] = "#000000" - if(species in list("Human", "Unathi", "Grey", "Vulpkanin", "Tajaran", "Skrell", "Vox", "Drask")) //Species with body markings/tattoos. + if(istype(NS) && NS.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. m_styles["body"] = random_marking_style("body", species) else m_styles["body"] = "None" m_colours["body"] = "#000000" - if(species in list("Vox", "Vulpkanin")) //Species with tail markings. + if(istype(NS) && NS.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. m_styles["tail"] = random_marking_style("tail", species, null, body_accessory) else m_styles["tail"] = "None" @@ -1327,12 +1331,12 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts socks = random_socks(gender, species) //reset skin tone and colour - if(species in list("Human", "Drask", "Vox")) + if(istype(NS) && NS.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) random_skin_tone(species) else s_tone = 0 - if(!(species in list("Unathi", "Tajaran", "Skrell", "Slime People", "Vulpkanin", "Machine"))) + if(!(istype(NS) && NS.bodyflags & HAS_SKIN_COLOR)) r_skin = 0 g_skin = 0 b_skin = 0 @@ -1346,7 +1350,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts organ_data = list() rlimb_data = list() - if(!(species in list("Unathi", "Tajaran", "Plasmaman", "Kidan"))) + if(!(istype(NS) && NS.autohiss_basic_map)) autohiss_mode = 0 if("speciesprefs") speciesprefs = !speciesprefs //Starts 0, so if someone clicks the button up top there, this won't be 0 anymore. If they click it again, it'll go back to 0. @@ -1373,7 +1377,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts language = input("Please select a secondary language", "Character Generation", null) in new_languages if("autohiss_mode") - if(species in list("Unathi", "Tajaran", "Plasmaman", "Kidan")) + if(istype(S) && S.autohiss_basic_map) var/list/autohiss_choice = list("Off" = 0, "Basic" = 1, "Full" = 2) var/new_autohiss_pref = input(user, "Choose your character's auto-accent level:", "Character Preference") as null|anything in autohiss_choice autohiss_mode = autohiss_choice[new_autohiss_pref] @@ -1415,7 +1419,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(hairstyle == "Bald") //Just in case. valid_hairstyles += hairstyle continue - if(species == "Machine") //Species that can use prosthetic heads. + if(istype(S) && S.flags & ALL_RPARTS) //Species that can use prosthetic heads. var/head_model if(!rlimb_data["head"]) //Handle situations where the head is default. head_model = "Morpheus Cyberkinetics" @@ -1437,7 +1441,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts h_style = new_h_style if("headaccessory") - if(species in list("Unathi", "Vulpkanin", "Tajaran", "Machine", "Kidan")) //Species with head accessories. + if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories. var/input = "Choose the colour of your your character's head accessory:" var/new_head_accessory = input(user, input, "Character Preference", rgb(r_headacc, g_headacc, b_headacc)) as color|null if(new_head_accessory) @@ -1446,7 +1450,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts b_headacc = color2B(new_head_accessory) if("ha_style") - if(species in list("Unathi", "Vulpkanin", "Tajaran", "Machine", "Kidan")) //Species with head accessories. + if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories. var/list/valid_head_accessory_styles = list() for(var/head_accessory_style in head_accessory_styles_list) var/datum/sprite_accessory/H = head_accessory_styles_list[head_accessory_style] @@ -1462,7 +1466,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("alt_head") if(organ_data["head"] == "cyborg") return - if(species in list("Unathi")) //Species with alt heads. + if(istype(S) && S.bodyflags & HAS_ALT_HEADS) //Species with alt heads. var/list/valid_alt_heads = list() valid_alt_heads["None"] = alt_heads_list["None"] //The only null entry should be the "None" option for(var/alternate_head in alt_heads_list) @@ -1482,7 +1486,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["head"] = "None" if("m_style_head") - if(species in list("Machine", "Tajaran", "Unathi", "Vulpkanin")) //Species with head markings. + if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. var/list/valid_markings = list() valid_markings["None"] = marking_styles_list["None"] for(var/markingstyle in marking_styles_list) @@ -1498,7 +1502,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(M.heads_allowed && !("All" in M.heads_allowed)) continue - if(species == "Machine") //Species that can use prosthetic heads. + if(istype(S) && S.flags & ALL_RPARTS) //Species that can use prosthetic heads. var/head_model if(!rlimb_data["head"]) //Handle situations where the head is default. head_model = "Morpheus Cyberkinetics" @@ -1518,14 +1522,14 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["head"] = new_marking_style if("m_head_colour") - if(species in list("Machine", "Tajaran", "Unathi", "Vulpkanin")) //Species with head markings. + if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. var/input = "Choose the colour of your your character's head markings:" var/new_markings = input(user, input, "Character Preference", m_colours["head"]) as color|null if(new_markings) m_colours["head"] = new_markings if("m_style_body") - if(species in list("Human", "Unathi", "Grey", "Vulpkanin", "Tajaran", "Skrell", "Vox", "Drask")) //Species with body markings/tattoos. + if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. var/list/valid_markings = list() valid_markings["None"] = marking_styles_list["None"] for(var/markingstyle in marking_styles_list) @@ -1542,14 +1546,14 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["body"] = new_marking_style if("m_body_colour") - if(species in list("Human", "Unathi", "Grey", "Vulpkanin", "Tajaran", "Skrell", "Vox", "Drask")) //Species with body markings/tattoos. + if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. var/input = "Choose the colour of your your character's body markings:" var/new_markings = input(user, input, "Character Preference", m_colours["body"]) as color|null if(new_markings) m_colours["body"] = new_markings if("m_style_tail") - if(species in list("Vox", "Vulpkanin")) //Species with tail markings. + if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. var/list/valid_markings = list() valid_markings["None"] = marking_styles_list["None"] for(var/markingstyle in marking_styles_list) @@ -1572,7 +1576,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["tail"] = new_marking_style if("m_tail_colour") - if(species in list("Vox", "Vulpkanin")) //Species with tail markings. + if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. var/input = "Choose the colour of your your character's tail markings:" var/new_markings = input(user, input, "Character Preference", m_colours["tail"]) as color|null if(new_markings) @@ -1702,17 +1706,26 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts b_eyes = color2B(new_eyes) if("s_tone") - if(species == "Human" || species == "Drask") + if(istype(S) && S.bodyflags & HAS_SKIN_TONE) var/new_s_tone = input(user, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference") as num|null if(new_s_tone) s_tone = 35 - max(min(round(new_s_tone), 220), 1) - else if(species == "Vox") - var/skin_c = input(user, "Choose your Vox's skin color:\n(1 = Default Green, 2 = Dark Green, 3 = Brown, 4 = Grey, \n5 = Emerald, 6 = Azure)", "Character Preference") as num|null - if(skin_c) - s_tone = max(min(round(skin_c), 6), 1) + else if(istype(S) && S.bodyflags & HAS_ICON_SKIN_TONE) + var/const/MAX_LINE_ENTRIES = 4 + var/prompt = "Choose your character's skin tone: 1-[S.icon_skin_tones.len]\n(" + for(var/i = 1 to S.icon_skin_tones.len) + if(i > MAX_LINE_ENTRIES && !((i - 1) % MAX_LINE_ENTRIES)) + prompt += "\n" + prompt += "[i] = [S.icon_skin_tones[i]]" + if(i != S.icon_skin_tones.len) + prompt += ", " + prompt += ")" + var/skin_c = input(user, prompt, "Character Preference") as num|null + if(isnum(skin_c)) + s_tone = max(min(round(skin_c), S.icon_skin_tones.len), 1) if("skin") - if((species in list("Unathi", "Tajaran", "Skrell", "Slime People", "Vulpkanin", "Machine")) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) + if((istype(S) && S.bodyflags & HAS_SKIN_COLOR) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) var/new_skin = input(user, "Choose your character's skin colour: ", "Character Preference", rgb(r_skin, g_skin, b_skin)) as color|null if(new_skin) r_skin = color2R(new_skin) @@ -1746,7 +1759,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("limbs") var/valid_limbs = list("Left Leg", "Right Leg", "Left Arm", "Right Arm", "Left Foot", "Right Foot", "Left Hand", "Right Hand") - if(species == "Machine") + if(istype(S) && S.flags & ALL_RPARTS) valid_limbs = list("Torso", "Lower Body", "Head", "Left Leg", "Right Leg", "Left Arm", "Right Arm", "Left Foot", "Right Foot", "Left Hand", "Right Hand") var/limb_name = input(user, "Which limb do you want to change?") as null|anything in valid_limbs if(!limb_name) return @@ -1782,19 +1795,19 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts second_limb = "r_hand" if("Left Foot") limb = "l_foot" - if(species != "Machine") + if(!(istype(S) && S.flags & ALL_RPARTS)) third_limb = "l_leg" if("Right Foot") limb = "r_foot" - if(species != "Machine") + if(!(istype(S) && S.flags & ALL_RPARTS)) third_limb = "r_leg" if("Left Hand") limb = "l_hand" - if(species != "Machine") + if(!(istype(S) && S.flags & ALL_RPARTS)) third_limb = "l_arm" if("Right Hand") limb = "r_hand" - if(species != "Machine") + if(!(istype(S) && S.flags & ALL_RPARTS)) third_limb = "r_arm" var/new_state = input(user, "What state do you wish the limb to be in?") as null|anything in valid_limb_states @@ -1850,7 +1863,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(subchoice) choice = subchoice if(limb in list("head", "chest", "groin")) - if(species != "Machine") + if(!(istype(S) && S.flags & ALL_RPARTS)) return if(limb == "head") ha_style = "None" From 56bf4deb303e45a57059f9afdb2df404e854a53c Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Mon, 1 May 2017 00:40:40 -0400 Subject: [PATCH 3/5] istype() Reduction & A Missed Spot Checks once when S (or NS) is set. At S, it will default the species (human), fetch the species datum (also human) and generate a random character of that species (all but the random character generation is done at NS as well). Also sorts out a species check I missed (it checked to see if the species wasn't Machine. Now it checks to see if the species doesn't have ALL_RPARTS - functionally the same). --- code/modules/client/preference/preferences.dm | 116 ++++++++++-------- 1 file changed, 62 insertions(+), 54 deletions(-) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index a0061187528..f5647d158d4 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -261,6 +261,11 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts switch(current_tab) if(TAB_CHAR) // Character Settings var/datum/species/S = all_species[species] + if(!istype(S)) //The species was invalid. Set the species to the default, fetch the datum for that species and generate a random character. + species = initial(species) + S = all_species[species] + random_character() + dat += "
" dat += "
" dat += "Name: " @@ -291,10 +296,10 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(species == "Grey") dat += "Voice: [speciesprefs ? "Wingdings" : "Normal"]
" dat += "Secondary Language: [language]
" - if(istype(S) && S.autohiss_basic_map) + if(S.autohiss_basic_map) dat += "Auto-accent: [autohiss_mode == 2 ? "Full" : (autohiss_mode == 1 ? "Basic" : "Off")]
" dat += "Blood Type: [b_type]
" - if(istype(S) && S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) + if(S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) dat += "Skin Tone: [species == "Vox" ? "[s_tone]" : "[-s_tone + 35]/220"]
" dat += "Disabilities: \[Set\]
" dat += "Nanotrasen Relation: [nanotrasen_relation]
" @@ -306,7 +311,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "

Hair & Accessories

" - if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. + if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. var/headaccessoryname = "Head Accessory: " if(species == "Unathi") headaccessoryname = "Horns: " @@ -314,15 +319,15 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "[ha_style] " dat += "Color [color_square(r_headacc, g_headacc, b_headacc)]
" - if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. + if(S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. dat += "Head Markings: " dat += "[m_styles["head"]]" dat += "Color [color_square(color2R(m_colours["head"]), color2G(m_colours["head"]), color2B(m_colours["head"]))]
" - if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. + if(S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. dat += "Body Markings: " dat += "[m_styles["body"]]" dat += "Color [color_square(color2R(m_colours["body"]), color2G(m_colours["body"]), color2B(m_colours["body"]))]
" - if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. + if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. dat += "Tail Markings: " dat += "[m_styles["tail"]]" dat += "Color [color_square(color2R(m_colours["tail"]), color2G(m_colours["tail"]), color2B(m_colours["tail"]))]
" @@ -344,11 +349,11 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "
" - if(species != "Machine") + if(!(S.flags & ALL_RPARTS)) dat += "Eyes: " dat += "Color [color_square(r_eyes, g_eyes, b_eyes)]
" - if((istype(S) && S.bodyflags & HAS_SKIN_COLOR) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) //admins can always fuck with this, because they are admins + if((S.bodyflags & HAS_SKIN_COLOR) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) //admins can always fuck with this, because they are admins dat += "Body Color: " dat += "Color [color_square(r_skin, g_skin, b_skin)]
" @@ -365,7 +370,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "Character Records
" dat += "

Limbs

" - if(istype(S) && S.bodyflags & HAS_ALT_HEADS) //Species with alt heads. + if(S.bodyflags & HAS_ALT_HEADS) //Species with alt heads. dat += "Alternate Head: " dat += "[alt_head]
" dat += "Limbs and Parts: Adjust
" @@ -416,11 +421,11 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts else dat += "
" dat += "

Clothing

" - if(istype(S) && S.clothing_flags & HAS_UNDERWEAR) + if(S.clothing_flags & HAS_UNDERWEAR) dat += "Underwear: [underwear]
" - if(istype(S) && S.clothing_flags & HAS_UNDERSHIRT) + if(S.clothing_flags & HAS_UNDERSHIRT) dat += "Undershirt: [undershirt]
" - if(istype(S) && S.clothing_flags & HAS_SOCKS) + if(S.clothing_flags & HAS_SOCKS) dat += "Socks: [socks]
" dat += "Backpack Type: [backbag]
" @@ -1075,7 +1080,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("input") var/dflag=text2num(href_list["disability"]) if(dflag >= 0) - if(dflag==DISABILITY_FLAG_FAT && (istype(S) && S.flags & CAN_BE_FAT)) + if(dflag==DISABILITY_FLAG_FAT && (S.flags & CAN_BE_FAT)) disabilities ^= text2num(href_list["disability"]) //MAGIC SetDisabilities(user) else @@ -1161,7 +1166,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts switch(href_list["task"]) if("random") var/datum/robolimb/robohead - if(istype(S) && S.flags & ALL_RPARTS) + if(S.flags & ALL_RPARTS) var/head_model = "[!rlimb_data["head"] ? "Morpheus Cyberkinetics" : rlimb_data["head"]]" robohead = all_robolimbs[head_model] switch(href_list["preference"]) @@ -1194,30 +1199,30 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("f_style") f_style = random_facial_hair_style(gender, species, robohead) if("headaccessory") - if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. + if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. r_headacc = rand(0,255) g_headacc = rand(0,255) b_headacc = rand(0,255) if("ha_style") - if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. + if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. ha_style = random_head_accessory(species) if("m_style_head") - if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. + if(S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. m_styles["head"] = random_marking_style("head", species, robohead, null, alt_head) if("m_head_colour") - if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. + if(S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. m_colours["head"] = rgb(rand(0,255), rand(0,255), rand(0,255)) if("m_style_body") - if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings. + if(S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings. m_styles["body"] = random_marking_style("body", species) if("m_body_colour") - if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings. + if(S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings. m_colours["body"] = rgb(rand(0,255), rand(0,255), rand(0,255)) if("m_style_tail") - if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. + if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. m_styles["tail"] = random_marking_style("tail", species, null, body_accessory) if("m_tail_colour") - if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. + if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. m_colours["tail"] = rgb(rand(0,255), rand(0,255), rand(0,255)) if("underwear") underwear = random_underwear(gender, species) @@ -1233,10 +1238,10 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts g_eyes = rand(0,255) b_eyes = rand(0,255) if("s_tone") - if(istype(S) && S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) + if(S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) s_tone = random_skin_tone() if("s_color") - if(istype(S) && S.bodyflags & HAS_SKIN_COLOR) + if(S.bodyflags & HAS_SKIN_COLOR) r_skin = rand(0,255) g_skin = rand(0,255) b_skin = rand(0,255) @@ -1278,11 +1283,14 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts species = input("Please select a species", "Character Generation", null) in new_species var/datum/species/NS = all_species[species] + if(!istype(NS)) //The species was invalid. Set the species to the default and fetch the datum for that species. + species = initial(species) + NS = all_species[species] if(prev_species != species) if(NS.has_gender && gender == PLURAL) gender = pick(MALE,FEMALE) var/datum/robolimb/robohead - if(istype(NS) && NS.flags & ALL_RPARTS) + if(NS.flags & ALL_RPARTS) var/head_model = "[!rlimb_data["head"] ? "Morpheus Cyberkinetics" : rlimb_data["head"]]" robohead = all_robolimbs[head_model] //grab one of the valid hair styles for the newly chosen species @@ -1291,7 +1299,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts //grab one of the valid facial hair styles for the newly chosen species f_style = random_facial_hair_style(gender, species, robohead) - if(istype(NS) && NS.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. + if(NS.bodyflags & HAS_HEAD_ACCESSORY) //Species that have head accessories. ha_style = random_head_accessory(species) else ha_style = "None" // No Vulp ears on Unathi @@ -1299,19 +1307,19 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts g_headacc = 0 b_headacc = 0 - if(istype(NS) && NS.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. + if(NS.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. m_styles["head"] = random_marking_style("head", species, robohead, null, alt_head) else m_styles["head"] = "None" m_colours["head"] = "#000000" - if(istype(NS) && NS.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. + if(NS.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. m_styles["body"] = random_marking_style("body", species) else m_styles["body"] = "None" m_colours["body"] = "#000000" - if(istype(NS) && NS.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. + if(NS.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. m_styles["tail"] = random_marking_style("tail", species, null, body_accessory) else m_styles["tail"] = "None" @@ -1331,12 +1339,12 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts socks = random_socks(gender, species) //reset skin tone and colour - if(istype(NS) && NS.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) + if(NS.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) random_skin_tone(species) else s_tone = 0 - if(!(istype(NS) && NS.bodyflags & HAS_SKIN_COLOR)) + if(!(NS.bodyflags & HAS_SKIN_COLOR)) r_skin = 0 g_skin = 0 b_skin = 0 @@ -1350,7 +1358,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts organ_data = list() rlimb_data = list() - if(!(istype(NS) && NS.autohiss_basic_map)) + if(!(NS.autohiss_basic_map)) autohiss_mode = 0 if("speciesprefs") speciesprefs = !speciesprefs //Starts 0, so if someone clicks the button up top there, this won't be 0 anymore. If they click it again, it'll go back to 0. @@ -1377,7 +1385,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts language = input("Please select a secondary language", "Character Generation", null) in new_languages if("autohiss_mode") - if(istype(S) && S.autohiss_basic_map) + if(S.autohiss_basic_map) var/list/autohiss_choice = list("Off" = 0, "Basic" = 1, "Full" = 2) var/new_autohiss_pref = input(user, "Choose your character's auto-accent level:", "Character Preference") as null|anything in autohiss_choice autohiss_mode = autohiss_choice[new_autohiss_pref] @@ -1419,7 +1427,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(hairstyle == "Bald") //Just in case. valid_hairstyles += hairstyle continue - if(istype(S) && S.flags & ALL_RPARTS) //Species that can use prosthetic heads. + if(S.flags & ALL_RPARTS) //Species that can use prosthetic heads. var/head_model if(!rlimb_data["head"]) //Handle situations where the head is default. head_model = "Morpheus Cyberkinetics" @@ -1441,7 +1449,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts h_style = new_h_style if("headaccessory") - if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories. + if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories. var/input = "Choose the colour of your your character's head accessory:" var/new_head_accessory = input(user, input, "Character Preference", rgb(r_headacc, g_headacc, b_headacc)) as color|null if(new_head_accessory) @@ -1450,7 +1458,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts b_headacc = color2B(new_head_accessory) if("ha_style") - if(istype(S) && S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories. + if(S.bodyflags & HAS_HEAD_ACCESSORY) //Species with head accessories. var/list/valid_head_accessory_styles = list() for(var/head_accessory_style in head_accessory_styles_list) var/datum/sprite_accessory/H = head_accessory_styles_list[head_accessory_style] @@ -1466,7 +1474,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("alt_head") if(organ_data["head"] == "cyborg") return - if(istype(S) && S.bodyflags & HAS_ALT_HEADS) //Species with alt heads. + if(S.bodyflags & HAS_ALT_HEADS) //Species with alt heads. var/list/valid_alt_heads = list() valid_alt_heads["None"] = alt_heads_list["None"] //The only null entry should be the "None" option for(var/alternate_head in alt_heads_list) @@ -1486,7 +1494,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["head"] = "None" if("m_style_head") - if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. + if(S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. var/list/valid_markings = list() valid_markings["None"] = marking_styles_list["None"] for(var/markingstyle in marking_styles_list) @@ -1502,7 +1510,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(M.heads_allowed && !("All" in M.heads_allowed)) continue - if(istype(S) && S.flags & ALL_RPARTS) //Species that can use prosthetic heads. + if(S.flags & ALL_RPARTS) //Species that can use prosthetic heads. var/head_model if(!rlimb_data["head"]) //Handle situations where the head is default. head_model = "Morpheus Cyberkinetics" @@ -1522,14 +1530,14 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["head"] = new_marking_style if("m_head_colour") - if(istype(S) && S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. + if(S.bodyflags & HAS_HEAD_MARKINGS) //Species with head markings. var/input = "Choose the colour of your your character's head markings:" var/new_markings = input(user, input, "Character Preference", m_colours["head"]) as color|null if(new_markings) m_colours["head"] = new_markings if("m_style_body") - if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. + if(S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. var/list/valid_markings = list() valid_markings["None"] = marking_styles_list["None"] for(var/markingstyle in marking_styles_list) @@ -1546,14 +1554,14 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["body"] = new_marking_style if("m_body_colour") - if(istype(S) && S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. + if(S.bodyflags & HAS_BODY_MARKINGS) //Species with body markings/tattoos. var/input = "Choose the colour of your your character's body markings:" var/new_markings = input(user, input, "Character Preference", m_colours["body"]) as color|null if(new_markings) m_colours["body"] = new_markings if("m_style_tail") - if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. + if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. var/list/valid_markings = list() valid_markings["None"] = marking_styles_list["None"] for(var/markingstyle in marking_styles_list) @@ -1576,7 +1584,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts m_styles["tail"] = new_marking_style if("m_tail_colour") - if(istype(S) && S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. + if(S.bodyflags & HAS_TAIL_MARKINGS) //Species with tail markings. var/input = "Choose the colour of your your character's tail markings:" var/new_markings = input(user, input, "Character Preference", m_colours["tail"]) as color|null if(new_markings) @@ -1630,7 +1638,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts continue if(gender == FEMALE && SA.gender == MALE) continue - if(istype(S) && S.flags & ALL_RPARTS) //Species that can use prosthetic heads. + if(S.flags & ALL_RPARTS) //Species that can use prosthetic heads. var/head_model if(!rlimb_data["head"]) //Handle situations where the head is default. head_model = "Morpheus Cyberkinetics" @@ -1706,11 +1714,11 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts b_eyes = color2B(new_eyes) if("s_tone") - if(istype(S) && S.bodyflags & HAS_SKIN_TONE) + if(S.bodyflags & HAS_SKIN_TONE) var/new_s_tone = input(user, "Choose your character's skin-tone:\n(Light 1 - 220 Dark)", "Character Preference") as num|null if(new_s_tone) s_tone = 35 - max(min(round(new_s_tone), 220), 1) - else if(istype(S) && S.bodyflags & HAS_ICON_SKIN_TONE) + else if(S.bodyflags & HAS_ICON_SKIN_TONE) var/const/MAX_LINE_ENTRIES = 4 var/prompt = "Choose your character's skin tone: 1-[S.icon_skin_tones.len]\n(" for(var/i = 1 to S.icon_skin_tones.len) @@ -1725,7 +1733,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts s_tone = max(min(round(skin_c), S.icon_skin_tones.len), 1) if("skin") - if((istype(S) && S.bodyflags & HAS_SKIN_COLOR) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) + if((S.bodyflags & HAS_SKIN_COLOR) || body_accessory_by_species[species] || check_rights(R_ADMIN, 0, user)) var/new_skin = input(user, "Choose your character's skin colour: ", "Character Preference", rgb(r_skin, g_skin, b_skin)) as color|null if(new_skin) r_skin = color2R(new_skin) @@ -1759,7 +1767,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("limbs") var/valid_limbs = list("Left Leg", "Right Leg", "Left Arm", "Right Arm", "Left Foot", "Right Foot", "Left Hand", "Right Hand") - if(istype(S) && S.flags & ALL_RPARTS) + if(S.flags & ALL_RPARTS) valid_limbs = list("Torso", "Lower Body", "Head", "Left Leg", "Right Leg", "Left Arm", "Right Arm", "Left Foot", "Right Foot", "Left Hand", "Right Hand") var/limb_name = input(user, "Which limb do you want to change?") as null|anything in valid_limbs if(!limb_name) return @@ -1795,19 +1803,19 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts second_limb = "r_hand" if("Left Foot") limb = "l_foot" - if(!(istype(S) && S.flags & ALL_RPARTS)) + if(!(S.flags & ALL_RPARTS)) third_limb = "l_leg" if("Right Foot") limb = "r_foot" - if(!(istype(S) && S.flags & ALL_RPARTS)) + if(!(S.flags & ALL_RPARTS)) third_limb = "r_leg" if("Left Hand") limb = "l_hand" - if(!(istype(S) && S.flags & ALL_RPARTS)) + if(!(S.flags & ALL_RPARTS)) third_limb = "l_arm" if("Right Hand") limb = "r_hand" - if(!(istype(S) && S.flags & ALL_RPARTS)) + if(!(S.flags & ALL_RPARTS)) third_limb = "r_arm" var/new_state = input(user, "What state do you wish the limb to be in?") as null|anything in valid_limb_states @@ -1863,7 +1871,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if(subchoice) choice = subchoice if(limb in list("head", "chest", "groin")) - if(!(istype(S) && S.flags & ALL_RPARTS)) + if(!(S.flags & ALL_RPARTS)) return if(limb == "head") ha_style = "None" From 63379b1723edf9d9fe49e338a555947a0f41c20e Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Mon, 1 May 2017 02:04:09 -0400 Subject: [PATCH 4/5] Adjusts Failure Behaviour of Species-changing in Charsetup & Uses Defines --- code/modules/client/preference/preferences.dm | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index f5647d158d4..f4bc656f914 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -1265,7 +1265,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("age") var/new_age = input(user, "Choose your character's age:\n([AGE_MIN]-[AGE_MAX])", "Character Preference") as num|null if(new_age) - age = max(min( round(text2num(new_age)), AGE_MAX),AGE_MIN) + age = max(min(round(text2num(new_age)), AGE_MAX),AGE_MIN) if("species") var/list/new_species = list("Human", "Tajaran", "Skrell", "Unathi", "Diona", "Vulpkanin") var/prev_species = species @@ -1283,9 +1283,10 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts species = input("Please select a species", "Character Generation", null) in new_species var/datum/species/NS = all_species[species] - if(!istype(NS)) //The species was invalid. Set the species to the default and fetch the datum for that species. - species = initial(species) - NS = all_species[species] + if(!istype(NS)) //The species was invalid. Notify the user and fail out. + species = prev_species + to_chat(user, "Invalid species, please pick something else.") + return if(prev_species != species) if(NS.has_gender && gender == PLURAL) gender = pick(MALE,FEMALE) @@ -1359,7 +1360,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts rlimb_data = list() if(!(NS.autohiss_basic_map)) - autohiss_mode = 0 + autohiss_mode = AUTOHISS_OFF if("speciesprefs") speciesprefs = !speciesprefs //Starts 0, so if someone clicks the button up top there, this won't be 0 anymore. If they click it again, it'll go back to 0. if("language") @@ -1386,7 +1387,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts if("autohiss_mode") if(S.autohiss_basic_map) - var/list/autohiss_choice = list("Off" = 0, "Basic" = 1, "Full" = 2) + var/list/autohiss_choice = list("Off" = AUTOHISS_OFF, "Basic" = AUTOHISS_BASIC, "Full" = AUTOHISS_FULL) var/new_autohiss_pref = input(user, "Choose your character's auto-accent level:", "Character Preference") as null|anything in autohiss_choice autohiss_mode = autohiss_choice[new_autohiss_pref] From f2230c00b4ea40fec089fcb01bf41cf6ee2b9470 Mon Sep 17 00:00:00 2001 From: KasparoVy Date: Mon, 1 May 2017 15:53:38 -0400 Subject: [PATCH 5/5] One Last Define & One Last Missed Spot --- code/__DEFINES/language.dm | 1 + code/modules/client/preference/preferences.dm | 8 ++++---- code/modules/mob/living/autohiss.dm | 3 --- 3 files changed, 5 insertions(+), 7 deletions(-) diff --git a/code/__DEFINES/language.dm b/code/__DEFINES/language.dm index 87a8805ca7e..2af0fd6ade8 100644 --- a/code/__DEFINES/language.dm +++ b/code/__DEFINES/language.dm @@ -23,3 +23,4 @@ #define AUTOHISS_OFF 0 #define AUTOHISS_BASIC 1 #define AUTOHISS_FULL 2 +#define AUTOHISS_NUM 3 //Number of auto-accent options. diff --git a/code/modules/client/preference/preferences.dm b/code/modules/client/preference/preferences.dm index f4bc656f914..b5250e49bd3 100644 --- a/code/modules/client/preference/preferences.dm +++ b/code/modules/client/preference/preferences.dm @@ -297,10 +297,10 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts dat += "Voice: [speciesprefs ? "Wingdings" : "Normal"]
" dat += "Secondary Language: [language]
" if(S.autohiss_basic_map) - dat += "Auto-accent: [autohiss_mode == 2 ? "Full" : (autohiss_mode == 1 ? "Basic" : "Off")]
" + dat += "Auto-accent: [autohiss_mode == AUTOHISS_FULL ? "Full" : (autohiss_mode == AUTOHISS_BASIC ? "Basic" : "Off")]
" dat += "Blood Type: [b_type]
" if(S.bodyflags & (HAS_SKIN_TONE|HAS_ICON_SKIN_TONE)) - dat += "Skin Tone: [species == "Vox" ? "[s_tone]" : "[-s_tone + 35]/220"]
" + dat += "Skin Tone: [S.bodyflags & HAS_ICON_SKIN_TONE ? "[s_tone]" : "[-s_tone + 35]/220"]
" dat += "Disabilities: \[Set\]
" dat += "Nanotrasen Relation: [nanotrasen_relation]
" dat += "Set Flavor Text
" @@ -1402,7 +1402,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts b_type = new_b_type if("hair") - if(species in list("Human", "Unathi", "Tajaran", "Skrell", "Machine", "Vulpkanin", "Vox")) + if(species in list("Human", "Unathi", "Tajaran", "Skrell", "Machine", "Vulpkanin", "Vox")) //Species that have hair. (No HAS_HAIR flag) var/input = "Choose your character's hair colour:" var/new_hair = input(user, input, "Character Preference", rgb(r_hair, g_hair, b_hair)) as color|null if(new_hair) @@ -1610,7 +1610,7 @@ var/global/list/special_role_times = list( //minimum age (in days) for accounts body_accessory = (new_body_accessory == "None") ? null : new_body_accessory if("facial") - if(species in list("Human", "Unathi", "Tajaran", "Skrell", "Machine", "Vulpkanin", "Vox")) + if(species in list("Human", "Unathi", "Tajaran", "Skrell", "Machine", "Vulpkanin", "Vox")) //Species that have facial hair. (No HAS_HAIR_FACIAL flag) var/new_facial = input(user, "Choose your character's facial-hair colour:", "Character Preference", rgb(r_facial, g_facial, b_facial)) as color|null if(new_facial) r_facial = color2R(new_facial) diff --git a/code/modules/mob/living/autohiss.dm b/code/modules/mob/living/autohiss.dm index 0c2c6defeb8..da19b6a35b2 100644 --- a/code/modules/mob/living/autohiss.dm +++ b/code/modules/mob/living/autohiss.dm @@ -1,6 +1,3 @@ -#define AUTOHISS_NUM 3 - - /mob/living/proc/handle_autohiss(message, datum/language/L) return message // no autohiss at this level