Fixes areastring grabbing area subtypes

This commit is contained in:
CitadelStationBot
2017-08-06 03:21:24 -05:00
parent 521c149627
commit a209582b8a
3 changed files with 40 additions and 0 deletions

View File

@@ -605,6 +605,18 @@ Turf and target are separate in case you want to teleport some distance from a t
GLOB.sortedAreas.Add(src)
sortTim(GLOB.sortedAreas, /proc/cmp_name_asc)
//Takes: Area type as a text string from a variable.
//Returns: Instance for the area in the world.
/proc/get_area_instance_from_text(areatext)
var/areainstance = null
if(istext(areatext))
areatext = text2path(areatext)
for(var/V in GLOB.sortedAreas)
var/area/A = V
if(A.type == areatext)
areainstance = V
return areainstance
//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)

View File

@@ -0,0 +1,14 @@
diff a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm (rejected hunks)
@@ -669,11 +669,7 @@
return
if(control_area)
- control_area = text2path(control_area) //resolves the string to path, then filters out instances generated by subtypes of the path in sortedAreas
- for(var/V in GLOB.sortedAreas)
- var/area/B = V
- if(B.type == control_area)
- control_area = V
+ control_area = get_area_instance_from_text(control_area)
if(control_area == null)
control_area = get_area(src)
stack_trace("Bad control_area path for [src], [src.control_area]")

View File

@@ -0,0 +1,14 @@
diff a/code/modules/power/apc.dm b/code/modules/power/apc.dm (rejected hunks)
@@ -178,11 +178,7 @@
//if area isn't specified use current
if(areastring)
- areastring = text2path(areastring) //resolves the string to path, then filters out instances generated by subtypes of the path in sortedAreas
- for(var/V in GLOB.sortedAreas)
- var/area/B = V
- if(B.type == areastring)
- src.area = V
+ src.area = get_area_instance_from_text(areastring)
if(!src.area)
src.area = A
stack_trace("Bad areastring path for [src], [src.areastring]")