From 3819a5a9b5986993bb7c050e6f6b076a04424465 Mon Sep 17 00:00:00 2001 From: kevinz000 <2003111+kevinz000@users.noreply.github.com> Date: Wed, 9 May 2018 23:32:40 -0700 Subject: [PATCH 1/2] Fixes EMPs (#37656) --- code/__DEFINES/components.dm | 2 +- .../components/storage/concrete/_concrete.dm | 2 ++ code/datums/components/storage/storage.dm | 29 ++++++++++--------- code/modules/mob/living/living.dm | 18 +++++------- code/modules/mob/living/living_defense.dm | 3 +- 5 files changed, 27 insertions(+), 27 deletions(-) diff --git a/code/__DEFINES/components.dm b/code/__DEFINES/components.dm index 512e2cc4d9..b59ebfe7aa 100644 --- a/code/__DEFINES/components.dm +++ b/code/__DEFINES/components.dm @@ -138,7 +138,7 @@ #define COMSIG_TRY_STORAGE_FILL_TYPE "storage_fill_type" //(type, amount = INFINITY, force = FALSE) //don't fuck this up. Force will ignore max_items, and amount is normally clamped to max_items. #define COMSIG_TRY_STORAGE_TAKE "storage_take_obj" //(obj, new_loc, force = FALSE) - returns bool #define COMSIG_TRY_STORAGE_QUICK_EMPTY "storage_quick_empty" //(loc) - returns bool - if loc is null it will dump at parent location. -#define COMSIG_TRY_STORAGE_RETURN_INVENTORY "storage_return_inventory" //(list/list_to_inject_results_into) +#define COMSIG_TRY_STORAGE_RETURN_INVENTORY "storage_return_inventory" //(list/list_to_inject_results_into, recursively_search_inside_storages = TRUE) #define COMSIG_TRY_STORAGE_CAN_INSERT "storage_can_equip" //(obj/item/insertion_candidate, mob/user, silent) - returns bool /*******Non-Signal Component Related Defines*******/ diff --git a/code/datums/components/storage/concrete/_concrete.dm b/code/datums/components/storage/concrete/_concrete.dm index 4234dadd85..8701252fe6 100644 --- a/code/datums/components/storage/concrete/_concrete.dm +++ b/code/datums/components/storage/concrete/_concrete.dm @@ -73,6 +73,8 @@ slave.refresh_mob_views() /datum/component/storage/concrete/emp_act(severity) + if(emp_shielded) + return var/atom/real_location = real_location() for(var/i in real_location) var/atom/A = i diff --git a/code/datums/components/storage/storage.dm b/code/datums/components/storage/storage.dm index 483ab07e47..084056fb10 100644 --- a/code/datums/components/storage/storage.dm +++ b/code/datums/components/storage/storage.dm @@ -369,10 +369,10 @@ . = TRUE //returns TRUE if any mobs actually got a close(M) call /datum/component/storage/proc/emp_act(severity) - var/atom/A = parent - if(!isliving(A.loc) && !emp_shielded) - var/datum/component/storage/concrete/master = master() - master.emp_act(severity) + if(emp_shielded) + return + var/datum/component/storage/concrete/master = master() + master.emp_act(severity) //This proc draws out the inventory and places the items on it. tx and ty are the upper left tile and mx, my are the bottm right. //The numbers are calculated from the bottom-left The bottom-left slot being 1,1. @@ -455,23 +455,24 @@ return FALSE handle_item_insertion(I, FALSE, M) -/datum/component/storage/proc/return_inv() - . = list() - . += contents() - for(var/i in contents()) - var/atom/a = i - GET_COMPONENT_FROM(STR, /datum/component/storage, a) - if(STR) - . += STR.return_inv() +/datum/component/storage/proc/return_inv(recursive) + var/list/ret = list() + ret |= contents() + if(recursive) + for(var/i in ret.Copy()) + var/atom/A = i + A.SendSignal(COMSIG_TRY_STORAGE_RETURN_INVENTORY, ret, TRUE) + return ret /datum/component/storage/proc/contents() //ONLY USE IF YOU NEED TO COPY CONTENTS OF REAL LOCATION, COPYING IS NOT AS FAST AS DIRECT ACCESS! var/atom/real_location = real_location() return real_location.contents.Copy() -/datum/component/storage/proc/signal_return_inv(list/interface) +//Abuses the fact that lists are just references, or something like that. +/datum/component/storage/proc/signal_return_inv(list/interface, recursive = TRUE) if(!islist(interface)) return FALSE - interface |= return_inv() + interface |= return_inv(recursive) return TRUE /datum/component/storage/proc/mousedrop_onto(atom/over_object, mob/M) diff --git a/code/modules/mob/living/living.dm b/code/modules/mob/living/living.dm index bf06cd1ebb..df111f1f2b 100644 --- a/code/modules/mob/living/living.dm +++ b/code/modules/mob/living/living.dm @@ -407,16 +407,14 @@ */ //Recursive function to find everything a mob is holding. Really shitty proc tbh. /mob/living/get_contents() - . = list() - . |= list(src) - for(var/obj/o in .) - var/list/newlist = list() - o.SendSignal(COMSIG_TRY_STORAGE_RETURN_INVENTORY, newlist) - . |= newlist - for(var/obj/item/clothing/under/U in .) - . |= U.contents - for(var/obj/item/folder/F in .) - . |= F.contents + var/list/ret = list() + ret |= contents //add our contents + for(var/i in ret.Copy()) //iterate storage objects + var/atom/A = i + A.SendSignal(COMSIG_TRY_STORAGE_RETURN_INVENTORY, ret) + for(var/obj/item/folder/F in ret.Copy()) //very snowflakey-ly iterate folders + ret |= F.contents + return ret // Living mobs use can_inject() to make sure that the mob is not syringe-proof in general. /mob/living/proc/can_inject() diff --git a/code/modules/mob/living/living_defense.dm b/code/modules/mob/living/living_defense.dm index 2b2e0de0b3..b12133c5a1 100644 --- a/code/modules/mob/living/living_defense.dm +++ b/code/modules/mob/living/living_defense.dm @@ -317,8 +317,7 @@ return shock_damage /mob/living/emp_act(severity) - var/list/L = src.get_contents() - for(var/obj/O in L) + for(var/obj/O in contents) O.emp_act(severity) ..()