* Openturf icon fixes and improvements

* more things

* Remove some pointless/bad layering/planing

* yeah well I didn't need this anyways

* Refactor Z mimickry to be at /turf

* more refactoring

* Cleanup, use turf/flags instead of z_mimic_flags

* Fix turf/Entered()

* misc optimizations

* fixes

* Major icon smoothing optimizations

* Speed up boot some more

* Fix AO

* Remove some redundant code

* Tie Z-lights to Z-mimic instead of openturfs

* Fix an opacity issue with no_mutate turfs

* Fix some issues with Z-mimic AO not properly clearing

* Fix some OT->OT changetuf bugs

* Add helpers for changing Z-mimic operational state on turfs

* Fix some merge issues, change how F_CUT smoothhint works a bit.

* indentation

* SSopenturf -> SSzcopy
This commit is contained in:
Lohikar
2017-12-29 20:42:18 -06:00
committed by Erki
parent 6debd29cb7
commit 06514840f7
19 changed files with 301 additions and 264 deletions

View File

@@ -169,7 +169,6 @@
#include "code\controllers\subsystems\mob.dm"
#include "code\controllers\subsystems\mob_ai.dm"
#include "code\controllers\subsystems\night_lighting.dm"
#include "code\controllers\subsystems\openturf.dm"
#include "code\controllers\subsystems\orbit.dm"
#include "code\controllers\subsystems\overlays.dm"
#include "code\controllers\subsystems\pai.dm"
@@ -185,6 +184,7 @@
#include "code\controllers\subsystems\timer.dm"
#include "code\controllers\subsystems\trade.dm"
#include "code\controllers\subsystems\vote.dm"
#include "code\controllers\subsystems\zcopy.dm"
#include "code\controllers\subsystems\initialization\atlas.dm"
#include "code\controllers\subsystems\initialization\atoms.dm"
#include "code\controllers\subsystems\initialization\map_finalization.dm"
@@ -1085,7 +1085,6 @@
#include "code\modules\alarm\fire_alarm.dm"
#include "code\modules\alarm\motion_alarm.dm"
#include "code\modules\alarm\power_alarm.dm"
#include "code\modules\ambient_occlusion\ao_openspace.dm"
#include "code\modules\ambient_occlusion\ao_turf.dm"
#include "code\modules\ambient_occlusion\ao_verbs.dm"
#include "code\modules\antag_contest\sol_items.dm"
@@ -1802,10 +1801,12 @@
#include "code\modules\multiz\hoist.dm"
#include "code\modules\multiz\mobile_ladders.dm"
#include "code\modules\multiz\movement.dm"
#include "code\modules\multiz\openspace.dm"
#include "code\modules\multiz\pipes.dm"
#include "code\modules\multiz\structures.dm"
#include "code\modules\multiz\turf.dm"
#include "code\modules\multiz\turfs\open_space.dm"
#include "code\modules\multiz\zmimic\mimic_common.dm"
#include "code\modules\multiz\zmimic\mimic_movable.dm"
#include "code\modules\multiz\zmimic\mimic_turf.dm"
#include "code\modules\nano\nanoexternal.dm"
#include "code\modules\nano\nanomapgen.dm"
#include "code\modules\nano\nanoui.dm"

View File

@@ -17,6 +17,10 @@ Will print: "/mob/living/carbon/human/death" (you can optionally embed it in a s
// Turf-only flags.
#define NOJAUNT 1 // This is used in literally one place, turf.dm, to block ethereal jaunt.
#define MIMIC_BELOW 2 // If this turf should mimic the turf on the Z below.
#define MIMIC_OVERWRITE 4 // If this turf is Z-mimicing, overwrite the turf's appearance instead of using a movable. This is faster, but means the turf cannot have an icon.
#define MIMIC_QUEUED 8 // If the turf is currently queued for Z-mimic update.
#define MIMIC_NO_AO 16 // If the turf shouldn't apply regular turf AO and only do Z-mimic AO.
#define TRANSITIONEDGE 7 // Distance from edge to move to another z-level.

View File

@@ -71,8 +71,9 @@
#define STOP_EFFECT(effect) effect.isprocessing = FALSE; SSeffects.effect_systems -= effect;
#define STOP_VISUAL(visual) visual.isprocessing = FALSE; SSeffects.visuals -= visual;
// -- SSopenturf --
#define CHECK_OO_EXISTENCE(OO) if (OO && !isopenturf(OO.loc)) { qdel(OO); }
// -- SSzcopy --
#define TURF_IS_MIMICING(T) (isturf(T) && (T.flags & MIMIC_BELOW))
#define CHECK_OO_EXISTENCE(OO) if (OO && !TURF_IS_MIMICING(OO.loc)) { qdel(OO); }
#define UPDATE_OO_IF_PRESENT CHECK_OO_EXISTENCE(bound_overlay); if (bound_overlay) { update_above(); }
// -- SSfalling --

View File

@@ -18,9 +18,9 @@
#define SS_INIT_AO 5 // Wall AO neighbour build.
#define SS_INIT_OVERLAY 4 // Overlay flush.
#define SS_INIT_MISC 3 // Subsystems without an explicitly set initialization order start here.
#define SS_INIT_SUNLIGHT 2 // Sunlight setup. Creates lots of lighting & SSopenturf updates.
#define SS_INIT_LIGHTING 1 // Generation of lighting overlays and pre-bake. May cause openturf updates, should initialize before SSopenturf.
#define SS_INIT_OPENTURF 0 // Openturf flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites.
#define SS_INIT_SUNLIGHT 2 // Sunlight setup. Creates lots of lighting & SSzcopy updates.
#define SS_INIT_LIGHTING 1 // Generation of lighting overlays and pre-bake. May cause openturf updates, should initialize before SSzcopy.
#define SS_INIT_ZCOPY 0 // Z-mimic flush. Should run after SSoverlay & SSicon_smooth so it copies the smoothed sprites.
#define SS_INIT_LOBBY -1 // Lobby timer starts here. The lobby timer won't actually start going down until the MC starts ticking, so you probably want this last.
// Something to remember when setting priorities: SS_TICKER runs before Normal, which runs before SS_BACKGROUND.
@@ -54,7 +54,7 @@
#define SS_PRIORITY_PLANTS 40 // Spreading plant effects.
#define SS_PRIORITY_EFFECTS 35 // New-style effects manager. Timing of effects may be off if this gets too far behind.
#define SS_PRIORITY_AIRFLOW 15 // Handles object movement due to ZAS airflow.
#define SS_PRIORITY_OPENTURF 10 // Open turf icon generation/updates.
#define SS_PRIORITY_ZCOPY 10 // Z-mimic icon generation/updates.
// SS_BACKGROUND
//#define SS_PRIORITY_DEFAULT 50 // This is defined somewhere else.

View File

@@ -31,15 +31,15 @@
#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
#define SMOOTH_MORE 2 //smooths with all subtypes of specified types or just itself (this value can replace SMOOTH_TRUE)
#define SMOOTH_DIAGONAL 4 //if atom should smooth diagonally, this should be present in 'smooth' var
#define SMOOTH_BORDER 8 //atom will smooth with the borders of the map
#define SMOOTH_QUEUED 16 //atom is currently queued to smooth.
#define SMOOTH_FALSE 0 // not smooth
#define SMOOTH_TRUE 1 // smooths with exact specified types or just itself
#define SMOOTH_MORE 2 // smooths with all subtypes of specified types or just itself (this value can replace SMOOTH_TRUE)
#define SMOOTH_DIAGONAL 4 // if atom should smooth diagonally, this should be present in 'smooth' var
#define SMOOTH_BORDER 8 // atom will smooth with the borders of the map
#define SMOOTH_QUEUED 16 // atom is currently queued to smooth.
#define SMOOTH_NO_CLEAR_ICON 32 // don't clear the atom's icon_state on smooth.
#define SMOOTHHINT_CUT_ON_ALL_F 1 // Don't apply overlays if they're all the 'f' state.
#define SMOOTHHINT_CUT_F 1 // Don't draw the 'F' state. Useful with SMOOTH_NO_CLEAR_ICON.
#define SMOOTHHINT_ONLY_MATCH_TURF 2 // Only try to match turfs (this is faster than matching all atoms)
#define SMOOTHHINT_TARGETS_NOT_UNIQUE 4 // The smoother can assume that all atoms of this type will have the same canSmoothWith value.
@@ -228,13 +228,11 @@
underlays = U
/proc/cardinal_smooth(atom/A, adjacencies)
var/num_of_f = 0
//NW CORNER
var/nw = "1-i"
if((adjacencies & N_NORTH) && (adjacencies & N_WEST))
if(adjacencies & N_NORTHWEST)
nw = "1-f"
num_of_f++
else
nw = "1-nw"
else
@@ -248,7 +246,6 @@
if((adjacencies & N_NORTH) && (adjacencies & N_EAST))
if(adjacencies & N_NORTHEAST)
ne = "2-f"
num_of_f++
else
ne = "2-ne"
else
@@ -262,7 +259,6 @@
if((adjacencies & N_SOUTH) && (adjacencies & N_WEST))
if(adjacencies & N_SOUTHWEST)
sw = "3-f"
num_of_f++
else
sw = "3-sw"
else
@@ -276,7 +272,6 @@
if((adjacencies & N_SOUTH) && (adjacencies & N_EAST))
if(adjacencies & N_SOUTHEAST)
se = "4-f"
num_of_f++
else
se = "4-se"
else
@@ -287,35 +282,40 @@
var/list/New
var/list/Old
var/cut_f = A.smoothing_hints & SMOOTHHINT_CUT_F
if(A.top_left_corner != nw)
if (A.top_left_corner)
LAZYADD(Old, A.top_left_corner)
A.top_left_corner = nw
if (!cut_f || nw != "1-f")
LAZYADD(New, nw)
if(A.top_right_corner != ne)
if (A.top_right_corner)
LAZYADD(Old, A.top_right_corner)
A.top_right_corner = ne
if (!cut_f || ne != "2-f")
LAZYADD(New, ne)
if(A.bottom_right_corner != sw)
if (A.bottom_right_corner)
LAZYADD(Old, A.bottom_right_corner)
A.bottom_right_corner = sw
if (!cut_f || sw != "3-f")
LAZYADD(New, sw)
if(A.bottom_left_corner != se)
if (A.bottom_left_corner)
LAZYADD(Old, A.bottom_left_corner)
A.bottom_left_corner = se
if (!cut_f || se != "4-f")
LAZYADD(New, se)
if(Old)
A.cut_overlay(Old)
if(New && (num_of_f != 4 || !(A.smoothing_hints & SMOOTHHINT_CUT_ON_ALL_F)))
if(New)
A.add_overlay(New)
if (A.icon_state && !(A.smooth & SMOOTH_NO_CLEAR_ICON))

View File

@@ -27,9 +27,10 @@
if (!QDELETED(target))
if (target.ao_queued == AO_UPDATE_REBUILD)
var/old = target.ao_neighbors
var/old_n = target.ao_neighbors
var/old_z = target.ao_neighbors_mimic
target.calculate_ao_neighbors()
if (old != target.ao_neighbors)
if (old_n != target.ao_neighbors || old_z != target.ao_neighbors_mimic)
target.update_ao()
else
target.update_ao()

View File

@@ -3,13 +3,13 @@
#define OPENTURF_MAX_DEPTH 10 // The maxiumum number of planes deep we'll go before we just dump everything on the same plane.
#define SHADOWER_DARKENING_FACTOR 0.4 // The multiplication factor for openturf shadower darkness. Lighting will be multiplied by this.
/var/datum/controller/subsystem/openturf/SSopenturf
/var/datum/controller/subsystem/zcopy/SSzcopy
/datum/controller/subsystem/openturf
name = "Open Space"
/datum/controller/subsystem/zcopy
name = "Z-Copy"
wait = 1
init_order = SS_INIT_OPENTURF
priority = SS_PRIORITY_OPENTURF
init_order = SS_INIT_ZCOPY
priority = SS_PRIORITY_ZCOPY
flags = SS_FIRE_IN_LOBBY
var/list/queued_turfs = list()
@@ -22,53 +22,57 @@
var/starlight_enabled = FALSE
/datum/controller/subsystem/openturf/New()
NEW_SS_GLOBAL(SSopenturf)
/datum/controller/subsystem/zcopy/New()
NEW_SS_GLOBAL(SSzcopy)
/datum/controller/subsystem/openturf/proc/update_all()
/datum/controller/subsystem/zcopy/proc/update_all()
disable()
for (var/thing in openspace_overlays)
var/atom/movable/AM = thing
var/turf/simulated/open/T = get_turf(AM)
if (istype(T))
T.update_icon()
var/turf/T = get_turf(AM)
if (TURF_IS_MIMICING(T))
if (!(T.flags & MIMIC_QUEUED))
T.update_mimic()
else
qdel(AM)
CHECK_TICK
for (var/thing in openspace_turfs)
var/turf/simulated/open/T = thing
T.update_icon()
var/turf/T = thing
T.update_mimic()
enable()
/datum/controller/subsystem/openturf/proc/hard_reset()
/datum/controller/subsystem/zcopy/proc/hard_reset()
disable()
log_debug("SSopenturf: hard_reset() invoked.")
log_debug("SSzcopy: hard_reset() invoked.")
var/num_deleted = 0
for (var/thing in openspace_overlays)
var/thing
for (thing in openspace_overlays)
qdel(thing)
num_deleted++
CHECK_TICK
log_debug("SSopenturf: deleted [num_deleted] overlays.")
log_debug("SSzcopy: deleted [num_deleted] overlays.")
var/num_turfs = 0
for (var/turf/simulated/open/T in turfs)
T.update_icon()
for (thing in turfs)
var/turf/T = thing
if (T.flags & MIMIC_BELOW)
T.update_mimic()
num_turfs++
CHECK_TICK
log_debug("SSopenturf: queued [num_turfs] openturfs for update. hard_reset() complete.")
log_debug("SSzcopy: queued [num_turfs] turfs for update. hard_reset() complete.")
enable()
/datum/controller/subsystem/openturf/stat_entry()
/datum/controller/subsystem/zcopy/stat_entry()
..("Q:{T:[queued_turfs.len - (qt_idex - 1)]|O:[queued_overlays.len - (qo_idex - 1)]} T:{T:[openspace_turfs.len]|O:[openspace_overlays.len]}")
/datum/controller/subsystem/openturf/Initialize(timeofday)
/datum/controller/subsystem/zcopy/Initialize(timeofday)
starlight_enabled = config.starlight && config.openturf_starlight_permitted
// Flush the queue.
fire(FALSE, TRUE)
@@ -86,7 +90,7 @@
..()
/datum/controller/subsystem/openturf/fire(resumed = FALSE, no_mc_tick = FALSE)
/datum/controller/subsystem/zcopy/fire(resumed = FALSE, no_mc_tick = FALSE)
if (!resumed)
qt_idex = 1
qo_idex = 1
@@ -99,7 +103,7 @@
var/list/curr_ov = queued_overlays
while (qt_idex <= curr_turfs.len)
var/turf/simulated/open/T = curr_turfs[qt_idex]
var/turf/T = curr_turfs[qt_idex]
curr_turfs[qt_idex] = null
qt_idex++
@@ -115,8 +119,8 @@
// Figure out how many z-levels down we are.
var/depth = 0
var/turf/simulated/open/Td = T
while (Td && isopenturf(Td.below))
var/turf/Td = T
while (Td && TURF_IS_MIMICING(Td.below))
Td = Td.below
depth++
if (depth > OPENTURF_MAX_DEPTH)
@@ -135,15 +139,17 @@
if (starlight_enabled && T.light_range)
T.set_light(0)
if (T.no_mutate)
if (!(T.flags & MIMIC_OVERWRITE))
// Some openturfs have icons, so we can't overwrite their appearance.
if (!T.below.bound_overlay)
T.below.bound_overlay = new(T)
var/atom/movable/openspace/turf_overlay/TO = T.below.bound_overlay
TO.appearance = T.below
TO.name = T.name
TO.opacity = FALSE
T.desc = TO.desc = "Below seems to be \a [T.below]."
TO.plane = t_target
TO.mouse_opacity = FALSE
else
// This openturf doesn't care about its icon, so we can just overwrite it.
if (T.below.bound_overlay)
@@ -173,12 +179,17 @@
var/atom/movable/openspace/overlay/OO = object.bound_overlay
// If the OO was queued for destruction but was claimed by another OT, stop the destruction timer.
if (OO.destruction_timer)
deltimer(OO.destruction_timer)
OO.destruction_timer = null
// Cache our already-calculated depth so we don't need to re-calculate it a bunch of times.
OO.depth = oo_target
queued_overlays += OO
T.updating = FALSE
T.flags &= ~MIMIC_QUEUED
if (no_mc_tick)
CHECK_TICK
@@ -233,7 +244,7 @@
qo_idex = 1
/client/proc/analyze_openturf(turf/simulated/open/T)
/client/proc/analyze_openturf(turf/T)
set name = "Analyze Openturf"
set desc = "Show the layering of an openturf and everything it's mimicking."
set category = "Debug"
@@ -241,14 +252,9 @@
if (!check_rights(R_DEBUG|R_DEV))
return
if (!istype(T))
usr << "Invalid Selection."
return
var/list/out = list(
"<h1>Analysis of [T] at [T.x],[T.y],[T.z]</h1>",
"<b>Queued for update:</b> [T.updating ? "Yes" : "No"]",
"<b>Appearance Type:</b> [T.no_mutate ? "Movable Copy" : "Turf Overwrite"]",
"<b>Z Flags</b>: [english_list(bitfield2list(T.flags, list("NOJAUNT", "MIMIC_BELOW", "MIMIC_OVERWRITE", "MIMIC_QUEUED", "MIMIC_NO_AO")), "(none)")]",
"<b>Has Shadower:</b> [T.shadower ? "Yes" : "No"]",
"<b>Below:</b> [!T.below ? "(nothing)" : "[T.below] at [T.below.x],[T.below.y],[T.below.z]"]",
"<ul>"

View File

@@ -73,6 +73,9 @@
if (A.flags & SPAWN_ROOF)
spawn_roof()
if (flags & MIMIC_BELOW)
setup_zmimic(mapload)
return INITIALIZE_HINT_NORMAL
/turf/Destroy()
@@ -88,6 +91,12 @@
SSocclusion.queue -= src
ao_queued = 0
if (flags & MIMIC_BELOW)
cleanup_zmimic()
if (bound_overlay)
QDEL_NULL(bound_overlay)
..()
return QDEL_HINT_IWILLGC

View File

@@ -1107,7 +1107,7 @@ var/list/admin_verbs_cciaa = list(
log_and_message_admins("has regenerated all openturfs.")
SSopenturf.hard_reset()
SSzcopy.hard_reset()
#ifdef ENABLE_SUNLIGHT
/client/proc/apply_sunstate()

View File

@@ -1,41 +0,0 @@
// Openturfs need special snowflake CAO and UA behavior - they're shadowing based on turf type instead of ao opacity,
// as well as applying the overlays to the openspace shadower object instead of the turf itself.
/turf/simulated/open/calculate_ao_neighbors()
ao_neighbors = 0
var/turf/T
CALCULATE_NEIGHBORS(src, ao_neighbors, T, isopenturf(T))
/turf/simulated/open/update_ao()
if (ao_overlays)
shadower.cut_overlay(ao_overlays)
ao_overlays.Cut()
if (ao_neighbors == AO_ALL_NEIGHBORS)
return
var/list/cache = SSicon_cache.ao_cache
for(var/i = 1 to 4)
var/cdir = cornerdirs[i]
var/corner = 0
if (ao_neighbors & (1 << cdir))
corner |= 2
if (ao_neighbors & (1 << turn(cdir, 45)))
corner |= 1
if (ao_neighbors & (1 << turn(cdir, -45)))
corner |= 4
if (corner != 7) // 7 is the 'no shadows' state, no reason to add overlays for it.
var/image/I = cache["[corner]-[i]"]
if (!I)
I = make_ao_image(corner, i)
LAZYADD(ao_overlays, I)
UNSETEMPTY(ao_overlays)
if (ao_overlays)
shadower.add_overlay(ao_overlays)

View File

@@ -8,6 +8,8 @@
var/permit_ao = TRUE
var/tmp/list/ao_overlays // Current ambient occlusion overlays. Tracked so we can reverse them without dropping all priority overlays.
var/tmp/ao_neighbors
var/tmp/list/ao_overlays_mimic
var/tmp/ao_neighbors_mimic
var/ao_queued = AO_UPDATE_NONE
/turf/proc/regenerate_ao()
@@ -20,10 +22,14 @@
/turf/proc/calculate_ao_neighbors()
ao_neighbors = 0
ao_neighbors_mimic = 0
if (!permit_ao)
return
var/turf/T
if (flags & MIMIC_BELOW)
CALCULATE_NEIGHBORS(src, ao_neighbors_mimic, T, (T.flags & MIMIC_BELOW))
if (!has_opaque_atom && !(flags & MIMIC_NO_AO))
CALCULATE_NEIGHBORS(src, ao_neighbors, T, AO_TURF_CHECK(T))
/proc/make_ao_image(corner, i, px = 0, py = 0, pz = 0, pw = 0)
@@ -54,36 +60,52 @@
if (ao_queued < new_level)
ao_queued = new_level
#define PROCESS_AO_CORNER(AO_LIST, NEIGHBORS, CORNER_INDEX, CDIR) \
corner = 0; \
if (NEIGHBORS & (1 << CDIR)) { \
corner |= 2; \
} \
if (NEIGHBORS & (1 << turn(CDIR, 45))) { \
corner |= 1; \
} \
if (NEIGHBORS & (1 << turn(CDIR, -45))) { \
corner |= 4; \
} \
if (corner != 7) { /* 7 is the 'no shadows' state, no reason to add overlays for it. */ \
var/image/I = cache["[corner]-[CORNER_INDEX]-[pixel_x]/[pixel_y]/[pixel_z]/[pixel_w]"]; \
if (!I) { \
I = make_ao_image(corner, CORNER_INDEX, pixel_x, pixel_y, pixel_z, pixel_w) /* this will also add the image to the cache. */ \
} \
LAZYADD(AO_LIST, I); \
}
#define CUT_AO(TARGET, AO_LIST) \
if (AO_LIST) { \
TARGET.cut_overlay(AO_LIST, TRUE); \
AO_LIST.Cut(); \
}
#define REGEN_AO(TARGET, AO_LIST, NEIGHBORS) \
if (permit_ao && NEIGHBORS != AO_ALL_NEIGHBORS) { \
var/corner;\
PROCESS_AO_CORNER(AO_LIST, NEIGHBORS, 1, NORTHWEST); \
PROCESS_AO_CORNER(AO_LIST, NEIGHBORS, 2, SOUTHEAST); \
PROCESS_AO_CORNER(AO_LIST, NEIGHBORS, 3, NORTHEAST); \
PROCESS_AO_CORNER(AO_LIST, NEIGHBORS, 4, SOUTHWEST); \
} \
UNSETEMPTY(AO_LIST); \
if (AO_LIST) { \
TARGET.add_overlay(AO_LIST, TRUE); \
}
/turf/proc/update_ao()
if (ao_overlays)
cut_overlay(ao_overlays, TRUE)
ao_overlays.Cut()
if (!permit_ao || ao_neighbors == AO_ALL_NEIGHBORS) // If all corners are going to be transparent anyways, bail early.
return
var/list/cache = SSicon_cache.ao_cache
CUT_AO(shadower, ao_overlays_mimic)
CUT_AO(src, ao_overlays)
if (flags & MIMIC_BELOW)
REGEN_AO(shadower, ao_overlays_mimic, ao_neighbors_mimic)
if (!has_opaque_atom && !(flags & MIMIC_NO_AO))
REGEN_AO(src, ao_overlays, ao_neighbors)
if (!has_opaque_atom)
for(var/i = 1 to 4)
var/cdir = cornerdirs[i]
var/corner = 0
if (ao_neighbors & (1 << cdir))
corner |= 2
if (ao_neighbors & (1 << turn(cdir, 45)))
corner |= 1
if (ao_neighbors & (1 << turn(cdir, -45)))
corner |= 4
if (corner != 7) // 7 is the 'no shadows' state, no reason to add overlays for it.
var/image/I = cache["[corner]-[i]-[pixel_x]/[pixel_y]/[pixel_z]/[pixel_w]"]
if (!I)
I = make_ao_image(corner, i, pixel_x, pixel_y, pixel_z, pixel_w) // this will also add the image to the cache.
LAZYADD(ao_overlays, I)
UNSETEMPTY(ao_overlays)
if (ao_overlays)
add_overlay(ao_overlays, TRUE)
#undef REGEN_AO
#undef PROCESS_AO_CORNER

View File

@@ -12,6 +12,7 @@
for (var/turf/T in world) // Yes, in world.
T.ao_neighbors = null // To force a recalc.
T.ao_neighbors_mimic = null
if (T.permit_ao)
T.queue_ao()

View File

@@ -402,8 +402,8 @@
T = T.above
goto check_t
else
if (isopenturf(T) && T:below) // Not searching upwards and we have a below turf.
T = T:below // Consider the turf below us as well. (Z-lights)
if (T && (T.flags & MIMIC_BELOW) && T.below) // Not searching upwards and we have a below turf.
T = T.below // Consider the turf below us as well. (Z-lights)
goto check_t
else // Not searching upwards and we don't have a below turf.
zlights_going_up = TRUE

View File

@@ -99,8 +99,8 @@
CHECK_TICK
// Sunlight only checks downwards as it has no need to shine upwards, really.
if (isopenturf(T) && T:below)
T = T:below
if (T && (T.flags & MIMIC_BELOW) && T.below)
T = T.below
goto check_t
LAZYINITLIST(affecting_turfs)

View File

@@ -26,7 +26,7 @@ var/list/mineral_can_smooth_with = list(
// canSmoothWith is set in Initialize().
smooth = SMOOTH_MORE | SMOOTH_BORDER | SMOOTH_NO_CLEAR_ICON
smoothing_hints = SMOOTHHINT_CUT_ON_ALL_F | SMOOTHHINT_ONLY_MATCH_TURF | SMOOTHHINT_TARGETS_NOT_UNIQUE
smoothing_hints = SMOOTHHINT_CUT_F | SMOOTHHINT_ONLY_MATCH_TURF | SMOOTHHINT_TARGETS_NOT_UNIQUE
oxygen = 0
nitrogen = 0
@@ -506,7 +506,7 @@ var/list/mineral_can_smooth_with = list(
icon_state = "ash"
desc = "A fine grey ash. Looks pretty tightly packed."
smooth = SMOOTH_MORE | SMOOTH_BORDER | SMOOTH_NO_CLEAR_ICON
smoothing_hints = SMOOTHHINT_CUT_ON_ALL_F | SMOOTHHINT_ONLY_MATCH_TURF | SMOOTHHINT_TARGETS_NOT_UNIQUE
smoothing_hints = SMOOTHHINT_CUT_F | SMOOTHHINT_ONLY_MATCH_TURF | SMOOTHHINT_TARGETS_NOT_UNIQUE
gender = PLURAL
base_icon = 'icons/turf/smooth/ash.dmi'
base_icon_state = "ash"

View File

@@ -1,27 +1,3 @@
/**
* Used to check wether or not an atom can pass through a turf.
*
* @param A The atom that's moving either up or down from this turf or to it.
* @param direction The direction of the atom's movement in relation to its
* current position.
*
* @return TRUE if A can pass in the movement direction, FALSE if not.
*/
/turf/proc/CanZPass(atom/A, direction)
if(z == A.z) //moving FROM this turf
return direction == UP //can't go below
else
if(direction == UP) //on a turf below, trying to enter
return FALSE
if(direction == DOWN) //on a turf above, trying to enter
return !density
/turf/simulated/open/CanZPass(atom, direction)
return TRUE
/turf/space/CanZPass(atom, direction)
return TRUE
/**
* Open turf class.
*
@@ -35,19 +11,14 @@
density = 0
pathweight = 100000 //Seriously, don't try and path over this one numbnuts
is_hole = TRUE
flags = MIMIC_BELOW | MIMIC_OVERWRITE | MIMIC_NO_AO
roof_type = null
var/tmp/turf/below
var/tmp/atom/movable/openspace/multiplier/shadower // Overlay used to multiply color of all OO overlays at once.
var/tmp/updating = FALSE // If this turf is queued for openturf update.
var/tmp/depth
var/tmp/list/climbers // A lazy list to contain a list of mobs who are currently scaling
// A lazy list to contain a list of mobs who are currently scaling
// up this turf. Used in human/can_fall.
var/no_mutate = FALSE // If TRUE, SSopenturf will not modify the appearance of this turf.
var/tmp/list/climbers
// An override of turf/Enter() to make it so that magboots allow you to stop
// falling off the damned rock.
@@ -85,38 +56,10 @@
LAZYREMOVE(climbers, mover)
/turf/simulated/open/Destroy()
SSopenturf.openspace_turfs -= src
SSopenturf.queued_turfs -= src
QDEL_NULL(shadower)
for (var/atom/movable/openspace/overlay/OwO in src) // wats this~?
OwO.owning_turf_changed()
if (istype(above))
addtimer(CALLBACK(above, /turf/simulated/open/.proc/update), 0)
above = null
if (below)
below.above = null
below = null
LAZYCLEARLIST(climbers)
UNSETEMPTY(climbers)
return ..()
/**
* Used to check whether or not the specific open turf eventually leads into spess.
*
* @return TRUE if the turfs/holes eventually lead into space. FALSE otherwise.
*/
/turf/simulated/open/proc/is_above_space()
var/turf/T = GetBelow(src)
while (isopenturf(T))
T = GetBelow(T)
return istype(T, /turf/space)
/**
* Used to add a climber to the climbers list. Climbers do not fall down this specific tile.
*
@@ -163,7 +106,8 @@
icon = 'icons/turf/smooth/chasms_seethrough.dmi'
icon_state = "debug"
smooth = SMOOTH_TRUE | SMOOTH_BORDER | SMOOTH_NO_CLEAR_ICON
no_mutate = TRUE
smoothing_hints = SMOOTHHINT_CUT_F | SMOOTHHINT_ONLY_MATCH_TURF | SMOOTHHINT_TARGETS_NOT_UNIQUE
flags = MIMIC_BELOW
name = "hole"
/turf/simulated/open/chasm/airless
@@ -172,7 +116,7 @@
temperature = TCMB
icon_state = "debug_airless"
/turf/simulated/open/chasm/airless/Initialize()
/turf/simulated/open/chasm/Initialize()
. = ..()
icon_state = "Fill"
@@ -190,9 +134,9 @@
/turf/simulated/open/Initialize(mapload)
. = ..()
icon_state = "" // Clear out the debug icon.
SSopenturf.openspace_turfs += src
SSzcopy.openspace_turfs += src
shadower = new(src)
if (no_mutate && plane == PLANE_SPACE_BACKGROUND)
if (!(flags & MIMIC_OVERWRITE) && plane == PLANE_SPACE_BACKGROUND)
// If the plane is default and we're a no_mutate turf, force it to 0 so the icon works properly.
plane = 0
update(mapload)
@@ -219,8 +163,6 @@
if (is_hole && O.simulated)
ADD_FALLING_ATOM(O)
update_icon(mapload)
/turf/simulated/open/update_dirt()
return 0
@@ -230,13 +172,7 @@
O.hide(0)
/turf/simulated/open/update_icon(mapload)
if(!updating && below)
updating = TRUE
SSopenturf.queued_turfs += src
if (!mapload && above) // Even if we're already updating, the turf above us might not be.
// Cascade updates until we hit the top openturf.
above.update_icon()
update_mimic(!mapload)
/turf/simulated/open/attackby(obj/item/C as obj, mob/user as mob)
if (istype(C, /obj/item/stack/rods))

View File

@@ -0,0 +1,39 @@
// Updates whatever openspace components may be mimicing us. On turfs this queues an openturf update on the above openturf, on movables this updates their bound movable (if present). Meaningless on any type other than `/turf` or `/atom/movable` (incl. children).
/atom/proc/update_above()
return
/**
* Used to check wether or not an atom can pass through a turf.
*
* @param A The atom that's moving either up or down from this turf or to it.
* @param direction The direction of the atom's movement in relation to its
* current position.
*
* @return TRUE if A can pass in the movement direction, FALSE if not.
*/
/turf/proc/CanZPass(atom/A, direction)
if(z == A.z) //moving FROM this turf
return direction == UP //can't go below
else
if(direction == UP) //on a turf below, trying to enter
return FALSE
if(direction == DOWN) //on a turf above, trying to enter
return !density
/**
* Used to check whether or not the specific open turf eventually leads into spess.
*
* @return TRUE if the turf eventually leads into space. FALSE otherwise.
*/
/turf/proc/is_above_space()
var/turf/T = GetBelow(src)
while (T && (T.flags & MIMIC_BELOW))
T = GetBelow(T)
return istype(T, /turf/space)
/turf/simulated/open/CanZPass(atom, direction)
return TRUE
/turf/space/CanZPass(atom, direction)
return TRUE

View File

@@ -1,36 +1,3 @@
/*
== Openspace ==
This file contains the openspace movable types, including interactrion code and openspace helpers.
Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
*/
// Updates whatever openspace components may be mimicing us. On turfs this queues an openturf update on the above openturf, on movables this updates their bound movable (if present). Meaningless on any type other than `/turf` or `/atom/movable` (incl. children).
/atom/proc/update_above()
return
/turf
// Reference to any open turf that might be above us to speed up atom Entered() updates.
var/tmp/turf/simulated/open/above
var/tmp/atom/movable/openspace/turf_overlay/bound_overlay
/turf/Entered(atom/movable/thing, atom/oldLoc)
. = ..()
if (above && !thing.no_z_overlay && !thing.bound_overlay && !isopenturf(oldLoc))
above.update_icon()
/turf/Destroy()
above = null
if (bound_overlay)
QDEL_NULL(bound_overlay)
return ..()
/turf/update_above()
if (istype(above))
above.update_icon()
/atom/movable
var/tmp/atom/movable/openspace/overlay/bound_overlay // The overlay that is directly mirroring us that we proxy movement to.
var/no_z_overlay // If TRUE, this atom will not be drawn on open turfs.
@@ -59,9 +26,9 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
if (!bound_overlay)
return
if (isopenturf(bound_overlay.loc))
if (TURF_IS_MIMICING(loc))
if (!bound_overlay.queued)
SSopenturf.queued_overlays += bound_overlay
SSzcopy.queued_overlays += bound_overlay
bound_overlay.queued = TRUE
else
qdel(bound_overlay)
@@ -117,7 +84,7 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
)
/atom/movable/openspace/multiplier/Destroy()
var/turf/simulated/open/myturf = loc
var/turf/myturf = loc
if (istype(myturf))
myturf.shadower = null
@@ -168,10 +135,10 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
/atom/movable/openspace/overlay/New()
initialized = TRUE
SSopenturf.openspace_overlays += src
SSzcopy.openspace_overlays += src
/atom/movable/openspace/overlay/Destroy()
SSopenturf.openspace_overlays -= src
SSzcopy.openspace_overlays -= src
if (associated_atom)
associated_atom.bound_overlay = null
@@ -194,9 +161,9 @@ Most openspace appearance code is in code/controllers/subsystems/openturf.dm.
/atom/movable/openspace/overlay/examine(mob/examiner)
associated_atom.examine(examiner)
/atom/movable/openspace/overlay/forceMove(atom/dest)
/atom/movable/openspace/overlay/forceMove(turf/dest)
. = ..()
if (isopenturf(dest))
if (TURF_IS_MIMICING(dest))
if (destruction_timer)
deltimer(destruction_timer)
destruction_timer = null

View File

@@ -0,0 +1,91 @@
/turf
// Reference to any open turf that might be above us to speed up atom Entered() updates.
var/tmp/turf/above
var/tmp/turf/below
var/tmp/atom/movable/openspace/turf_overlay/bound_overlay
var/tmp/atom/movable/openspace/multiplier/shadower // Overlay used to multiply color of all OO overlays at once.
/turf/Entered(atom/movable/thing, turf/oldLoc)
. = ..()
if (thing.bound_overlay || !thing.no_z_overlay || !above || !(above.flags & MIMIC_BELOW) || (isturf(oldLoc) && oldLoc.above && (oldLoc.above.flags & MIMIC_BELOW)))
return
above.update_mimic()
/turf/update_above()
if (TURF_IS_MIMICING(above))
above.update_mimic()
/turf/proc/update_mimic(recurse = TRUE)
if (!(flags & MIMIC_BELOW))
return
if (below && !(flags & MIMIC_QUEUED))
flags |= MIMIC_QUEUED
SSzcopy.queued_turfs += src
if (recurse)
update_above() // Even if we're already updating, the turf above us might not be.
// Enables Z-mimic for a turf that didn't already have it enabled.
/turf/proc/enable_zmimic(additional_flags = 0)
if (flags & MIMIC_BELOW)
return FALSE
flags |= MIMIC_BELOW | additional_flags
setup_zmimic(FALSE)
return TRUE
// Disables Z-mimic for a turf.
/turf/proc/disable_zmimic()
if (!(flags & MIMIC_BELOW))
return FALSE
flags &= ~MIMIC_BELOW
cleanup_zmimic()
// Sets up Z-mimic for this turf. You shouldn't call this directly 99% of the time.
/turf/proc/setup_zmimic(mapload)
if (shadower)
CRASH("Attempt to enable Z-mimic on already-enabled turf!")
shadower = new(src)
SSzcopy.openspace_turfs += src
var/turf/under = GetBelow(src)
if (under)
below = under
below.above = src
update_mimic(!mapload) // Only recursively update if the map isn't loading.
// Cleans up Z-mimic objects for this turf. You shouldn't call this directly 99% of the time.
/turf/proc/cleanup_zmimic()
SSzcopy.openspace_turfs -= src
if (flags & MIMIC_QUEUED)
SSzcopy.queued_turfs -= src
QDEL_NULL(shadower)
for (var/atom/movable/openspace/overlay/OwO in src) // wats this~?
OwO.owning_turf_changed()
if (above)
above.update_mimic()
if (below)
below.above = null
below = null
// Movable for mimicing turfs that don't allow appearance mutation.
/atom/movable/openspace/turf_overlay
plane = OPENTURF_MAX_PLANE
/atom/movable/openspace/turf_overlay/attackby(obj/item/W, mob/user)
loc.attackby(W, user)
/atom/movable/openspace/turf_overlay/attack_hand(mob/user as mob)
loc.attack_hand(user)
/atom/movable/openspace/turf_overlay/attack_generic(mob/user as mob)
loc.attack_generic(user)
/atom/movable/openspace/turf_overlay/examine(mob/examiner)
loc.examine(examiner)