Skip to content

Commit 07f4677

Browse files
authored
Z-Mimic: Fix recursive lighting copy (#7356)
changes: - Glass turfs now actually work properly. - `hard_reset()` now resets harder. - ZM now avoids some redundant lighting copies. - `update_above()` will now force a discovery if the movable is undiscovered. - `NO_SHADOW` is more reliable.
1 parent 816db26 commit 07f4677

File tree

3 files changed

+23
-29
lines changed

3 files changed

+23
-29
lines changed

code/controllers/subsystem/zcopy.dm

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,6 +127,7 @@ SUBSYSTEM_DEF(zcopy)
127127
if (isturf(A))
128128
T = A
129129
if (T.mz_flags & MZ_MIMIC_BELOW)
130+
flush_z_state(T)
130131
T.update_mimic()
131132
num_turfs += 1
132133

@@ -397,7 +398,8 @@ SUBSYSTEM_DEF(zcopy)
397398

398399
// Special case: these are merged into the shadower to reduce memory usage.
399400
if (object.type == /atom/movable/lighting_overlay)
400-
T.shadower.copy_lighting(object, !(T.below.mz_flags & MZ_NO_SHADOW))
401+
shadower_set = TRUE
402+
T.shadower.copy_lighting(object)
401403
continue
402404

403405
// If an atom already has an overlay, we probably don't need to discover it again.

code/modules/lighting/lighting_overlay.dm

Lines changed: 9 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -111,35 +111,19 @@
111111
color = null
112112
else
113113
icon_state = LIGHTING_BASE_ICON_STATE
114-
if (islist(color))
115-
// Does this even save a list alloc?
116-
var/list/c_list = color
117-
c_list[CL_MATRIX_RR] = rr
118-
c_list[CL_MATRIX_RG] = rg
119-
c_list[CL_MATRIX_RB] = rb
120-
c_list[CL_MATRIX_GR] = gr
121-
c_list[CL_MATRIX_GG] = gg
122-
c_list[CL_MATRIX_GB] = gb
123-
c_list[CL_MATRIX_BR] = br
124-
c_list[CL_MATRIX_BG] = bg
125-
c_list[CL_MATRIX_BB] = bb
126-
c_list[CL_MATRIX_AR] = ar
127-
c_list[CL_MATRIX_AG] = ag
128-
c_list[CL_MATRIX_AB] = ab
129-
color = c_list
130-
else
131-
color = list(
132-
rr, rg, rb, 0,
133-
gr, gg, gb, 0,
134-
br, bg, bb, 0,
135-
ar, ag, ab, 0,
136-
0, 0, 0, 1
137-
)
114+
color = list(
115+
rr, rg, rb, 0,
116+
gr, gg, gb, 0,
117+
br, bg, bb, 0,
118+
ar, ag, ab, 0,
119+
0, 0, 0, 1
120+
)
138121

139122
// If there's a Z-turf above us, update its shadower.
140123
if (T.above)
141124
if (T.above.shadower)
142-
T.above.shadower.copy_lighting(src)
125+
if (!T.above.z_queued) // If the turf is queued for update, that will do this update.
126+
T.above.shadower.copy_lighting(src)
143127
else
144128
T.above.update_mimic()
145129

code/modules/multiz/zmimic/mimic_movable.dm

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,10 +22,14 @@
2222
bound_overlay.setDir(ndir)
2323

2424
/atom/movable/update_above()
25-
if (!bound_overlay || !isturf(loc))
25+
if (!isturf(loc))
2626
return
2727

2828
if (MOVABLE_IS_BELOW_ZTURF(src))
29+
if (!bound_overlay)
30+
SSzcopy.discover_movable(src)
31+
return
32+
2933
SSzcopy.queued_overlays += bound_overlay
3034
bound_overlay.queued += 1
3135
else
@@ -101,14 +105,18 @@
101105

102106
return ..()
103107

104-
/atom/movable/openspace/multiplier/proc/copy_lighting(atom/movable/lighting_overlay/LO, use_shadower_mult = TRUE)
108+
/atom/movable/openspace/multiplier/proc/copy_lighting(atom/movable/lighting_overlay/LO)
109+
if (LO.needs_update)
110+
// If this LO is pending an update, avoid this update and just let it update us.
111+
return
105112
appearance = LO
106113
layer = MIMICED_LIGHTING_LAYER_MAIN
107114
plane = OPENTURF_MAX_PLANE
108115
blend_mode = BLEND_MULTIPLY
109116
invisibility = 0
110117

111-
if (use_shadower_mult)
118+
var/turf/T = loc
119+
if (!(T.below.mz_flags & MZ_NO_SHADOW))
112120
if (icon_state == LIGHTING_BASE_ICON_STATE)
113121
// We're using a color matrix, so just darken the colors across the board.
114122
var/list/c_list = color

0 commit comments

Comments
 (0)