Skip to content

Commit

Permalink
Merge pull request #178 from honkpocket/early-tg87215
Browse files Browse the repository at this point in the history
Early mirror of tgstation:87215
  • Loading branch information
Nerev4r authored Oct 19, 2024
2 parents a14a4fc + d742151 commit 0693def
Show file tree
Hide file tree
Showing 22 changed files with 95 additions and 99 deletions.
6 changes: 6 additions & 0 deletions code/__DEFINES/living.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,12 @@
/// Always does *deathgasp when they die
/// If unset mobs will only deathgasp if supplied a death sound or custom death message
#define ALWAYS_DEATHGASP (1<<1)
/**
* For carbons, this stops bodypart overlays being added to bodyparts from calling mob.update_body_parts().
* This is useful for situations like initialization or species changes, where
* update_body_parts() is going to be called ONE time once everything is done.
*/
#define STOP_OVERLAY_UPDATE_BODY_PARTS (1<<2)

/// Getter for a mob/living's lying angle, otherwise protected
#define GET_LYING_ANGLE(mob) (UNLINT(mob.lying_angle))
5 changes: 0 additions & 5 deletions code/datums/bodypart_overlays/emote_bodypart_overlay.dm
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,6 @@
if(!referenced_bodypart)
return ..()
referenced_bodypart.remove_bodypart_overlay(src)
if(referenced_bodypart.owner) //Keep in mind that the bodypart could have been severed from the owner by now
referenced_bodypart.owner.update_body_parts()
else
referenced_bodypart.update_icon_dropped()
return ..()

/**
Expand All @@ -49,7 +45,6 @@
if(!bodypart)
return null
bodypart.add_bodypart_overlay(overlay)
src.update_body_parts()
return overlay

/datum/bodypart_overlay/simple/emote/blush
Expand Down
6 changes: 0 additions & 6 deletions code/datums/components/face_decal.dm
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,6 @@
bodypart_overlay.draw_color = color
my_head.add_bodypart_overlay(bodypart_overlay)
RegisterSignals(my_head, list(COMSIG_BODYPART_REMOVED, COMSIG_QDELETING), PROC_REF(lost_head))
carbon_parent.update_body_parts()
else
normal_overlay = get_normal_overlay()
normal_overlay.color = color
Expand Down Expand Up @@ -79,14 +78,9 @@
if(my_head)
if(bodypart_overlay)
my_head.remove_bodypart_overlay(bodypart_overlay)
if(!my_head.owner)
my_head.update_icon_dropped()
QDEL_NULL(bodypart_overlay)
UnregisterSignal(my_head, list(COMSIG_BODYPART_REMOVED, COMSIG_QDELETING))
my_head = null
if(iscarbon(parent))
var/mob/living/carbon/carbon_parent = parent
carbon_parent.update_body_parts()
if(normal_overlay)
var/atom/atom_parent = parent
UnregisterSignal(atom_parent, COMSIG_ATOM_UPDATE_OVERLAYS)
Expand Down
5 changes: 2 additions & 3 deletions code/datums/diseases/advance/symptoms/shedding.dm
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@
/datum/symptom/shedding/proc/baldify(mob/living/carbon/human/baldie, fully_bald)
if(fully_bald)
baldie.set_facial_hairstyle("Shaved", update = FALSE)
baldie.set_hairstyle("Bald", update = FALSE)
baldie.set_hairstyle("Bald") //this will call update_body_parts()
else
baldie.set_hairstyle("Balding Hair", update = FALSE)
baldie.update_body_parts()
baldie.set_hairstyle("Balding Hair")
5 changes: 1 addition & 4 deletions code/datums/quirks/negative_quirks/all_nighter.dm
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@
return
bodypart_overlay = new() //creates our overlay
face.add_bodypart_overlay(bodypart_overlay)
sleepy_head.update_body_parts() //make sure to update icon

///removes the bag overlay
/datum/quirk/all_nighter/proc/remove_bags()
var/mob/living/carbon/human/sleepy_head = quirk_holder
var/obj/item/bodypart/head/face = sleepy_head?.get_bodypart(BODY_ZONE_HEAD)
if(face)
face.remove_bodypart_overlay(bodypart_overlay)
sleepy_head.update_body_parts()
face?.remove_bodypart_overlay(bodypart_overlay)
QDEL_NULL(bodypart_overlay)

/**
Expand Down
24 changes: 5 additions & 19 deletions code/datums/status_effects/buffs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -306,26 +306,12 @@
newRod.activated()
if(!itemUser.has_hand_for_held_index(hand))
//If user does not have the corresponding hand anymore, give them one and return the rod to their hand
if(((hand % 2) == 0))
var/obj/item/bodypart/L = itemUser.newBodyPart(BODY_ZONE_R_ARM, FALSE, FALSE)
if(L.try_attach_limb(itemUser))
L.update_limb(is_creating = TRUE)
itemUser.update_body_parts()
itemUser.put_in_hand(newRod, hand, forced = TRUE)
else
qdel(L)
consume_owner() //we can't regrow, abort abort
return
var/zone = (hand % 2) ? BODY_ZONE_L_ARM : BODY_ZONE_R_ARM
if(itemUser.regenerate_limb(zone, FALSE))
itemUser.put_in_hand(newRod, hand, forced = TRUE)
else
var/obj/item/bodypart/L = itemUser.newBodyPart(BODY_ZONE_L_ARM, FALSE, FALSE)
if(L.try_attach_limb(itemUser))
L.update_limb(is_creating = TRUE)
itemUser.update_body_parts()
itemUser.put_in_hand(newRod, hand, forced = TRUE)
else
qdel(L)
consume_owner() //see above comment
return
consume_owner() //we can't regrow, abort abort
return
to_chat(itemUser, span_notice("Your arm suddenly grows back with the Rod of Asclepius still attached!"))
else
//Otherwise get rid of whatever else is in their hand and return the rod to said hand
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,17 +108,13 @@
/datum/bodypart_overlay/simple/golem_overlay/proc/add_to_bodypart(prefix, obj/item/bodypart/part)
icon_state = "[prefix]_[part.body_zone]"
attached_bodypart = WEAKREF(part)
part.add_bodypart_overlay(src)
part.add_bodypart_overlay(src, update = FALSE)

/datum/bodypart_overlay/simple/golem_overlay/Destroy(force)
var/obj/item/bodypart/referenced_bodypart = attached_bodypart.resolve()
if(!referenced_bodypart)
return ..()
referenced_bodypart.remove_bodypart_overlay(src)
if(referenced_bodypart.owner) //Keep in mind that the bodypart could have been severed from the owner by now
referenced_bodypart.owner.update_body_parts()
else
referenced_bodypart.update_icon_dropped()
return ..()

/// Freezes hunger for the duration
Expand Down
5 changes: 2 additions & 3 deletions code/game/objects/structures/mirror.dm
Original file line number Diff line number Diff line change
Expand Up @@ -346,14 +346,13 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/mirror/broken, 28)
var/new_hair_color = input(user, "Choose your hair color", "Hair Color", user.hair_color) as color|null

if(new_hair_color)
user.set_haircolor(sanitize_hexcolor(new_hair_color), update = FALSE)
user.set_haircolor(sanitize_hexcolor(new_hair_color))
user.dna.update_ui_block(DNA_HAIR_COLOR_BLOCK)
if(user.physique == MALE)
var/new_face_color = input(user, "Choose your facial hair color", "Hair Color", user.facial_hair_color) as color|null
if(new_face_color)
user.set_facial_haircolor(sanitize_hexcolor(new_face_color), update = FALSE)
user.set_facial_haircolor(sanitize_hexcolor(new_face_color))
user.dna.update_ui_block(DNA_FACIAL_HAIR_COLOR_BLOCK)
user.update_body_parts()

/obj/structure/mirror/magic/attack_hand(mob/living/carbon/human/user)
. = ..()
Expand Down
6 changes: 4 additions & 2 deletions code/modules/mob/living/brain/brain_item.dm
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,8 @@
trauma.on_gain()

//Update the body's icon so it doesnt appear debrained anymore
brain_owner.update_body_parts()
if(!special && !(brain_owner.living_flags & STOP_OVERLAY_UPDATE_BODY_PARTS))
brain_owner.update_body_parts()

/obj/item/organ/internal/brain/mob_remove(mob/living/carbon/organ_owner, special, movement_flags)
// Delete skillchips first as parent proc sets owner to null, and skillchips need to know the brain's owner.
Expand All @@ -134,7 +135,8 @@
if((!gc_destroyed || (owner && !owner.gc_destroyed)) && !(movement_flags & NO_ID_TRANSFER))
transfer_identity(organ_owner)
if(!special)
organ_owner.update_body_parts()
if(!(organ_owner.living_flags & STOP_OVERLAY_UPDATE_BODY_PARTS))
organ_owner.update_body_parts()
organ_owner.clear_mood_event("brain_damage")

/obj/item/organ/internal/brain/update_icon_state()
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/carbon/alien/alien_update_icons.dm
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
/mob/living/carbon/alien/update_damage_overlays() //aliens don't have damage overlays.
return

/mob/living/carbon/alien/update_body() // we don't use the bodyparts or body layers for aliens.
/mob/living/carbon/alien/update_body(is_creating = FALSE) // we don't use the bodyparts or body layers for aliens.
return

/mob/living/carbon/alien/update_body_parts()//we don't use the bodyparts layer for aliens.
Expand Down
6 changes: 5 additions & 1 deletion code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
/mob/living/carbon/Initialize(mapload)
. = ..()
create_carbon_reagents()
update_body_parts() //to update the carbon's new bodyparts appearance
update_body(is_creating = TRUE) //to update the carbon's new bodyparts appearance
living_flags &= ~STOP_OVERLAY_UPDATE_BODY_PARTS

register_context()

GLOB.carbon_list += src
Expand All @@ -12,6 +14,8 @@
//This must be done first, so the mob ghosts correctly before DNA etc is nulled
. = ..()

living_flags |= STOP_OVERLAY_UPDATE_BODY_PARTS

QDEL_LIST(hand_bodyparts)
QDEL_LIST(organs)
QDEL_LIST(bodyparts)
Expand Down
3 changes: 2 additions & 1 deletion code/modules/mob/living/carbon/carbon_defines.dm
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@
usable_hands = 0 //Populated on init through list/bodyparts
mobility_flags = MOBILITY_FLAGS_CARBON_DEFAULT
blocks_emissive = EMISSIVE_BLOCK_NONE
living_flags = ALWAYS_DEATHGASP
// STOP_OVERLAY_UPDATE_BODY_PARTS is removed after we call update_body_parts() during init.
living_flags = ALWAYS_DEATHGASP|STOP_OVERLAY_UPDATE_BODY_PARTS
///List of [/obj/item/organ]s in the mob. They don't go in the contents for some reason I don't want to know.
var/list/obj/item/organ/organs = list()
///Same as [above][/mob/living/carbon/var/organs], but stores "slot ID" - "organ" pairs for easy access.
Expand Down
48 changes: 28 additions & 20 deletions code/modules/mob/living/carbon/human/_species.dm
Original file line number Diff line number Diff line change
Expand Up @@ -370,6 +370,9 @@ GLOBAL_LIST_EMPTY(features_by_species)
*/
/datum/species/proc/on_species_gain(mob/living/carbon/human/human_who_gained_species, datum/species/old_species, pref_load)
SHOULD_CALL_PARENT(TRUE)

human_who_gained_species.living_flags |= STOP_OVERLAY_UPDATE_BODY_PARTS //Don't call update_body_parts() for every single bodypart overlay added.

// Drop the items the new species can't wear
if(human_who_gained_species.hud_used)
human_who_gained_species.hud_used.update_locked_slots()
Expand Down Expand Up @@ -421,6 +424,8 @@ GLOBAL_LIST_EMPTY(features_by_species)

properly_gained = TRUE

human_who_gained_species.living_flags &= ~STOP_OVERLAY_UPDATE_BODY_PARTS

/**
* Proc called when a carbon is no longer this species.
*
Expand All @@ -431,40 +436,44 @@ GLOBAL_LIST_EMPTY(features_by_species)
* * new_species - The new species that the carbon became, used for genetics mutations.
* * pref_load - Preferences to be loaded from character setup, loads in preferred mutant things like bodyparts, digilegs, skin color, etc.
*/
/datum/species/proc/on_species_loss(mob/living/carbon/human/C, datum/species/new_species, pref_load)
/datum/species/proc/on_species_loss(mob/living/carbon/human/human, datum/species/new_species, pref_load)
SHOULD_CALL_PARENT(TRUE)
C.butcher_results = null
for(var/X in inherent_traits)
REMOVE_TRAIT(C, X, SPECIES_TRAIT)

human.living_flags |= STOP_OVERLAY_UPDATE_BODY_PARTS //Don't call update_body_parts() for every single bodypart overlay removed.
human.butcher_results = null
for(var/trait in inherent_traits)
REMOVE_TRAIT(human, trait, SPECIES_TRAIT)

//If their inert mutation is not the same, swap it out
if((inert_mutation != new_species.inert_mutation) && LAZYLEN(C.dna.mutation_index) && (inert_mutation in C.dna.mutation_index))
C.dna.remove_mutation(inert_mutation)
if((inert_mutation != new_species.inert_mutation) && LAZYLEN(human.dna.mutation_index) && (inert_mutation in human.dna.mutation_index))
human.dna.remove_mutation(inert_mutation)
//keep it at the right spot, so we can't have people taking shortcuts
var/location = C.dna.mutation_index.Find(inert_mutation)
C.dna.mutation_index[location] = new_species.inert_mutation
C.dna.default_mutation_genes[location] = C.dna.mutation_index[location]
C.dna.mutation_index[new_species.inert_mutation] = create_sequence(new_species.inert_mutation)
C.dna.default_mutation_genes[new_species.inert_mutation] = C.dna.mutation_index[new_species.inert_mutation]
var/location = human.dna.mutation_index.Find(inert_mutation)
human.dna.mutation_index[location] = new_species.inert_mutation
human.dna.default_mutation_genes[location] = human.dna.mutation_index[location]
human.dna.mutation_index[new_species.inert_mutation] = create_sequence(new_species.inert_mutation)
human.dna.default_mutation_genes[new_species.inert_mutation] = human.dna.mutation_index[new_species.inert_mutation]

if(inherent_factions)
for(var/i in inherent_factions)
C.faction -= i
human.faction -= i

clear_tail_moodlets(C)
clear_tail_moodlets(human)

remove_body_markings(C)
remove_body_markings(human)

// Removes all languages previously associated with [LANGUAGE_SPECIES], gaining our new species will add new ones back
var/datum/language_holder/losing_holder = GLOB.prototype_language_holders[species_language_holder]
for(var/language in losing_holder.understood_languages)
C.remove_language(language, UNDERSTOOD_LANGUAGE, LANGUAGE_SPECIES)
human.remove_language(language, UNDERSTOOD_LANGUAGE, LANGUAGE_SPECIES)
for(var/language in losing_holder.spoken_languages)
C.remove_language(language, SPOKEN_LANGUAGE, LANGUAGE_SPECIES)
human.remove_language(language, SPOKEN_LANGUAGE, LANGUAGE_SPECIES)
for(var/language in losing_holder.blocked_languages)
C.remove_blocked_language(language, LANGUAGE_SPECIES)
human.remove_blocked_language(language, LANGUAGE_SPECIES)

SEND_SIGNAL(human, COMSIG_SPECIES_LOSS, src)

SEND_SIGNAL(C, COMSIG_SPECIES_LOSS, src)
human.living_flags &= ~STOP_OVERLAY_UPDATE_BODY_PARTS

/**
* Handles the body of a human
Expand Down Expand Up @@ -840,8 +849,7 @@ GLOBAL_LIST_EMPTY(features_by_species)
if(QDELETED(target)) //may be called from a timer
return
target.set_facial_hairstyle("Shaved", update = FALSE)
target.set_hairstyle("Bald", update = FALSE)
target.update_body_parts()
target.set_hairstyle("Bald") //This calls update_body_parts()

//////////////////
// ATTACK PROCS //
Expand Down
4 changes: 3 additions & 1 deletion code/modules/mob/living/carbon/human/human.dm
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@
setup_human_dna()

create_carbon_reagents()
set_species(dna.species.type)
set_species(dna.species.type, icon_update = FALSE) //carbon/Initialize will call update_body()
//set species enables and disables the flag. Just to be sure, we re-enable it now until it's removed by the parent call.
living_flags |= STOP_OVERLAY_UPDATE_BODY_PARTS

prepare_huds() //Prevents a nasty runtime on human init

Expand Down
3 changes: 1 addition & 2 deletions code/modules/mob/living/carbon/human/human_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -521,8 +521,7 @@
affecting.receive_damage(acidity, 2*acidity)
emote("scream")
set_facial_hairstyle("Shaved", update = FALSE)
set_hairstyle("Bald", update = FALSE)
update_body_parts()
set_hairstyle("Bald") //This calls update_body_parts()
ADD_TRAIT(src, TRAIT_DISFIGURED, TRAIT_GENERIC)

update_damage_overlays()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1606,8 +1606,7 @@
if(!(methods & (TOUCH|VAPOR)) || !ishuman(exposed_human) || (reac_volume < 0.5))
return
exposed_human.set_facial_haircolor("#9922ff", update = FALSE)
exposed_human.set_haircolor(color, update = TRUE)
exposed_human.update_body_parts()
exposed_human.set_haircolor(color) //this will call update_body_parts()

/datum/reagent/medicine/polypyr/overdose_process(mob/living/affected_mob, seconds_per_tick, times_fired)
. = ..()
Expand Down
11 changes: 4 additions & 7 deletions code/modules/reagents/chemistry/reagents/other_reagents.dm
Original file line number Diff line number Diff line change
Expand Up @@ -2193,8 +2193,7 @@

var/mob/living/carbon/human/exposed_human = exposed_mob
exposed_human.set_facial_haircolor(pick(potential_colors), update = FALSE)
exposed_human.set_haircolor(pick(potential_colors), update = TRUE)
exposed_human.update_body_parts()
exposed_human.set_haircolor(pick(potential_colors)) //this will call update_body_parts()

/datum/reagent/barbers_aid
name = "Barber's Aid"
Expand Down Expand Up @@ -2252,13 +2251,11 @@
if(!head || (head.head_flags & HEAD_HAIR))
return
head.head_flags |= HEAD_HAIR
var/message
if(HAS_TRAIT(affected_mob, TRAIT_BALD))
message = span_warning("You feel your scalp mutate, but you are still hopelessly bald.")
to_chat(affected_mob, span_warning("You feel your scalp mutate, but you are still hopelessly bald."))
else
message = span_notice("Your scalp mutates, a full head of hair sprouting from it.")
to_chat(affected_mob, message)
human_mob.update_body_parts()
to_chat(affected_mob, span_notice("Your scalp mutates, a full head of hair sprouting from it."))
human_mob.update_body_parts()

/datum/reagent/baldium
name = "Baldium"
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/advanced/wingreconstruction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
wings.heal_wings(user, ALL)

var/obj/item/organ/external/antennae/antennae = target.get_organ_slot(ORGAN_SLOT_EXTERNAL_ANTENNAE) //i mean we might aswell heal their antennae too
antennae?.heal_antennae()
antennae?.heal_antennae(user, ALL)

human_target.update_body_parts()
return ..()
Loading

0 comments on commit 0693def

Please sign in to comment.