Revert "bettering of get area procs"

This commit is contained in:
oranges
2016-08-23 10:45:28 +12:00
committed by GitHub
parent c6919ca95a
commit cd0fd4fcf1
2 changed files with 39 additions and 42 deletions
+37 -39
View File
@@ -624,60 +624,58 @@ Turf and target are seperate in case you want to teleport some distance from a t
//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all areas of that type in the world.
/proc/get_areas(areatype, subtypes=TRUE)
/proc/get_areas(areatype)
if(!areatype)
return null
if(istext(areatype))
areatype = text2path(areatype)
else if(isarea(areatype))
if(isarea(areatype))
var/area/areatemp = areatype
areatype = areatemp.type
else
return null
var/list/areas = list()
if(subtypes)
var/list/cache = typecacheof(areatype)
for(var/V in sortedAreas)
var/area/A = V
if(cache[A.type])
areas += V
else
for(var/V in sortedAreas)
var/area/A = V
if(A.type == areatype)
areas += V
var/list/areas = new/list()
for(var/area/N in world)
if(istype(N, areatype))
areas += N
return areas
//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all turfs in areas of that type of that type in the world.
/proc/get_area_turfs(areatype, target_z = 0, subtypes=FALSE)
/proc/get_area_turfs(areatype, target_z = 0)
if(!areatype)
return null
if(istext(areatype))
areatype = text2path(areatype)
else if(isarea(areatype))
if(isarea(areatype))
var/area/areatemp = areatype
areatype = areatemp.type
else
return null
var/list/turfs = list()
if(subtypes)
var/list/cache = typecacheof(areatype)
for(var/V in sortedAreas)
var/area/A = V
if(!cache[A.type])
continue
for(var/turf/T in A)
if(target_z == 0 || target_z == T.z)
turfs += T
else
for(var/V in sortedAreas)
var/area/A = V
if(A.type != areatype)
continue
for(var/turf/T in A)
var/list/turfs = new/list()
for(var/area/N in world)
if(istype(N, areatype))
for(var/turf/T in N)
if(target_z == 0 || target_z == T.z)
turfs += T
return turfs
//Takes: Area type as text string or as typepath OR an instance of the area.
//Returns: A list of all atoms (objs, turfs, mobs) in areas of that type of that type in the world.
/proc/get_area_all_atoms(areatype)
if(!areatype)
return null
if(istext(areatype))
areatype = text2path(areatype)
if(isarea(areatype))
var/area/areatemp = areatype
areatype = areatemp.type
var/list/atoms = new/list()
for(var/area/N in world)
if(istype(N, areatype))
for(var/atom/A in N)
atoms += A
return atoms
/proc/get_cardinal_dir(atom/A, atom/B)
var/dx = abs(B.x - A.x)
var/dy = abs(B.y - A.y)
@@ -1301,13 +1299,13 @@ B --><-- A
/proc/get_areas_in_z(zlevel)
. = list()
var/validarea = FALSE
var/validarea = 0
for(var/V in sortedAreas)
var/area/A = V
validarea = TRUE
validarea = 1
for(var/turf/T in A)
if(T.z != zlevel)
validarea = FALSE
validarea = 0
break
if(validarea)
. += A
@@ -717,8 +717,7 @@
/obj/machinery/turretid/initialize() //map-placed turrets autolink turrets
if(control_area && istext(control_area))
for(var/V in sortedAreas)
var/area/A = V
for(var/area/A in world)
if(A.name == control_area)
control_area = A
break
@@ -730,7 +729,7 @@
else
control_area = CA
for(var/obj/machinery/porta_turret/T in control_area)
for(var/obj/machinery/porta_turret/T in get_area_all_atoms(control_area))
turrets |= T
/obj/machinery/turretid/attackby(obj/item/I, mob/user, params)