News:

Do you need help?
Simutrans Wiki Manual can help you to play and extend Simutrans. In 9 languages.

Overtakers run over a stationary obstacle

Started by iv5343, November 26, 2023, 06:29:52 PM

Previous topic - Next topic

0 Members and 1 Guest are viewing this topic.

iv5343

This is a bug in Simutrans r11009, apparently introduced in 2016, in file simconvoi.cc line 3692, convoi_t::can_overtake():

const sint32 tiles = other_speed == 0 ? 2 : (steps_other-1)/(CARUNITS_PER_TILE*VEHICLE_STEPS_PER_CARUNIT) + get_tile_length() + 1;

At this point it was already established that the obstacle is stationary, i.e. other_speed == 0, so we always get tiles = 2.  This variable is the distance in tiles the overtaker must remain on the passing lane.  The value 2 counts the tile the overtaker is on and the tile of the obstacle.  The overtaker returns to its original lane when its midpoint enters the following tile, so its rear half runs over the obstacle.  When the obstacle convoi_t occupies more than one tile the overtaker runs wholly over its leading vehicles.  Moreover this code does not add the length of the overtaker (get_length_in_steps()) so any trailing vehicles of the overtaking convoi_t run over the obstacle as well.  Note vehicles can overtake a stationary object in four directions and for unrelated reasons the symptoms are direction dependent.

Please restrain the length of your lines.  This one has 123 characters including indentation, I've seen others cross the 250 character mark and code nested 12 levels deep.  Bugs should be obvious, hard to read code is not helping.

prissi

This routine also ignored the length of the other convoi too.

The East and North display directions are shifted by half a tile since the old display code needed that to avoid artefacts if one does not use directional clipping. Thus that bug is less prominent is those directions. You can see this by the stopping position at traffic lights. The new code could handle this but would require a realignment of all vehicles across most pak sets.

The overtaking code has not been reworked for some time, and I am sure there are even more bugs lurking. I hope I can have a look at it later.