Skip to content

Commit f05aaca

Browse files
Fixes accidential infinite loop in multiz rendering (#95472)
## About The Pull Request Ok so on the parallax pr I moved a bunch of dumb plane group signal registration to the set home proc. Unfortunately because set_home is run BEFORE update_offset, any created relays will then be offset down X from where they should be. For the master plate, this means #1's relay to transparent plate #0 will instead draw to transparent plate #1 (which of course renders into master plate #1) To fix this I've moved update_offset to BEFORE set_home, so children can hook into it and do things in a sane and normal way. Near as I can tell there's no reason they're ordered as they currently are. I've also added a failsafe check to prevent relay creation before update_offset is called, and attached a CRASH() to such. Interestingly enough this caused crashes on shift right click. That's fun I think
1 parent a675704 commit f05aaca

2 files changed

Lines changed: 7 additions & 1 deletion

File tree

code/_onclick/hud/rendering/plane_masters/_plane_master.dm

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,15 +64,18 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/plane_master)
6464
/// If this plane master is outside of our visual bounds right now
6565
var/is_outside_bounds = FALSE
6666

67+
/// Has this plane master had its offset made concrete? Avoids modifications/uses that are going to immediately break
68+
var/offset_already_updated = FALSE
69+
6770
/atom/movable/screen/plane_master/Initialize(mapload, datum/hud/hud_owner, datum/plane_master_group/home, offset = 0)
6871
. = ..()
6972
src.offset = offset
7073
true_alpha = alpha
7174
real_plane = plane
75+
update_offset()
7276

7377
if(!set_home(home))
7478
return INITIALIZE_HINT_QDEL
75-
update_offset()
7679
if(!documentation && !(istype(src, /atom/movable/screen/plane_master) || istype(src, /atom/movable/screen/plane_master/rendering_plate)))
7780
stack_trace("Plane master created without a description. Document how your thing works so people will know in future, and we can display it in the debug menu")
7881
if(start_hidden)
@@ -109,6 +112,7 @@ INITIALIZE_IMMEDIATE(/atom/movable/screen/plane_master)
109112
render_relay_planes[i] = GET_NEW_PLANE(render_relay_planes[i], offset)
110113
if(initial(render_target))
111114
render_target = OFFSET_RENDER_TARGET(initial(render_target), offset)
115+
offset_already_updated = TRUE
112116

113117
/atom/movable/screen/plane_master/proc/set_alpha(new_alpha)
114118
true_alpha = new_alpha

code/_onclick/hud/rendering/render_plate.dm

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -505,6 +505,8 @@
505505
/atom/movable/screen/plane_master/proc/add_relay_to(target_plane, blend_override, relay_layer, relay_color)
506506
if(get_relay_to(target_plane))
507507
return
508+
if(!offset_already_updated)
509+
CRASH("Attempted to draw a render relay before our offset has been applied, this WILL break")
508510
render_relay_planes += target_plane
509511
var/client/display_lad = home?.our_hud?.mymob?.canon_client
510512
var/atom/movable/render_plane_relay/relay = generate_relay_to(target_plane, show_to = display_lad, blend_override = blend_override, relay_layer = relay_layer)

0 commit comments

Comments
 (0)