News: Portal
Our Simutrans site. You can find everything about Simutrans from here.

Road vehicles are displayed in wrong depth order on heading changes

Started by iv5343, November 25, 2023, 06:43:04 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.


This is a bug in Simutrans r11009 and earlier, in file line 518, in road_vehicle_t::enter_tile():


The order of these statements is backwards. enter_tile() invokes objlist_t::intern_add_moving() which uses vehicle_base_t::disp_lane to depth-sort the vehicles on this tile.  Symptoms, on a world with right side driving:  When road vehicles change their heading from NW to N they are drawn in wrong order, convoi_t leader last.  When they change from E to SE the same happens except in this direction the wrong order is leader first.  When a vehicle changes from SE to E, moving on the right (front) lane, it is drawn "under", i.e. first before any vehicles moving in the opposite direction on the opposite (back) lane of the same tile.

For road users Simutrans distinguishes five parallel lanes to draw vehicles on different lanes in correct back to front order.  Taking the driver's perspective they have ascending numbers from leftmost to rightmost, and vehicles are sorted in ascending order by that number for display.  That means for vehicles moving to the left side of the screen, i.e. with a heading between SE and NW clockwise, the lane number must be mirrored.  This is done by the calc_disp_lane() method, not objlist_t or get_disp_lane().  The glitches occur where calc_disp_lane() changes disp_lane and objlist_t still uses the previous value.

private_car_t::enter_tile() has a similar code sequence and may be affected too.


Thanks for the report, both instances should be fixed now (r11010).