Author Topic: Departures per month depends on map rotation  (Read 431 times)

0 Members and 1 Guest are viewing this topic.

Offline TurfIt

Departures per month depends on map rotation
« on: July 25, 2017, 01:45:49 AM »
or actually the facing of the stop which changes upon map rotation.
Attached example. Both lines are set for 15 min spacing, one waits at the north station, one at the south. In steady state, the north waiters end up with 30 min spacing.

Observe the first two convois arriving at the north station have the correct waiting times. Once a line into the station forms, the waiting time doubles. The reversing convoi is still counted as being in the station for the purposes of  halt->get_queue_pos(self) in the waiting time calc. For the south station waiters, the queue_pos remains 1 since the reversing completes before the next convoi makes it in all the way.

Rotate the map once so the north station becomes east. Now the waiting times return to the correct 15 min spacing. But the formerly south, now west, line ends up with the 30 min waits...

« Last Edit: July 25, 2017, 01:59:26 AM by TurfIt »

Online jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15698
  • Total likes: 395
  • Helpful: 174
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Departures per month depends on map rotation
« Reply #1 on: July 26, 2017, 10:44:38 PM »
Thank you very much for reporting this, and apologies for not reverting on this or the other bugs any sooner: I have been rather busy with work in the past few days.

I am having some difficulty in working out quite what is happening here (albeit I have only looked at this relatively cursorily so far): normally, errors caused by rotation are caused by a koord or koord3d value being stored somewhere and not being rotated when the map is rotated. Here, the only koord(3d) values that I can find are vehicle_t::last_stop_pos, which is rotated, and haltestelle_t::get_basis_pos(). May I ask - is the latter rotationally consistent? In other words, would the following evaluate to true:

Code: [Select]
koord3d k = get_basis_pos();
[Rotate the world]
koord3d k2 = get_basis_pos();
k == k2

It would help me to know the position before I start looking into this in detail as this might save me some time. Thank you again for all of your very helpful testing and detailed reports of late.
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.

Offline Dwachs

  • DevTeam, Coder/patcher
  • Administrator
  • *
  • Posts: 4247
  • Total likes: 175
  • Helpful: 149
  • Languages: EN, DE, AT
Re: Departures per month depends on map rotation
« Reply #2 on: July 27, 2017, 06:06:04 AM »
basis_pos is rotated as well: it is the position of the first tile of the station.
Parsley, sage, rosemary, and maggikraut.

Offline TurfIt

Re: Departures per month depends on map rotation
« Reply #3 on: July 27, 2017, 06:38:47 PM »
Don't confuse the method to expose the bug with the bug itself...

Rotating map changes station orientation. Station orientation determines convois stop position - half tile in for N/W, full tile for E/S. Combine with unfortunate coincidence of timings - convois reversing time, and other convois speed/accel  (time it takes to go a half and full tile), and you end up with a wrong waiting time.

The problem is  haltestelle_t::get_queue_pos is including the reversing convoi as being in the queue waiting for a full time slot even though its in the process of departing. Hence when the second convoi arrives while the first is in the reversing stage, the second convoi gets given a departure slot two out. The go_on_ticks calculations in convoi_t::hat_gehalten are faulty.

The map rotation simply makes it so the second convoi has to travel farther before arriving at the stop, and hence the arrival is after the reversing convoi departs.

Online jamespetts

  • Simitrans-Extended project coordinator
  • Moderator
  • *
  • Posts: 15698
  • Total likes: 395
  • Helpful: 174
  • Cake baker
    • Bridgewater-Brunel
  • Languages: EN
Re: Departures per month depends on map rotation
« Reply #4 on: July 27, 2017, 09:53:12 PM »
Thank you both for your help: that is much appreciated. It seems that the difference in the waiting time is caused, as TurfIt has helpfully deduced, from the stop position inconsistency (which is ultimately from Standard), leading some vehicles to reach the stop at different times than others. This difference would, if I have understood this correctly, be the same whether or not reversing were taken into account in the determination of the queue position, albeit the difference would occur at slightly different times.

Reversing vehicles being counted as loading for the purposes of the queue position, however, is deliberate: vehicles with a waiting time start reversing in time so that they finish reversing just before they are due to depart, as reversing takes time. Vehicles can load and unload whilst reversing in a station/stop, so vehicles reversing ought to be accounted for in the queue position.

Thus, I am not sure that this is, properly understood, an error in the code relating to determining the queue position or the calculation of the waiting/reversing time. Does this make sense, or have I misunderstood something?
Download Simutrans-Extended.

Want to help with development? See here for things to do for coding, and here for information on how to make graphics/objects.

Follow Simutrans-Extended on Facebook.