From b0b08005285db8abb7bcd5d6de0c0fb0e09c7296 Mon Sep 17 00:00:00 2001 From: SkyratBot <59378654+SkyratBot@users.noreply.github.com> Date: Sun, 10 Oct 2021 16:40:25 +0200 Subject: [PATCH] [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 --- code/__DEFINES/turfs.dm | 7 +++++-- code/game/objects/items/blueprints.dm | 13 ++++++++----- code/game/turfs/turf.dm | 2 ++ 3 files changed, 15 insertions(+), 7 deletions(-) diff --git a/code/__DEFINES/turfs.dm b/code/__DEFINES/turfs.dm index 73a36c5b2aa..14911e1ddbd 100644 --- a/code/__DEFINES/turfs.dm +++ b/code/__DEFINES/turfs.dm @@ -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 diff --git a/code/game/objects/items/blueprints.dm b/code/game/objects/items/blueprints.dm index d827d3ceb9a..43f7a5d6f40 100644 --- a/code/game/objects/items/blueprints.dm +++ b/code/game/objects/items/blueprints.dm @@ -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) diff --git a/code/game/turfs/turf.dm b/code/game/turfs/turf.dm index 4f4603a9b81..5ad6115bccf 100644 --- a/code/game/turfs/turf.dm +++ b/code/game/turfs/turf.dm @@ -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