From 7632bf23057159181c2d5be5b63f5f2744173628 Mon Sep 17 00:00:00 2001 From: shizcalev Date: Fri, 4 Aug 2017 16:29:37 -0400 Subject: [PATCH 1/2] Fixes APCs grabbing area subtypes --- code/game/machinery/porta_turret/portable_turret.dm | 6 +++++- code/modules/power/apc.dm | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 4628ab8c7b9..0376a3726eb 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -669,7 +669,11 @@ return if(control_area) - control_area = locate(text2path(control_area)) in GLOB.sortedAreas + 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 if(control_area == null) control_area = get_area(src) stack_trace("Bad control_area path for [src], [src.control_area]") diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 907f3791b84..62c75a8b52c 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -178,7 +178,11 @@ //if area isn't specified use current if(areastring) - src.area = locate(text2path(areastring)) in GLOB.sortedAreas + 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 if(!src.area) src.area = A stack_trace("Bad areastring path for [src], [src.areastring]") From 319fe3326ccb1892ce8c6620bfd0f72359637828 Mon Sep 17 00:00:00 2001 From: shizcalev Date: Fri, 4 Aug 2017 16:59:32 -0400 Subject: [PATCH 2/2] Moved to a proc --- code/__HELPERS/unsorted.dm | 12 ++++++++++++ code/game/machinery/porta_turret/portable_turret.dm | 6 +----- code/modules/power/apc.dm | 6 +----- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/code/__HELPERS/unsorted.dm b/code/__HELPERS/unsorted.dm index aab766f9e4e..e94fc9f4b00 100644 --- a/code/__HELPERS/unsorted.dm +++ b/code/__HELPERS/unsorted.dm @@ -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) diff --git a/code/game/machinery/porta_turret/portable_turret.dm b/code/game/machinery/porta_turret/portable_turret.dm index 0376a3726eb..f88578bbf9c 100644 --- a/code/game/machinery/porta_turret/portable_turret.dm +++ b/code/game/machinery/porta_turret/portable_turret.dm @@ -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]") diff --git a/code/modules/power/apc.dm b/code/modules/power/apc.dm index 62c75a8b52c..28882a0c7e8 100644 --- a/code/modules/power/apc.dm +++ b/code/modules/power/apc.dm @@ -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]")