Skip to content

Commit

Permalink
[MIRROR] Parse_zone audit + minor misc cleanup (#2510)
Browse files Browse the repository at this point in the history
* Parse_zone audit + minor misc cleanup (#83154)

## About The Pull Request

Does a audit on all uses of parse_zone, replacing most instances of it
with a new living-level proc that refers to the bodypart in that zone if
it exists.

In other cases, removes parse_zone entirely because the bodypart is
already confirmed to exist, so we just use plaintext_zone.

Also cleans up some single letter vars.
## Why It's Good For The Game

In the doc of ```plaintext_zone```, its said it ```Should be used for
parsing non-instantiated bodyparts```. 99% of the code ignores the
possibility of a bodypart existing, and so uses parse_zone when
plaintext_zone could be accessed instead.
## Changelog
:cl:
code: Most instances of parse_zone now refer to the limb's
plaintext_zone var
/:cl:

---------

Co-authored-by: Ghom <[email protected]>

* Parse_zone audit + minor misc cleanup

---------

Co-authored-by: nikothedude <[email protected]>
Co-authored-by: Ghom <[email protected]>
Co-authored-by: NovaBot13 <[email protected]>
  • Loading branch information
4 people authored and StealsThePRs committed May 16, 2024
1 parent a0aa7b3 commit 0a0235b
Show file tree
Hide file tree
Showing 26 changed files with 253 additions and 244 deletions.
6 changes: 6 additions & 0 deletions code/__HELPERS/mobs.dm
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,12 @@ GLOBAL_LIST_INIT(skin_tone_names, list(
if(mob.ckey == key)
return mob

/// Returns a string for the specified body zone. If we have a bodypart in this zone, refers to its plaintext_zone instead.
/mob/living/proc/parse_zone_with_bodypart(zone)
var/obj/item/bodypart/part = get_bodypart(zone)

return part?.plaintext_zone || parse_zone(zone)

///Return a string for the specified body zone. Should be used for parsing non-instantiated bodyparts, otherwise use [/obj/item/bodypart/var/plaintext_zone]
/proc/parse_zone(zone)
switch(zone)
Expand Down
2 changes: 1 addition & 1 deletion code/_onclick/item_attack.dm
Original file line number Diff line number Diff line change
Expand Up @@ -289,7 +289,7 @@
if(body_position == LYING_DOWN)
zone_hit_chance += 10
targeting = get_random_valid_zone(targeting, zone_hit_chance)
var/targeting_human_readable = parse_zone(targeting)
var/targeting_human_readable = parse_zone_with_bodypart(targeting)

send_item_attack_message(attacking_item, user, targeting_human_readable, targeting)

Expand Down
18 changes: 9 additions & 9 deletions code/datums/components/surgery_initiator.dm
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@
patient.surgeries -= the_surgery
REMOVE_TRAIT(patient, TRAIT_ALLOWED_HONORBOUND_ATTACK, type)
user.visible_message(
span_notice("[user] removes [parent] from [patient]'s [parse_zone(selected_zone)]."),
span_notice("You remove [parent] from [patient]'s [parse_zone(selected_zone)]."),
span_notice("[user] removes [parent] from [patient]'s [patient.parse_zone_with_bodypart(selected_zone)]."),
span_notice("You remove [parent] from [patient]'s [patient.parse_zone_with_bodypart(selected_zone)]."),
)

patient.balloon_alert(user, "stopped work on [parse_zone(selected_zone)]")
patient.balloon_alert(user, "stopped work on [patient.parse_zone_with_bodypart(selected_zone)]")

qdel(the_surgery)
return
Expand Down Expand Up @@ -153,11 +153,11 @@
REMOVE_TRAIT(patient, TRAIT_ALLOWED_HONORBOUND_ATTACK, ELEMENT_TRAIT(type))

user.visible_message(
span_notice("[user] closes [patient]'s [parse_zone(selected_zone)] with [close_tool] and removes [parent]."),
span_notice("You close [patient]'s [parse_zone(selected_zone)] with [close_tool] and remove [parent]."),
span_notice("[user] closes [patient]'s [patient.parse_zone_with_bodypart(selected_zone)] with [close_tool] and removes [parent]."),
span_notice("You close [patient]'s [patient.parse_zone_with_bodypart(selected_zone)] with [close_tool] and remove [parent]."),
)

patient.balloon_alert(user, "closed up [parse_zone(selected_zone)]")
patient.balloon_alert(user, "closed up [patient.parse_zone_with_bodypart(selected_zone)]")

qdel(the_surgery)

Expand Down Expand Up @@ -328,7 +328,7 @@
return

if (surgery_needs_exposure(surgery, target))
target.balloon_alert(user, "expose [target.p_their()] [parse_zone(selected_zone)]!")
target.balloon_alert(user, "expose [target.p_their()] [target.parse_zone_with_bodypart(selected_zone)]!")
return

ui_close()
Expand All @@ -339,8 +339,8 @@
target.balloon_alert(user, "starting \"[LOWER_TEXT(procedure.name)]\"")

user.visible_message(
span_notice("[user] drapes [parent] over [target]'s [parse_zone(selected_zone)] to prepare for surgery."),
span_notice("You drape [parent] over [target]'s [parse_zone(selected_zone)] to prepare for \an [procedure.name]."),
span_notice("[user] drapes [parent] over [target]'s [target.parse_zone_with_bodypart(selected_zone)] to prepare for surgery."),
span_notice("You drape [parent] over [target]'s [target.parse_zone_with_bodypart(selected_zone)] to prepare for \an [procedure.name]."),
)
// NOVA EDIT ADDITION START - warning for unanesthetized surgery
if(!(HAS_TRAIT(target, TRAIT_ANALGESIA) || target.stat >= UNCONSCIOUS))
Expand Down
2 changes: 1 addition & 1 deletion code/game/machinery/computer/operating_computer.dm
Original file line number Diff line number Diff line change
Expand Up @@ -151,7 +151,7 @@
else
alternative_step = "Finish operation"
data["procedures"] += list(list(
"name" = capitalize("[parse_zone(procedure.location)] [procedure.name]"),
"name" = capitalize("[patient.parse_zone_with_bodypart(procedure.location)] [procedure.name]"),
"next_step" = capitalize(surgery_step.name),
"chems_needed" = chems_needed,
"alternative_step" = alternative_step,
Expand Down
2 changes: 1 addition & 1 deletion code/game/objects/items/robot/items/hypo.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@
balloon_alert(user, "[amount_per_transfer_from_this] unit\s injected")
log_combat(user, injectee, "injected", src, "(CHEMICALS: [selected_reagent])")
else
balloon_alert(user, "[parse_zone(user.zone_selected)] is blocked!")
balloon_alert(user, "[injectee.parse_zone_with_bodypart(user.zone_selected)] is blocked!")

/obj/item/reagent_containers/borghypo/ui_interact(mob/user, datum/tgui/ui)
ui = SStgui.try_update_ui(user, src, ui)
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/items/stacks/medical.dm
Original file line number Diff line number Diff line change
Expand Up @@ -182,8 +182,8 @@
if(!try_heal_checks(patient, user, brute, burn))
return FALSE
user.visible_message(
span_infoplain(span_green("[user] applies [src] on [patient]'s [parse_zone(affecting.body_zone)].")),
span_infoplain(span_green("You apply [src] on [patient]'s [parse_zone(affecting.body_zone)]."))
span_infoplain(span_green("[user] applies [src] on [patient]'s [affecting.plaintext_zone].")),
span_infoplain(span_green("You apply [src] on [patient]'s [affecting.plaintext_zone]."))
)
var/previous_damage = affecting.get_damage()
if(affecting.heal_damage(brute, burn))
Expand Down
4 changes: 2 additions & 2 deletions code/game/objects/structures/watercloset.dm
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sink, (-14))
if(busy)
to_chat(user, span_warning("Someone's already washing here!"))
return
var/selected_area = parse_zone(user.zone_selected)
var/selected_area = user.parse_zone_with_bodypart(user.zone_selected)
var/washing_face = 0
if(selected_area in list(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_MOUTH, BODY_ZONE_PRECISE_EYES))
washing_face = 1
Expand Down Expand Up @@ -601,7 +601,7 @@ MAPPING_DIRECTIONAL_HELPERS(/obj/structure/sink/kitchen, (-16))
if(busy)
to_chat(user, span_warning("Someone's already washing here!"))
return
var/selected_area = parse_zone(user.zone_selected)
var/selected_area = user.parse_zone_with_bodypart(user.zone_selected)
var/washing_face = FALSE
if(selected_area in list(BODY_ZONE_HEAD, BODY_ZONE_PRECISE_MOUTH, BODY_ZONE_PRECISE_EYES))
washing_face = TRUE
Expand Down
2 changes: 1 addition & 1 deletion code/modules/antagonists/heretic/magic/flesh_surgery.dm
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@

// Round u pto the nearest generic zone (body, chest, arm)
var/zone_to_check = check_zone(caster.zone_selected)
var/parsed_zone = parse_zone(zone_to_check)
var/parsed_zone = victim.parse_zone_with_bodypart(zone_to_check)

var/list/organs_we_can_remove = list()
for(var/obj/item/organ/organ as anything in carbon_victim.organs)
Expand Down
11 changes: 7 additions & 4 deletions code/modules/clothing/clothing.dm
Original file line number Diff line number Diff line change
Expand Up @@ -195,13 +195,16 @@
if(!(def_zone in covered_limbs))
return

var/zone_name = parse_zone(def_zone)
var/zone_name
var/break_verb = ((damage_type == BRUTE) ? "torn" : "burned")

if(iscarbon(loc))
var/mob/living/carbon/C = loc
C.visible_message(span_danger("The [zone_name] on [C]'s [src.name] is [break_verb] away!"), span_userdanger("The [zone_name] on your [src.name] is [break_verb] away!"), vision_distance = COMBAT_MESSAGE_RANGE)
RegisterSignal(C, COMSIG_MOVABLE_MOVED, PROC_REF(bristle), override = TRUE)
var/mob/living/carbon/carbon_loc = loc
zone_name = carbon_loc.parse_zone_with_bodypart(def_zone)
carbon_loc.visible_message(span_danger("The [zone_name] on [carbon_loc]'s [src.name] is [break_verb] away!"), span_userdanger("The [zone_name] on your [src.name] is [break_verb] away!"), vision_distance = COMBAT_MESSAGE_RANGE)
RegisterSignal(carbon_loc, COMSIG_MOVABLE_MOVED, PROC_REF(bristle), override = TRUE)
else
zone_name = parse_zone(def_zone)

zones_disabled++
body_parts_covered &= ~body_zone2cover_flags(def_zone)
Expand Down
28 changes: 14 additions & 14 deletions code/modules/clothing/neck/_neck.dm
Original file line number Diff line number Diff line change
Expand Up @@ -198,14 +198,14 @@
user.visible_message(span_suicide("[user] puts \the [src] to [user.p_their()] chest! It looks like [user.p_they()] won't hear much!"))
return OXYLOSS

/obj/item/clothing/neck/stethoscope/attack(mob/living/M, mob/living/user)
if(!ishuman(M) || !isliving(user))
/obj/item/clothing/neck/stethoscope/attack(mob/living/target, mob/living/user)
if(!ishuman(target) || !isliving(user))
return ..()
if(user.combat_mode)
return

var/mob/living/carbon/carbon_patient = M
var/body_part = parse_zone(user.zone_selected)
var/mob/living/carbon/carbon_patient = target
var/body_part = carbon_patient.parse_zone_with_bodypart(user.zone_selected)
var/oxy_loss = carbon_patient.getOxyLoss()

var/heart_strength
Expand Down Expand Up @@ -235,13 +235,13 @@
|| (HAS_TRAIT(carbon_patient, TRAIT_NOBREATH))\
|| carbon_patient.failed_last_breath \
|| carbon_patient.losebreath)//If pt is dead or otherwise not breathing
render_list += "<span class='danger ml-1'>[M.p_Theyre()] not breathing!</span>\n"
render_list += "<span class='danger ml-1'>[target.p_Theyre()] not breathing!</span>\n"
else if(lungs.damage > 10)//if breathing, check for lung damage
render_list += "<span class='danger ml-1'>You hear fluid in [M.p_their()] lungs!</span>\n"
render_list += "<span class='danger ml-1'>You hear fluid in [target.p_their()] lungs!</span>\n"
else if(oxy_loss > 10)//if they have suffocation damage
render_list += "<span class='danger ml-1'>[M.p_Theyre()] breathing heavily!</span>\n"
render_list += "<span class='danger ml-1'>[target.p_Theyre()] breathing heavily!</span>\n"
else
render_list += "<span class='notice ml-1'>[M.p_Theyre()] breathing normally.</span>\n"//they're okay :D
render_list += "<span class='notice ml-1'>[target.p_Theyre()] breathing normally.</span>\n"//they're okay :D

//assess heart
if(body_part == BODY_ZONE_CHEST)//if we're listening to the chest
Expand All @@ -261,20 +261,20 @@
var/appendix_okay = TRUE
var/liver_okay = TRUE
if(!liver)//sanity check, ensure the patient actually has a liver
render_list += "<span class='danger ml-1'>You can't feel anything where [M.p_their()] liver would be.</span>\n"
render_list += "<span class='danger ml-1'>You can't feel anything where [target.p_their()] liver would be.</span>\n"
liver_okay = FALSE
else
if(liver.damage > 10)
render_list += "<span class='danger ml-1'>[M.p_Their()] liver feels firm.</span>\n"//their liver is damaged
render_list += "<span class='danger ml-1'>[target.p_Their()] liver feels firm.</span>\n"//their liver is damaged
liver_okay = FALSE

if(!appendix)//sanity check, ensure the patient actually has an appendix
render_list += "<span class='danger ml-1'>You can't feel anything where [M.p_their()] appendix would be.</span>\n"
render_list += "<span class='danger ml-1'>You can't feel anything where [target.p_their()] appendix would be.</span>\n"
appendix_okay = FALSE
else
if(appendix.damage > 10 && carbon_patient.stat == CONSCIOUS)
render_list += "<span class='danger ml-1'>[M] screams when you lift your hand from [M.p_their()] appendix!</span>\n"//scream if their appendix is damaged and they're awake
M.emote("scream")
render_list += "<span class='danger ml-1'>[target] screams when you lift your hand from [target.p_their()] appendix!</span>\n"//scream if their appendix is damaged and they're awake
target.emote("scream")
appendix_okay = FALSE

if(liver_okay && appendix_okay)//if they have all their organs and have no detectable damage
Expand Down Expand Up @@ -310,7 +310,7 @@
else
pulse_pressure = span_notice("strong")//they're okay :D

render_list += "<span class='notice ml-1'>[M.p_Their()] pulse is [pulse_pressure] and [heart_strength].</span>\n"
render_list += "<span class='notice ml-1'>[target.p_Their()] pulse is [pulse_pressure] and [heart_strength].</span>\n"

//display our packaged information in an examine block for easy reading
to_chat(user, examine_block(jointext(render_list, "")), type = MESSAGE_TYPE_INFO)
Expand Down
16 changes: 8 additions & 8 deletions code/modules/mob/living/carbon/carbon.dm
Original file line number Diff line number Diff line change
Expand Up @@ -1141,14 +1141,14 @@
return
var/list/limb_list = list()
if(edit_action == "remove")
for(var/obj/item/bodypart/B as anything in bodyparts)
limb_list += B.body_zone
for(var/obj/item/bodypart/iter_part as anything in bodyparts)
limb_list += iter_part.body_zone
limb_list -= BODY_ZONE_CHEST
else
limb_list = list(BODY_ZONE_HEAD, BODY_ZONE_L_ARM, BODY_ZONE_R_ARM, BODY_ZONE_L_LEG, BODY_ZONE_R_LEG, BODY_ZONE_CHEST)
var/result = input(usr, "Please choose which bodypart to [edit_action]","[capitalize(edit_action)] Bodypart") as null|anything in sort_list(limb_list)
if(result)
var/obj/item/bodypart/BP = get_bodypart(result)
var/obj/item/bodypart/part = get_bodypart(result)
var/list/limbtypes = list()
switch(result)
if(BODY_ZONE_CHEST)
Expand All @@ -1165,18 +1165,18 @@
limbtypes = typesof(/obj/item/bodypart/leg/right)
switch(edit_action)
if("remove")
if(BP)
BP.drop_limb()
admin_ticket_log("[key_name_admin(usr)] has removed [src]'s [parse_zone(BP.body_zone)]")
if(part)
part.drop_limb()
admin_ticket_log("[key_name_admin(usr)] has removed [src]'s [part.plaintext_zone]")
else
to_chat(usr, span_boldwarning("[src] doesn't have such bodypart."))
admin_ticket_log("[key_name_admin(usr)] has attempted to modify the bodyparts of [src]")
if("replace")
var/limb2add = input(usr, "Select a bodypart type to add", "Add/Replace Bodypart") as null|anything in sort_list(limbtypes)
var/obj/item/bodypart/new_bp = new limb2add()
if(new_bp.replace_limb(src, special = TRUE))
admin_ticket_log("key_name_admin(usr)] has replaced [src]'s [BP.type] with [new_bp.type]")
qdel(BP)
admin_ticket_log("key_name_admin(usr)] has replaced [src]'s [part.type] with [new_bp.type]")
qdel(part)
else
to_chat(usr, "Failed to replace bodypart! They might be incompatible.")
admin_ticket_log("[key_name_admin(usr)] has attempted to modify the bodyparts of [src]")
Expand Down
2 changes: 1 addition & 1 deletion code/modules/mob/living/living_defense.dm
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@
span_userdanger("You're hit by [thrown_item]!"))
if(!thrown_item.throwforce)
return
var/armor = run_armor_check(zone, MELEE, "Your armor has protected your [parse_zone(zone)].", "Your armor has softened hit to your [parse_zone(zone)].", thrown_item.armour_penetration, "", FALSE, thrown_item.weak_against_armour)
var/armor = run_armor_check(zone, MELEE, "Your armor has protected your [parse_zone_with_bodypart(zone)].", "Your armor has softened hit to your [parse_zone_with_bodypart(zone)].", thrown_item.armour_penetration, "", FALSE, thrown_item.weak_against_armour)
apply_damage(thrown_item.throwforce, thrown_item.damtype, zone, armor, sharpness = thrown_item.get_sharpness(), wound_bonus = (nosell_hit * CANT_WOUND))
if(QDELETED(src)) //Damage can delete the mob.
return
Expand Down
2 changes: 1 addition & 1 deletion code/modules/projectiles/projectile.dm
Original file line number Diff line number Diff line change
Expand Up @@ -358,7 +358,7 @@

var/organ_hit_text = ""
if(hit_limb_zone)
organ_hit_text = " in \the [parse_zone(hit_limb_zone)]"
organ_hit_text = " in \the [living_target.parse_zone_with_bodypart(hit_limb_zone)]"
if(suppressed == SUPPRESSED_VERY)
//playsound(loc, hitsound, 5, TRUE, -1) NOVA EDIT REMOVAL - IMPACT SOUNDS
organ_hit_text = organ_hit_text // NOVA EDIT ADDITION -- this is just so we don't have to nova edit the TG control statements. Otherwise will error in linters for being an empty block
Expand Down
14 changes: 7 additions & 7 deletions code/modules/surgery/amputation.dm
Original file line number Diff line number Diff line change
Expand Up @@ -43,9 +43,9 @@
display_results(
user,
target,
span_notice("You begin to sever [target]'s [parse_zone(target_zone)]..."),
span_notice("[user] begins to sever [target]'s [parse_zone(target_zone)]!"),
span_notice("[user] begins to sever [target]'s [parse_zone(target_zone)]!"),
span_notice("You begin to sever [target]'s [target.parse_zone_with_bodypart(target_zone)]..."),
span_notice("[user] begins to sever [target]'s [target.parse_zone_with_bodypart(target_zone)]!"),
span_notice("[user] begins to sever [target]'s [target.parse_zone_with_bodypart(target_zone)]!"),
)
display_pain(target, "You feel a gruesome pain in your [parse_zone(target_zone)]'s joint!")

Expand All @@ -54,11 +54,11 @@
display_results(
user,
target,
span_notice("You sever [target]'s [parse_zone(target_zone)]."),
span_notice("[user] severs [target]'s [parse_zone(target_zone)]!"),
span_notice("[user] severs [target]'s [parse_zone(target_zone)]!"),
span_notice("You sever [target]'s [target.parse_zone_with_bodypart(target_zone)]."),
span_notice("[user] severs [target]'s [target.parse_zone_with_bodypart(target_zone)]!"),
span_notice("[user] severs [target]'s [target.parse_zone_with_bodypart(target_zone)]!"),
)
display_pain(target, "You can no longer feel your severed [parse_zone(target_zone)]!")
display_pain(target, "You can no longer feel your severed [target.parse_zone_with_bodypart(target_zone)]!")

if(HAS_MIND_TRAIT(user, TRAIT_MORBID) && ishuman(user))
var/mob/living/carbon/human/morbid_weirdo = user
Expand Down
2 changes: 1 addition & 1 deletion code/modules/surgery/bodyparts/wounds.dm
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@
dam_mul *= iter_wound.damage_multiplier_penalty

if(!LAZYLEN(wounds) && current_gauze && !replaced) // no more wounds = no need for the gauze anymore
owner.visible_message(span_notice("\The [current_gauze.name] on [owner]'s [name] falls away."), span_notice("The [current_gauze.name] on your [parse_zone(body_zone)] falls away."))
owner.visible_message(span_notice("\The [current_gauze.name] on [owner]'s [name] falls away."), span_notice("The [current_gauze.name] on your [plaintext_zone] falls away."))
QDEL_NULL(current_gauze)

wound_damage_multiplier = dam_mul
Expand Down
Loading

0 comments on commit 0a0235b

Please sign in to comment.