From 051e5b889ba01ca031d1e281e230da30d823a1bf Mon Sep 17 00:00:00 2001 From: xxalpha Date: Mon, 14 Dec 2015 01:41:18 +0000 Subject: [PATCH 1/2] Added code to resmooth loaded maps atoms. --- code/__HELPERS/icon_smoothing.dm | 30 +++++++++++++++++++++++++++-- code/modules/awaymissions/zlevel.dm | 1 + 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/code/__HELPERS/icon_smoothing.dm b/code/__HELPERS/icon_smoothing.dm index 6fe6880b967..8440b3380a7 100644 --- a/code/__HELPERS/icon_smoothing.dm +++ b/code/__HELPERS/icon_smoothing.dm @@ -60,7 +60,7 @@ /proc/smooth_icon(atom/A) if(qdeleted(A)) return - spawn(1) //don't remove this, otherwise smoothing breaks + spawn(0) //don't remove this, otherwise smoothing breaks if(A && A.smooth) var/adjacencies = calculate_adjacencies(A) @@ -134,7 +134,8 @@ return "4-[sdir]" /proc/smooth_icon_neighbors(atom/A) - for(var/atom/T in orange(1,A)) + for(var/V in orange(1,A)) + var/atom/T = V if(T.smooth) smooth_icon(T) @@ -189,3 +190,28 @@ return SOUTH_EAST if(SOUTHWEST) return SOUTH_WEST + +//Icon smoothing helpers +/proc/smooth_zlevel(var/zlevel) + var/list/away_turfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) + for(var/V in away_turfs) + var/turf/T = V + if(T.smooth) + smooth_icon(T) + for(var/R in T) + var/atom/A = R + if(A.smooth) + smooth_icon(A) + +/mob/proc/resmooth(times=1) + var/list/L = block(locate(1, 1, z), locate(world.maxx, world.maxy, z)) + while(times) + for(var/V in L) + var/turf/T = V + if(T.smooth) + smooth_icon(T) + for(var/R in T) + var/atom/A = R + if(A.smooth) + smooth_icon(A) + times-- \ No newline at end of file diff --git a/code/modules/awaymissions/zlevel.dm b/code/modules/awaymissions/zlevel.dm index 967779fb1b8..807c8f1a291 100644 --- a/code/modules/awaymissions/zlevel.dm +++ b/code/modules/awaymissions/zlevel.dm @@ -39,6 +39,7 @@ var/file = file(map) if(isfile(file)) maploader.load_map(file) + smooth_zlevel(world.maxz) world.log << "away mission loaded: [map]" map_transition_config.Add(AWAY_MISSION_LIST) From b99141260ed8703b3ce35e1f59eb9296a03fe035 Mon Sep 17 00:00:00 2001 From: xxalpha Date: Mon, 14 Dec 2015 01:59:33 +0000 Subject: [PATCH 2/2] One direction YOU NEVER SAW THAT --- code/__HELPERS/icon_smoothing.dm | 90 ++++++++++++-------------------- 1 file changed, 34 insertions(+), 56 deletions(-) diff --git a/code/__HELPERS/icon_smoothing.dm b/code/__HELPERS/icon_smoothing.dm index 8440b3380a7..f6bbfc2831c 100644 --- a/code/__HELPERS/icon_smoothing.dm +++ b/code/__HELPERS/icon_smoothing.dm @@ -1,8 +1,12 @@ //Redefinitions of the diagonal directions so they can be stored in one var without conflicts -#define NORTH_EAST 16 -#define NORTH_WEST 32 -#define SOUTH_EAST 64 -#define SOUTH_WEST 128 +#define N_NORTH 2 +#define N_SOUTH 4 +#define N_EAST 16 +#define N_WEST 256 +#define N_NORTHEAST 32 +#define N_NORTHWEST 512 +#define N_SOUTHEAST 64 +#define N_SOUTHWEST 1024 #define SMOOTH_FALSE 0 //not smooth #define SMOOTH_TRUE 1 //smooths with exact specified types or just itself @@ -16,12 +20,6 @@ /atom/var/can_be_unanchored = 0 /atom/var/list/canSmoothWith = null // TYPE PATHS I CAN SMOOTH WITH~~~~~ If this is null and atom is smooth, it smooths only with itself -/atom/proc/clear_smooth_overlays() - overlays -= top_left_corner - overlays -= top_right_corner - overlays -= bottom_right_corner - overlays -= bottom_left_corner - //generic (by snowflake) tile smoothing code; smooth your icons with this! /* Each tile is divided in 4 corners, each corner has an image associated to it; the tile is then overlayed by these 4 images @@ -47,14 +45,14 @@ AM = find_type_in_direction(A, direction) if(istype(AM)) if(AM.anchored) - adjacencies |= transform_dir(direction) + adjacencies |= 1 << direction else if(AM) - adjacencies |= transform_dir(direction) + adjacencies |= 1 << direction else for(var/direction in alldirs) if(find_type_in_direction(A, direction)) - adjacencies |= transform_dir(direction) + adjacencies |= 1 << direction return adjacencies /proc/smooth_icon(atom/A) @@ -63,7 +61,6 @@ spawn(0) //don't remove this, otherwise smoothing breaks if(A && A.smooth) var/adjacencies = calculate_adjacencies(A) - A.clear_smooth_overlays() A.top_left_corner = make_nw_corner(adjacencies) @@ -78,58 +75,58 @@ /proc/make_nw_corner(adjacencies) var/sdir = "i" - if((adjacencies & NORTH) && (adjacencies & WEST)) - if(adjacencies & NORTH_WEST) + if((adjacencies & N_NORTH) && (adjacencies & N_WEST)) + if(adjacencies & N_NORTHWEST) sdir = "f" else sdir = "nw" else - if(adjacencies & NORTH) + if(adjacencies & N_NORTH) sdir = "n" - else if(adjacencies & WEST) + else if(adjacencies & N_WEST) sdir = "w" return "1-[sdir]" /proc/make_ne_corner(adjacencies) var/sdir = "i" - if((adjacencies & NORTH) && (adjacencies & EAST)) - if(adjacencies & NORTH_EAST) + if((adjacencies & N_NORTH) && (adjacencies & N_EAST)) + if(adjacencies & N_NORTHEAST) sdir = "f" else sdir = "ne" else - if(adjacencies & NORTH) + if(adjacencies & N_NORTH) sdir = "n" - else if(adjacencies & EAST) + else if(adjacencies & N_EAST) sdir = "e" return "2-[sdir]" /proc/make_sw_corner(adjacencies) var/sdir = "i" - if((adjacencies & SOUTH) && (adjacencies & WEST)) - if(adjacencies & SOUTH_WEST) + if((adjacencies & N_SOUTH) && (adjacencies & N_WEST)) + if(adjacencies & N_SOUTHWEST) sdir = "f" else sdir = "sw" else - if(adjacencies & SOUTH) + if(adjacencies & N_SOUTH) sdir = "s" - else if(adjacencies & WEST) + else if(adjacencies & N_WEST) sdir = "w" return "3-[sdir]" /proc/make_se_corner(adjacencies) var/sdir = "i" - if((adjacencies & SOUTH) && (adjacencies & EAST)) - if(adjacencies & SOUTH_EAST) + if((adjacencies & N_SOUTH) && (adjacencies & N_EAST)) + if(adjacencies & N_SOUTHEAST) sdir = "f" else sdir = "se" else - if(adjacencies & SOUTH) + if(adjacencies & N_SOUTH) sdir = "s" else - if(adjacencies & EAST) + if(adjacencies & N_EAST) sdir = "e" return "4-[sdir]" @@ -178,20 +175,14 @@ var/atom/A = locate(source.type) in target_turf return A && A.type == source.type ? A : null -/proc/transform_dir(direction) - switch(direction) - if(NORTH,SOUTH,EAST,WEST) - return direction - if(NORTHEAST) - return NORTH_EAST - if(NORTHWEST) - return NORTH_WEST - if(SOUTHEAST) - return SOUTH_EAST - if(SOUTHWEST) - return SOUTH_WEST - //Icon smoothing helpers + +/atom/proc/clear_smooth_overlays() + overlays -= top_left_corner + overlays -= top_right_corner + overlays -= bottom_right_corner + overlays -= bottom_left_corner + /proc/smooth_zlevel(var/zlevel) var/list/away_turfs = block(locate(1, 1, zlevel), locate(world.maxx, world.maxy, zlevel)) for(var/V in away_turfs) @@ -202,16 +193,3 @@ var/atom/A = R if(A.smooth) smooth_icon(A) - -/mob/proc/resmooth(times=1) - var/list/L = block(locate(1, 1, z), locate(world.maxx, world.maxy, z)) - while(times) - for(var/V in L) - var/turf/T = V - if(T.smooth) - smooth_icon(T) - for(var/R in T) - var/atom/A = R - if(A.smooth) - smooth_icon(A) - times-- \ No newline at end of file