Fix runtime error with handle_heartbeat()

Fixes this runtime error:
//-------------------------------------------------\\
|| runtime error: Cannot read null.status          ||
|| proc name: handle heartbeat                     ||
|| (/mob/living/carbon/human/proc/handle_heartbeat)||
|| source file: life.dm,1648                       ||
\\-------------------------------------------------//

This was caused by no sanity check to make sure that
internal_organs_by_name actually returned an organ, therefore it was
attempting to read a null variable, which causes a runtime error.
This commit is contained in:
Tigercat2000
2015-04-11 11:36:32 -07:00
parent 51db1854c7
commit f3dd9d5e82
+4 -3
View File
@@ -1623,6 +1623,10 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
var/client/C = src.client
if(C && C.prefs.sound & SOUND_HEARTBEAT) //disable heartbeat by pref
var/obj/item/organ/heart/H = internal_organs_by_name["heart"]
if(!H) //H.status will runtime if there is no H (obviously)
return
if(H.status & ORGAN_ROBOT) //Handle robotic hearts specially with a wuuuubb. This also applies to machine-people.
if(shock_stage >= 10 || istype(get_turf(src), /turf/space))
//PULSE_THREADY - maximum value for pulse, currently it 5.
@@ -1641,9 +1645,6 @@ var/global/list/brutefireloss_overlays = list("1" = image("icon" = 'icons/mob/sc
if(pulse == PULSE_NONE)
return
if(!H)
return
if(pulse >= PULSE_2FAST || shock_stage >= 10 || istype(get_turf(src), /turf/space))
//PULSE_THREADY - maximum value for pulse, currently it 5.
//High pulse value corresponds to a fast rate of heartbeat.