From 0aa2e6b6a209c42f8026bddecc1af25b482e93b6 Mon Sep 17 00:00:00 2001 From: kevinz000 Date: Thu, 19 Oct 2017 00:00:16 -0700 Subject: [PATCH 1/2] Adds type checks to HUD alert clicks to prevent ghosts from causing runtimes (#31609) * Update alert.dm * better fix --- code/_onclick/hud/alert.dm | 6 +++--- code/modules/mob/living/living.dm | 2 +- code/modules/mob/mob.dm | 3 +++ 3 files changed, 7 insertions(+), 4 deletions(-) diff --git a/code/_onclick/hud/alert.dm b/code/_onclick/hud/alert.dm index 3cc6734482..2d3a3341da 100644 --- a/code/_onclick/hud/alert.dm +++ b/code/_onclick/hud/alert.dm @@ -243,7 +243,7 @@ or shoot a gun to move around via Newton's 3rd Law of Motion." /obj/screen/alert/fire/Click() var/mob/living/L = usr - if(!L.can_resist()) + if(!istype(L) || !L.can_resist()) return L.changeNext_move(CLICK_CD_RESIST) if(L.canmove) @@ -559,7 +559,7 @@ so as to remain in compliance with the most up-to-date laws." /obj/screen/alert/restrained/Click() var/mob/living/L = usr - if(!L.can_resist()) + if(!istype(L) || !L.can_resist()) return L.changeNext_move(CLICK_CD_RESIST) if((L.canmove) && (L.last_special <= world.time)) @@ -567,7 +567,7 @@ so as to remain in compliance with the most up-to-date laws." /obj/screen/alert/restrained/buckled/Click() var/mob/living/L = usr - if(!L.can_resist()) + if(!istype(L) || !L.can_resist()) return L.changeNext_move(CLICK_CD_RESIST) if(L.last_special <= world.time) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index bbb36edad3..0cfda3821f 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -586,7 +586,7 @@ if(!force_moving) ..(pressure_difference, direction, pressure_resistance_prob_delta) -/mob/living/proc/can_resist() +/mob/living/can_resist() return !((next_move > world.time) || incapacitated(ignore_restraints = TRUE)) /mob/living/verb/resist() diff --git a/code/modules/mob/mob.dm b/code/modules/mob/mob.dm index 02c1fa4b44..657c4f0ded 100644 --- a/code/modules/mob/mob.dm +++ b/code/modules/mob/mob.dm @@ -356,6 +356,9 @@ else M.LAssailant = usr +/mob/proc/can_resist() + return FALSE //overridden in living.dm + /mob/proc/spin(spintime, speed) set waitfor = 0 var/D = dir