[MIRROR] CE blueprints: Fix structural overlay [MDB IGNORE] (#8729)

* CE blueprints: Fix structural overlay (#61974)

CE blueprints come with a niche but situationally useful ability to view the original atmos, disposals, and power cable layout.

This has suffered a fair amount of bitrot. Not only was this not updated to use the plane and layer variables, but it also didn't handle any client running in widescreen mode - RANGE_TURFS requires a numerical parameter for its radius parameter, and cannot handle a modern viewstring such as "17x17".

* CE blueprints: Fix structural overlay

Co-authored-by: esainane <esainane+github@gmail.com>
This commit is contained in:
SkyratBot
2021-10-10 15:40:25 +01:00
committed by GitHub
co-authored by esainane
parent 5a6b933785
commit b0b0800528
3 changed files with 15 additions and 7 deletions
+5 -2
View File
@@ -10,9 +10,12 @@
//supposedly the fastest way to do this according to https://gist.github.com/Giacom/be635398926bb463b42a
///Returns a list of turf in a square
#define RANGE_TURFS(RADIUS, CENTER) \
RECT_TURFS(RADIUS, RADIUS, CENTER)
#define RECT_TURFS(H_RADIUS, V_RADIUS, CENTER) \
block( \
locate(max(CENTER.x-(RADIUS),1), max(CENTER.y-(RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(RADIUS),world.maxx), min(CENTER.y+(RADIUS),world.maxy), CENTER.z) \
locate(max(CENTER.x-(H_RADIUS),1), max(CENTER.y-(V_RADIUS),1), CENTER.z), \
locate(min(CENTER.x+(H_RADIUS),world.maxx), min(CENTER.y+(V_RADIUS),world.maxy), CENTER.z) \
)
///Returns all turfs in a zlevel
+8 -5
View File
@@ -115,18 +115,21 @@
attack_self(usr) //this is not the proper way, but neither of the old update procs work! it's too ancient and I'm tired shush.
/obj/item/areaeditor/blueprints/proc/get_images(turf/T, viewsize)
/obj/item/areaeditor/blueprints/proc/get_images(turf/central_turf, viewsize)
. = list()
for(var/turf/TT in RANGE_TURFS(viewsize, T))
if(TT.blueprint_data)
. += TT.blueprint_data
var/list/dimensions = getviewsize(viewsize)
var/horizontal_radius = dimensions[1] / 2
var/vertical_radius = dimensions[2] / 2
for(var/turf/nearby_turf as anything in RECT_TURFS(horizontal_radius, vertical_radius, central_turf))
if(nearby_turf.blueprint_data)
. += nearby_turf.blueprint_data
/obj/item/areaeditor/blueprints/proc/set_viewer(mob/user, message = "")
if(user?.client)
if(viewing)
clear_viewer()
viewing = user.client
showing = get_images(get_turf(user), viewing.view)
showing = get_images(get_turf(viewing.eye || user), viewing.view)
viewing.images |= showing
if(message)
to_chat(user, message)
+2
View File
@@ -525,6 +525,8 @@ GLOBAL_LIST_EMPTY(station_turfs)
/turf/proc/add_blueprints(atom/movable/AM)
var/image/I = new
I.plane = GAME_PLANE
I.layer = OBJ_LAYER
I.appearance = AM.appearance
I.appearance_flags = RESET_COLOR|RESET_ALPHA|RESET_TRANSFORM
I.loc = src