Skip to content

Commit

Permalink
adds returns to prevent runtimes in /datum/component/healing_reductio…
Browse files Browse the repository at this point in the history
…n/process(delta_time) hopefuly (#5084)

# About the pull request

when there is no parent the function deleted src but then kept going and
asked for parent of null, it calls return now instead

# Explain why it's good for the game

runtime bad 


# Testing Photographs and Procedure
<details>
<summary>Screenshots & Videos</summary>

Put screenshots and videos here with an empty line between the
screenshots and the `<details>` tags.

</details>


# Changelog
:cl:
fix: fixed a runtime in
/datum/component/healing_reduction/process(delta_time)
/:cl:

---------

Co-authored-by: Drathek <[email protected]>
  • Loading branch information
cuberound and Drulikar authored Dec 3, 2023
1 parent 31da57d commit 570f55a
Showing 1 changed file with 17 additions and 14 deletions.
31 changes: 17 additions & 14 deletions code/datums/components/healing_reduction.dm
Original file line number Diff line number Diff line change
Expand Up @@ -21,33 +21,36 @@ Humans will take continuous damage instead.
src.healing_reduction_dissipation = healing_reduction_dissipation
src.max_buildup = max_buildup

/datum/component/healing_reduction/InheritComponent(datum/component/healing_reduction/C, i_am_original, healing_reduction)
/datum/component/healing_reduction/InheritComponent(datum/component/healing_reduction/inherit_component, i_am_original, healing_reduction)
. = ..()
if(!C)
if(!inherit_component)
src.healing_reduction += healing_reduction
else
src.healing_reduction += C.healing_reduction
src.healing_reduction += inherit_component.healing_reduction

src.healing_reduction = min(src.healing_reduction, max_buildup)

/datum/component/healing_reduction/process(delta_time)
if(!parent)
qdel(src)
healing_reduction = max(healing_reduction - healing_reduction_dissipation * delta_time, 0)
return

if(ishuman(parent)) //deals brute to humans
var/mob/living/carbon/human/H = parent
H.apply_damage(healing_reduction_dissipation * delta_time, BRUTE)
healing_reduction = max(healing_reduction - healing_reduction_dissipation * delta_time, 0)

if(healing_reduction <= 0)
qdel(src)
return

if(ishuman(parent)) //deals brute to humans
var/mob/living/carbon/human/human_parent = parent
human_parent.apply_damage(healing_reduction_dissipation * delta_time, BRUTE)

var/color = GLOW_COLOR
var/intensity = healing_reduction/max_buildup
color += num2text(MAX_ALPHA*intensity, 2, 16)

var/atom/A = parent
A.add_filter("healing_reduction", 2, list("type" = "outline", "color" = color, "size" = 1))
var/atom/parent_atom = parent
parent_atom.add_filter("healing_reduction", 2, list("type" = "outline", "color" = color, "size" = 1))

/datum/component/healing_reduction/RegisterWithParent()
START_PROCESSING(SSdcs, src)
Expand All @@ -64,14 +67,14 @@ Humans will take continuous damage instead.
COMSIG_XENO_ON_HEAL_WOUNDS,
COMSIG_XENO_APPEND_TO_STAT
))
var/atom/A = parent
A.remove_filter("healing_reduction")
var/atom/parent_atom = parent
parent_atom.remove_filter("healing_reduction")

/datum/component/healing_reduction/proc/stat_append(mob/M, list/L)
/datum/component/healing_reduction/proc/stat_append(mob/target_mob, list/stat_list)
SIGNAL_HANDLER
L += "Healing Reduction: [healing_reduction]/[max_buildup]"
stat_list += "Healing Reduction: [healing_reduction]/[max_buildup]"

/datum/component/healing_reduction/proc/apply_healing_reduction(mob/living/carbon/xenomorph/X, list/healing)
/datum/component/healing_reduction/proc/apply_healing_reduction(mob/living/carbon/xenomorph/xeno, list/healing)
SIGNAL_HANDLER
healing["healing"] -= healing_reduction

Expand Down

0 comments on commit 570f55a

Please sign in to comment.