ID:2525156
 
Not a bug
BYOND Version:513.1500
Operating System:Windows 7 Home Premium 64-bit
Web Browser:Chrome 78.0.3904.108
Applies to:Dream Seeker
Status: Not a bug

This is not a bug. It may be an incorrect use of syntax or a limitation in the software. For further discussion on the matter, please consult the BYOND forums.
Descriptive Problem Summary:
When I add an obj that also has overlays to my overlays or vis_contents, if it has layer = 5, it's appeareance layers get mixed, having the icon appear above the overlays. As in the picture:

https://prnt.sc/q1tlg5

Numbered Steps to Reproduce Problem:
1 - Create an obj
2 - Set an icon and overlays to it
3 - Set it's layer to 5
4 - Add it to your mob's overlay or vis_contents lsit


Code Snippet (if applicable) to Reproduce Problem:
atom/var/tmp/reflection

mob/verb/CreateReflection()
var/reflection/RF = new
RF.icon=src.icon
RF.overlays=src.overlays.Copy()
src.reflection=RF
src.overlays+=src.reflection//can also be vis_contents

reflection
layer=5//all other values below this can be removed and the issue will still persist
parent_type = /obj
density = 0
mouse_opacity = 0
appearance_flags = KEEP_TOGETHER | KEEP_APART | PIXEL_SCALE | LONG_GLIDE
alpha = 192
pixel_y=-40


Expected Results:
The obj's appeareance layering stays intact

Actual Results:
Icon gets above overlays

Does the problem occur:
Every time? Or how often? Yes
In other games? Yes
In other user accounts? Yes
On other computers? Yes

When does the problem NOT occur? Never

Did the problem NOT occur in any earlier versions? If so, what was the last version that worked? (Visit http://www.byond.com/download/build to download old versions for testing.) Can't test right now.

Workarounds:
Setting other value to the layer
Do you have a test project for this?
In response to Lummox JR
Sent the link on pm
I changed world.view to a smaller value in your project so I could see it better. I'm not seeing the same issue you are.

When I used the AddOverlays verb and followed it up with CreateReflection, the copy in the reflection object had all the same icons in the same order. At first I found this surprising, but on examining how things were actually behaving I realized this is correct.

Your original player with overlays has three icons: the mob itself on MOB_LAYER (4), the cape on MOB_LAYER-1 (3), and the helmet on MOB_LAYER+1 (5). Importantly, the icons appear in that order. Your reflection object has the same three icons, except the main icon is on layer 5 instead of 4; the cape and helmet are the same. So the reflection has icons on layer 5, 3, and 5, in that order.

After sorting by layer, the layers will retain their original positions relative to any other icons with the same layer. Therefore, the main icon in the reflection object stays on top of the cape because it's a higher layer, and it's underneath the helmet because it's the same layer but was added to the list first. When you change the reflection's main icon's layer to 3, then you have layers 3, 3, and 5. The main icon appears beneath the cape now because it has the same layer as the cape and precedes it in the original ordering.

So unless I'm missing something, I don't think this is a bug.
In response to Lummox JR
Well from the definition of overlays on the ref:
"This is a list of icons which are displayed on top of the object's main icon. "

So in my conception, no matter the layer, all things in overlays should appear above the parent atom.
In response to NSBR
NSBR wrote:
Well from the definition of overlays on the ref:
"This is a list of icons which are displayed on top of the object's main icon. "

So in my conception, no matter the layer, all things in overlays should appear above the parent atom.

That's incorrect. The reference entry for overlays does begin with that oversimplified statement, but it also says later on: "Overlays have their own independent drawing layer."

I believe the reference could use some clarification on this point however, in documenting overlays and underlays, to explain that layer takes priority. The difference between overlays and underlays is really only in which icons are put into the pre-render list first, which affects how FLOAT_LAYER behaves. To be honest this is the first time I've ever seen this issue of clarification come up; the fact that layer is more important than whether an object is in underlays or overlays is very well known, but apparently not as well documented.

In your example project, note that your main icon--not the reflection--already relies on the behavior I described. You have created both the cape and helmet as overlays, but the cape has a lower layer than your base icon and therefore draws beneath it.
Lummox JR resolved issue (Not a bug)