From 40b0ecf006f12b881e4e3024ad158fb0559af81a Mon Sep 17 00:00:00 2001 From: Mloc-Argent Date: Sat, 21 Jun 2014 22:16:44 +0100 Subject: [PATCH] optimize crew monitor's scan() New global list, "clothing_list". Signed-off-by: Mloc-Argent Conflicts: code/__HELPERS/global_lists.dm code/modules/clothing/clothing.dm --- code/__HELPERS/global_lists.dm | 3 +++ code/game/machinery/computer/crew.dm | 12 +++------ code/modules/clothing/clothing.dm | 37 ++++++++++++++++++++++++++++ 3 files changed, 43 insertions(+), 9 deletions(-) diff --git a/code/__HELPERS/global_lists.dm b/code/__HELPERS/global_lists.dm index 45917bc50ba..27589c024a9 100644 --- a/code/__HELPERS/global_lists.dm +++ b/code/__HELPERS/global_lists.dm @@ -22,6 +22,8 @@ var/global/list/side_effects = list() //list of all medical sideeffects types var/global/list/mechas_list = list() //list of all mechs. Used by hostile mobs target tracking. var/global/list/joblist = list() //list of all jobstypes, minus borg and AI var/global/list/flag_list = list() //list of flags during Nations gamemode +var/global/list/clothing_list = list() //list of all /obj/item/clothing instances in the world + //Languages/species/whitelist. var/global/list/all_species[0] var/global/list/all_languages[0] @@ -109,6 +111,7 @@ var/global/list/backbaglist = list("Nothing", "Backpack", "Satchel", "Satchel Al var/datum/language/L = new T all_languages[L.name] = L + var/rkey = 0 paths = typesof(/datum/species)-/datum/species for(var/T in paths) diff --git a/code/game/machinery/computer/crew.dm b/code/game/machinery/computer/crew.dm index bb8d5fd997d..011fe0630e1 100644 --- a/code/game/machinery/computer/crew.dm +++ b/code/game/machinery/computer/crew.dm @@ -108,13 +108,7 @@ /obj/machinery/computer/crew/proc/scan() - for(var/obj/item/clothing/under/C in world) + for(var/obj/item/clothing/under/C in clothing_list) if((C.has_sensor) && (istype(C.loc, /mob/living/carbon/human))) - var/check = 0 - for(var/O in src.tracked) - if(O == C) - check = 1 - break - if(!check) - src.tracked.Add(C) - return 1 \ No newline at end of file + tracked |= C + return 1 diff --git a/code/modules/clothing/clothing.dm b/code/modules/clothing/clothing.dm index d97cf213099..023fabb2c6f 100644 --- a/code/modules/clothing/clothing.dm +++ b/code/modules/clothing/clothing.dm @@ -2,6 +2,14 @@ name = "clothing" var/list/species_restricted = null //Only these species can wear this kit. +/obj/item/clothing/New() + . = ..() + clothing_list += src + +/obj/item/clothing/Del() + clothing_list -= src + return ..() + //BS12: Species-restricted clothing check. /obj/item/clothing/mob_can_equip(M as mob, slot) @@ -281,6 +289,35 @@ BLIND // can't see anything ..() +/obj/item/clothing/under/attack_hand(mob/user as mob) + //only forward to the attached accessory if the clothing is equipped (not in a storage) + if(hastie && src.loc == user) + hastie.attack_hand(user) + return + + if ((ishuman(usr) || ismonkey(usr)) && src.loc == user) //make it harder to accidentally undress yourself + return + + ..() + +/obj/item/clothing/under/MouseDrop(obj/over_object as obj) + if (ishuman(usr) || ismonkey(usr)) + //makes sure that the clothing is equipped so that we can't drag it into our hand from miles away. + if (!(src.loc == usr)) + return + + if (!( usr.restrained() ) && !( usr.stat )) + switch(over_object.name) + if("r_hand") + usr.u_equip(src) + usr.put_in_r_hand(src) + if("l_hand") + usr.u_equip(src) + usr.put_in_l_hand(src) + src.add_fingerprint(usr) + return + return + /obj/item/clothing/under/examine() set src in view() ..()