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.

This commit is contained in:
Remie Richards
2015-06-30 12:20:28 +01:00
parent 3fe48e2f26
commit d9ec8a1008
3 changed files with 9 additions and 5 deletions
+2 -1
View File
@@ -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
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.
+4
View File
@@ -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))
+3 -4
View File
@@ -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