That's odd, because those sprites can't overlap. TTD takes great care to never allow overlapping sprites by using some fake boxes, only the new stuff that isn't possible in TTD can have overlapping sprite boxes. For example, the depot bounding box for the front sprite is just a 1x1 box at the front corner (IIRC). Maybe there's a bug in the part of your code that checks whether sprites overlap?therax wrote:Exactly what I ran into. Depot sorting got weird (roofs), as did rail fences and particularly the "build-on-slopes" tiles. I haven't looked into these in detail because of time constraints, but I have a sneaking suspicion these are from bad Z coordinate bounds for these sprites.
I tried changing shorter vehicles so that the sprite boxes are smaller, but that gave other problems. Ideally, the sorter should support boxes at a 45⁰ angle too, or else vehicles moving diagonally across the grid won't have the right boxes. I looked into that briefly but couldn't find a simple yet efficient algorithm without using a z-buffer, which isn't useful for TTD unless you give the sprites themselves a z layer. Using a z-buffer would probably be the most reliable solution, but then you'd have to go through every single sprite and add z information to it, which just isn't feasible, particularly with the new graphics sets that have thousands of sprites each.
I did write a few working sprite sorters (you probably saw the code commented out), and they get the sorting right but break because TTD cheats with the bounding boxes and I didn't feel like fixing all those boxes (bridges, depots, stations, electrified railways). Besides, it would've broken many of the new station sets, because they all hardcode the sprite layout assuming TTD's sprite sorter.