From d9ec8a1008e64ee79f29cda6b8398aebeaaf6b0a Mon Sep 17 00:00:00 2001 From: Remie Richards Date: Tue, 30 Jun 2015 12:20:28 +0100 Subject: [PATCH] area/proc/get_apc() is no longer shit and does not lag (AT ALL) on large areas anymore, the new method stores a list of all APCs in the world, and checks if their area var is equal to the area get_apc() was called on. --- code/_globalvars/lists/objects.dm | 3 ++- code/modules/power/apc.dm | 4 ++++ code/modules/power/power.dm | 7 +++---- 3 files changed, 9 insertions(+), 5 deletions(-) diff --git a/code/_globalvars/lists/objects.dm b/code/_globalvars/lists/objects.dm index 2abd022a271..fcb84606da3 100644 --- a/code/_globalvars/lists/objects.dm +++ b/code/_globalvars/lists/objects.dm @@ -12,4 +12,5 @@ var/global/list/nuke_list = list() var/global/list/chemical_reactions_list //list of all /datum/chemical_reaction datums. Used during chemical reactions var/global/list/chemical_reagents_list //list of all /datum/reagent datums indexed by reagent id. Used by chemistry stuff var/global/list/surgeries_list = list() //list of all surgeries by name, associated with their path. -var/global/list/table_recipes = list() //list of all table craft recipes \ No newline at end of file +var/global/list/table_recipes = list() //list of all table craft recipes +var/global/list/apcs_list = list() //list of all Area Power Controller machines, seperate from machines for powernet speeeeeeed. \ No newline at end of file diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index a23baaa84f0..329346fa41b 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -112,6 +112,8 @@ /obj/machinery/power/apc/New(turf/loc, var/ndir, var/building=0) ..() + apcs_list += src + wires = new(src) // offset 24 pixels in direction of dir // this allows the APC to be embedded in a wall, yet still inside an area @@ -138,6 +140,8 @@ src.update() /obj/machinery/power/apc/Destroy() + apcs_list -= src + if(malfai && operating) if (ticker.mode.config_tag == "malfunction") if (src.z == ZLEVEL_STATION) //if (is_type_in_list(get_area(src), the_station_areas)) diff --git a/code/modules/power/power.dm b/code/modules/power/power.dm index 6468170f288..d6f19601413 100644 --- a/code/modules/power/power.dm +++ b/code/modules/power/power.dm @@ -356,7 +356,6 @@ return null /area/proc/get_apc() - for(var/area/RA in src.related) - var/obj/machinery/power/apc/FINDME = locate() in RA - if (FINDME) - return FINDME + for(var/obj/machinery/power/apc/APC in apcs_list) + if(APC.area == src) + return APC