From a3d01c18f7aff4bb18f20f1fbcdcd22dc5ee4e9a Mon Sep 17 00:00:00 2001 From: Iren <69871346+Kiyahitayika@users.noreply.github.com> Date: Wed, 21 Oct 2020 09:45:44 -0400 Subject: [PATCH] PR - Gender Update (#14406) * PR - Gender Update Gives Gender three states instead of two. This allows clones of tri-gendered species to properly carry their genders over to new bodies (e.g. Greys, Drask, etc.). Tristate Gender Set Proc Tristate Gender Get Proc Fixes where Binary State was needed. * Update update_icons.dm Yeah, let's _not_ have Genderless folks get inconsistently gendered body part sprites (e.g. head, groin, torso mismatch). * Update dna2.dm * Update dna2.dm * Update organ_icon.dm * Update update_icons.dm * Update dna2_helpers.dm * Update organ_icon.dm Readability (spacing) * Update dna_injector.dm * Update dna2.dm * Changes made per Affected's requests. Changes made per Affected's feedback. * Update dna2.dm Got our heads too deep in using this just for DNA_UI_GENDERr - returning the Set and Get procs to 0, 1, 2 as per Affected's request. While in there, noticed some housekeeping items: - reorganized the ranges so they flow numerically now - changed the ranges so they don't overlap (line 205 having been the worst) - removed the "else" statement from line 222 since we're using ASSERTS. There shouldn't be a value outside the range of 0 to 2 for this. --- code/__DEFINES/dna.dm | 5 +++ code/game/dna/dna2.dm | 45 ++++++++++++++++--- code/game/dna/dna2_helpers.dm | 13 +++--- .../mob/living/carbon/human/update_icons.dm | 5 ++- code/modules/surgery/organs/organ_icon.dm | 11 +++-- 5 files changed, 62 insertions(+), 17 deletions(-) diff --git a/code/__DEFINES/dna.dm b/code/__DEFINES/dna.dm index 7984c1a6dde..10da1be145e 100644 --- a/code/__DEFINES/dna.dm +++ b/code/__DEFINES/dna.dm @@ -55,3 +55,8 @@ #define DNA_UI_LENGTH 38 // Update this when you add something, or you WILL break shit. #define DNA_SE_LENGTH 55 // Was STRUCDNASIZE, size 27. 15 new blocks added = 42, plus room to grow. + +//Trinary State Values for DNA_UI_GENDER +#define DNA_GENDER_FEMALE 0 +#define DNA_GENDER_MALE 1 +#define DNA_GENDER_PLURAL 2 diff --git a/code/game/dna/dna2.dm b/code/game/dna/dna2.dm index 1a92210f570..a9a91ebf17f 100644 --- a/code/game/dna/dna2.dm +++ b/code/game/dna/dna2.dm @@ -85,7 +85,6 @@ GLOBAL_LIST_EMPTY(bad_blocks) // FIXME: Species-specific defaults pls var/obj/item/organ/external/head/H = character.get_organ("head") var/obj/item/organ/internal/eyes/eyes_organ = character.get_int_organ(/obj/item/organ/internal/eyes) - var/datum/species/S = character.dna.species /*// Body Accessory if(!character.body_accessory) @@ -121,16 +120,20 @@ GLOBAL_LIST_EMPTY(bad_blocks) SetUIValueRange(DNA_UI_SKIN_TONE, 35-character.s_tone, 220, 1) // Value can be negative. - if(S.has_gender) - SetUIState(DNA_UI_GENDER, character.gender!=MALE, 1) - else - SetUIState(DNA_UI_GENDER, pick(0,1), 1) - /*SetUIValueRange(DNA_UI_BACC_STYLE, bodyacc, GLOB.facial_hair_styles_list.len, 1)*/ SetUIValueRange(DNA_UI_HEAD_MARK_STYLE, head_marks, GLOB.marking_styles_list.len, 1) SetUIValueRange(DNA_UI_BODY_MARK_STYLE, body_marks, GLOB.marking_styles_list.len, 1) SetUIValueRange(DNA_UI_TAIL_MARK_STYLE, tail_marks, GLOB.marking_styles_list.len, 1) + //Set the Gender + switch(character.gender) + if(FEMALE) + SetUITriState(DNA_UI_GENDER, DNA_GENDER_FEMALE, 1) + if(MALE) + SetUITriState(DNA_UI_GENDER, DNA_GENDER_MALE, 1) + if(PLURAL) + SetUITriState(DNA_UI_GENDER, DNA_GENDER_PLURAL, 1) + UpdateUI() @@ -189,6 +192,36 @@ GLOBAL_LIST_EMPTY(bad_blocks) val=rand(1, 2049) SetUIValue(block, val, defer) +//Get Tri State Block State +/datum/dna/proc/GetUITriState(block) + if(block <= 0) + return + var/val = GetUIValue(block) + switch(val) + if(1 to 1395) + return 0 + if(1396 to 2760) + return 1 + if(2761 to 4095) + return 2 + +// Set Trinary UI Block State +/datum/dna/proc/SetUITriState(block, value, defer = FALSE) + if(block <= 0) + return + ASSERT(value >= 0) + ASSERT(value <= 2) + var/val + switch(value) + if(0) + val = rand(1, 1395) + if(1) + val = rand(1396, 2760) + if(2) + val = rand(2761, 4095) + SetUIValue(block, val, defer) + + // Get a hex-encoded UI block. /datum/dna/proc/GetUIBlock(block) return EncodeDNABlock(GetUIValue(block)) diff --git a/code/game/dna/dna2_helpers.dm b/code/game/dna/dna2_helpers.dm index 435133a3796..7ded549f29b 100644 --- a/code/game/dna/dna2_helpers.dm +++ b/code/game/dna/dna2_helpers.dm @@ -136,7 +136,6 @@ var/mob/living/carbon/human/H = src var/obj/item/organ/external/head/head_organ = H.get_organ("head") var/obj/item/organ/internal/eyes/eye_organ = H.get_int_organ(/obj/item/organ/internal/eyes) - var/datum/species/S = H.dna.species if(istype(head_organ)) dna.write_head_attributes(head_organ) if(istype(eye_organ)) @@ -151,11 +150,13 @@ H.s_tone = 35 - dna.GetUIValueRange(DNA_UI_SKIN_TONE, 220) // Value can be negative. - if(S.has_gender) - if(dna.GetUIState(DNA_UI_GENDER)) - H.change_gender(FEMALE, 0) - else - H.change_gender(MALE, 0) + switch(dna.GetUITriState(DNA_UI_GENDER)) + if(DNA_GENDER_FEMALE) + H.change_gender(FEMALE, FALSE) + if(DNA_GENDER_MALE) + H.change_gender(MALE, FALSE) + if(DNA_GENDER_PLURAL) + H.change_gender(PLURAL, FALSE) //Head Markings var/head_marks = dna.GetUIValueRange(DNA_UI_HEAD_MARK_STYLE, GLOB.marking_styles_list.len) diff --git a/code/modules/mob/living/carbon/human/update_icons.dm b/code/modules/mob/living/carbon/human/update_icons.dm index e667833dfe3..71ee1e00871 100644 --- a/code/modules/mob/living/carbon/human/update_icons.dm +++ b/code/modules/mob/living/carbon/human/update_icons.dm @@ -1289,6 +1289,9 @@ GLOBAL_LIST_EMPTY(damage_icon_parts) var/husk = (HUSK in mutations) var/hulk = (HULK in mutations) var/skeleton = (SKELETON in mutations) + var/g = dna.GetUITriState(DNA_UI_GENDER) + if(g == DNA_GENDER_PLURAL) + g = DNA_GENDER_FEMALE . = "" @@ -1317,8 +1320,8 @@ GLOBAL_LIST_EMPTY(damage_icon_parts) if(part) var/datum/species/S = GLOB.all_species[part.dna.species.name] . += "[S.race_key]" - . += "[part.dna.GetUIState(DNA_UI_GENDER)]" . += "[part.dna.GetUIValue(DNA_UI_SKIN_TONE)]" + . += "[g]" if(part.s_col) . += "[part.s_col]" if(part.s_tone) diff --git a/code/modules/surgery/organs/organ_icon.dm b/code/modules/surgery/organs/organ_icon.dm index b41ef824508..ba98554bfbe 100644 --- a/code/modules/surgery/organs/organ_icon.dm +++ b/code/modules/surgery/organs/organ_icon.dm @@ -162,10 +162,13 @@ GLOBAL_LIST_EMPTY(limb_icon_cache) new_icon_state = "[icon_name][gendered_icon ? "_f" : ""]" else if(gendered_icon) - if(dna.GetUIState(DNA_UI_GENDER)) - gender = "f" - else - gender = "m" + switch(dna.GetUITriState(DNA_UI_GENDER)) + if(DNA_GENDER_FEMALE) + gender = "f" + if(DNA_GENDER_MALE) + gender = "m" + else + gender = "f" //Default to "f" (per line 162). Using a pick("m", "f") will make different body parts different genders for the same character. if(limb_name == "head") var/obj/item/organ/external/head/head_organ = src head_organ.handle_alt_icon()