ID:1861711
 
BYOND Version:507
Operating System:Windows 7 Ultimate 64-bit
Web Browser:Chrome 43.0.2357.81
Applies to:Dream Seeker
Status: Open

Issue hasn't been assigned a status value.




Test project: http://www.mediafire.com/download/1ia2x67bsyahgqy/ layer_problem.zip

Descriptive Problem Summary:
The test project is very small, 1 page of code, it will explain everything!
I know this has been reported before but never fixed because nobody has yet provided a test game to show the bug, but I am. The bug is that in TOPDOWN_MAP with pixel movement there is a layering problem where for example if there are two players who's mobs have bound_y=0 and bound_height=23 with world.icon_size=32, and one player approaches vertically til they bump the other, they will be layered incorrectly about 50% of the time. See the picture.

Numbered Steps to Reproduce Problem:
Run the test project then approach the other mobs in it from the north til you bump into them and you will quickly see incorrect layering after bumping enough mobs.

Does the problem occur:
Every time? Or how often? 50% of the time roughly depending on step_y and step_x values
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.)
All versions I believe has this problem

Workarounds:
None that I know of being that my custom layering system based on y and step_y value didn't correct the problem as expected
This is the entire code to the test project
proc/Generate_test_mobs()
for(var/v in 1 to 100)
var/mob/m=new(locate(rand(1,world.maxx),rand(1,world.maxy),1))
m.step_x=rand(0,32)
m.step_y=rand(0,32)

world
fps=50
view=12
loop_checks=0
New()
Generate_test_mobs()

mob
step_size=4
bound_x=5
bound_height=23
bound_width=22
icon='Alien 9.dmi'
dir=NORTH

turf
icon='Grass.dmi'

Thanks for all your work on BYOND, I hate to slow down the process with another potentially useless bug report. But I think this is a real bug this time. Of course I always think it's a real bug til someone posts something refuting it.
I don't think this actually is a bug--not in topdown mode. Topdown mode does little tricks to try to present a consistent layering order when two objects share the same layer, but it can only go so far. You're overlapping your mobs, which requires the engine to get creative.

SIDE_MAP is actually intended for cases just like this. (Its layering isn't perfect either, owing to not using a topographic sort, but I'm hoping to fix that in the future. For what you're using it for, I'd say you're unlikely to see any of SIDE_MAP's issues and you're probably better off switching to it.)

I intend to look into this regardless, so if there is a bug in play I should find out. But I suspect that's not the case.
I did try SIDE_MAP and for some reason it has a bug where overlays of other players will flicker on and off while moving around. But that is an entirely different report.

But running this every Move() seems to give me the behavior I want in TOPDOWN_MAP
Update_y_layer()
if(!y) return
var/offset=y + (step_y / world.icon_size)
offset*=0.0001

layer=MOB_LAYER-offset

So it's all good
Probably the issue you're seeing is a subtle variation in the microlayer that objects are given. Your fix is basically very similar to the microlayer code.