diff --git a/code/datums/dna.dm b/code/datums/dna.dm index 785b70eb475..3d69a40dbdd 100644 --- a/code/datums/dna.dm +++ b/code/datums/dna.dm @@ -524,25 +524,31 @@ GLOBAL_LIST_INIT(total_uf_len_by_block, populate_total_uf_len_by_block()) /mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE) if(QDELETED(src)) CRASH("You're trying to change your species post deletion, this is a recipe for madness") - if(mrace && has_dna()) - var/datum/species/new_race - if(ispath(mrace)) - new_race = new mrace - else if(istype(mrace)) - new_race = mrace - else - return - death_sound = new_race.death_sound + if(isnull(mrace)) + CRASH("set_species called without a species to set to") + if(!has_dna()) + return + + var/datum/species/new_race + if(ispath(mrace)) + new_race = new mrace + else if(istype(mrace)) + if(QDELING(mrace)) + CRASH("someone is calling set_species() and is passing it a qdeling species datum, this is VERY bad, stop it") + new_race = mrace + else + CRASH("set_species called with an invalid mrace [mrace]") - var/datum/species/old_species = dna.species - dna.species = new_race + death_sound = new_race.death_sound - if (old_species.properly_gained) - old_species.on_species_loss(src, new_race, pref_load) + var/datum/species/old_species = dna.species + dna.species = new_race - dna.species.on_species_gain(src, old_species, pref_load) - log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]") + if (old_species.properly_gained) + old_species.on_species_loss(src, new_race, pref_load) + dna.species.on_species_gain(src, old_species, pref_load) + log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]") */ //SKYRAT EDIT REMOVAL END diff --git a/code/game/objects/structures/mirror.dm b/code/game/objects/structures/mirror.dm index ff8c1c57814..f51ef9c76d8 100644 --- a/code/game/objects/structures/mirror.dm +++ b/code/game/objects/structures/mirror.dm @@ -152,17 +152,17 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror/broken, 28) var/racechoice = tgui_input_list(race_changer, "What are we again?", "Race change", selectable_races) if(isnull(racechoice)) return TRUE - if(!selectable_races[racechoice]) - return TRUE - - var/datum/species/newrace = new selectable_races[racechoice] + var/new_race_path = selectable_races[racechoice] + if(!ispath(new_race_path, /datum/species)) + return TRUE + var/datum/species/newrace = new new_race_path() var/attributes_desc = newrace.get_physical_attributes() - qdel(newrace) var/answer = tgui_alert(race_changer, attributes_desc, "Become a [newrace]?", list("Yes", "No")) if(answer != "Yes") + qdel(newrace) change_race(race_changer) // try again return diff --git a/modular_skyrat/modules/customization/datums/dna.dm b/modular_skyrat/modules/customization/datums/dna.dm index 4ae22fceab5..7e0fb14838c 100644 --- a/modular_skyrat/modules/customization/datums/dna.dm +++ b/modular_skyrat/modules/customization/datums/dna.dm @@ -189,46 +189,54 @@ GLOBAL_LIST_EMPTY(total_uf_len_by_block) /mob/living/carbon/set_species(datum/species/mrace, icon_update = TRUE, pref_load = FALSE, list/override_features, list/override_mutantparts, list/override_markings, retain_features = FALSE, retain_mutantparts = FALSE) if(QDELETED(src)) CRASH("You're trying to change your species post deletion, this is a recipe for madness") - if(mrace && has_dna()) - var/datum/species/new_race - if(ispath(mrace)) - new_race = new mrace - else if(istype(mrace)) - new_race = mrace - else - return - death_sound = new_race.death_sound - var/datum/species/old_species = dna.species - dna.species = new_race + if(isnull(mrace)) + CRASH("set_species called without a species to set to") + if(!has_dna()) + return + + var/datum/species/new_race + if(ispath(mrace)) + new_race = new mrace + else if(istype(mrace)) + if(QDELING(mrace)) + CRASH("someone is calling set_species() and is passing it a qdeling species datum, this is VERY bad, stop it") + new_race = mrace + else + CRASH("set_species called with an invalid mrace [mrace]") + + death_sound = new_race.death_sound + + var/datum/species/old_species = dna.species + dna.species = new_race - if (old_species.properly_gained) - old_species.on_species_loss(src, new_race, pref_load) + if (old_species.properly_gained) + old_species.on_species_loss(src, new_race, pref_load) - //BODYPARTS AND FEATURES - We need to instantiate the list with compatible mutant parts so we don't break things + //BODYPARTS AND FEATURES - We need to instantiate the list with compatible mutant parts so we don't break things - if(override_mutantparts && override_mutantparts.len) - for(var/feature in dna.mutant_bodyparts) - override_mutantparts[feature] = dna.mutant_bodyparts[feature] - dna.mutant_bodyparts = override_mutantparts + if(override_mutantparts && override_mutantparts.len) + for(var/feature in dna.mutant_bodyparts) + override_mutantparts[feature] = dna.mutant_bodyparts[feature] + dna.mutant_bodyparts = override_mutantparts - if(override_markings && override_markings.len) - for(var/feature in dna.body_markings) - override_markings[feature] = dna.body_markings[feature] - dna.body_markings = override_markings + if(override_markings && override_markings.len) + for(var/feature in dna.body_markings) + override_markings[feature] = dna.body_markings[feature] + dna.body_markings = override_markings - if(override_features && override_features.len) - for(var/feature in dna.features) - override_features[feature] = dna.features[feature] - dna.features = override_features - //END OF BODYPARTS AND FEATURES + if(override_features && override_features.len) + for(var/feature in dna.features) + override_features[feature] = dna.features[feature] + dna.features = override_features + //END OF BODYPARTS AND FEATURES - apply_customizable_dna_features_to_species() - dna.unique_features = dna.generate_unique_features() + apply_customizable_dna_features_to_species() + dna.unique_features = dna.generate_unique_features() - dna.update_body_size() + dna.update_body_size() - dna.species.on_species_gain(src, old_species, pref_load) - log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]") + dna.species.on_species_gain(src, old_species, pref_load) + log_mob_tag("TAG: [tag] SPECIES: [key_name(src)] \[[mrace]\]") /mob/living/carbon/proc/apply_customizable_dna_features_to_species()