ID:2337799
 
Resolved
FLOAT_PLANE didn't work correctly in multiply-nested cases.
BYOND Version:512.1403
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 63.0.3239.84
Applies to:Dream Seeker
Status: Resolved (512.1404)

This issue has been resolved.
Descriptive Problem Summary:

When an object with FLOAT_PLANE/FLOAT_LAYER is added to the vis_contents of an object with FLOAT_PLANE/FLOAT_LAYER, which is in the vis_contents of an object with a specific plane/layer, the floating behavior does not conform to the top-level object's plane/layer as one would expect.

This causes components of components to become mislayered when rendered.

Object A has layer of 1, and plane of 2.

Object B has layer of FLOAT_LAYER, and plane of FLOAT_PLANE.

Object C has layer of FLOAT_LAYER, and plane of FLOAT_PLANE.

They are nested via vis contents:

A{B{C}}

A renders properly.

B renders properly.

C renders beneath A.


One would expect, that C would use A's layer/plane for rendering, given that C is inside of B, which defers to A for layer/plane. Instead, FLOAT_LAYER/FLOAT_PLANE only attempt to look to the parent for layering, rather than the last explicit plane/layer being carried down the visual hierarchy, which in my opinion, would be the correct behavior.
Man, that's a weird one. I know that Unfloat() isn't called until the top parent returns, so this is kinda baffling. Maybe it has something to do with two successive inherited FLOAT_PLANEs.

If by any chance you can whip up a quick demo that would be helpful. I can investigate myself in a test project if not though.
Lummox JR resolved issue with message:
FLOAT_PLANE didn't work correctly in multiply-nested cases.
This is not resolved.
In response to Ter13
Huh. But the test case I created in my debug project shows the correct behavior now.

mob/verb/Planes()
if(vis_contents.len)
vis_contents = null
plane = initial(plane)
return
plane = 2
var/obj/O1 = new
var/obj/O2 = new
O1.plane = FLOAT_PLANE
O1.layer = FLOAT_LAYER
O1.icon = 'items.dmi'
O1.icon_state = "sphere"
O1.pixel_x = 12
O2.appearance = O1.appearance
O2.icon_state = "box"
O2.pixel_x = 12
O1.vis_contents += O2
vis_contents += O1

What cases does this fail on currently? Or better still, is there a quick test project to show it?
I cut out all the unnecessary crap from the project I was seeing this in. This is a minimal test case. If you need me to explain how things work, just hit me up via PM. I'll explain why it's designed the way it is.

http://files.byondhome.com/Ter13/TestFloat_src.zip

Also, there's a bonus in there for you. I never made the report properly, but the new screen_loc flags for LEFT,TOP,BOTTOM,RIGHT, etc. have never worked since the first release.

Read the comments in my test project. I've left a couple lines for you to mess with to demonstrate the issue.
Thanks. I'll look into this.
For the main bug, I found a couple of issues. First, screen objects were not calling Unfloat() in the correct way, which effectively acted like it wasn't called at all. Second, and this is a legacy issue, Unfloat() never liked working with layer=0 and wasn't prepared to handle it properly. Since I can't see a reason for an old project to be using layer=0 and the changed behavior is better and more consistent, I'm making the change.

I see the issue with the screen edge coordinates, and that's gonna take longer to fix. I have to rethink how I'm handling those coords so they work properly in sub-icons.