The International Simutrans Forum

Simutrans Extended => Simutrans-Extended bug reports => Simutrans-Extended development => Simutrans-Extended closed bug reports => Topic started by: Jando on May 06, 2017, 05:00:44 PM

Title: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 06, 2017, 05:00:44 PM
Here is a saved game where I can observe a train pulling into a station, correctly waiting for full load, but not loading any new cargo that becomes available after train entered the station: http://files.simutrans.com/index.php/s/8i15sTLdhDUGb0H

What can be observed:
When does the train finally depart?

Train will load the cargo when one of the following actions happen (whatever comes first):

1. Player opens and closes the schedule window of that train (no change to any settings needed).
2. Another train pulls into another platform of that station, no matter whether other train is serving the same line or not.
3. Player saves the game and reloads the saved game.
4. About 3 game-hours pass.

And awfully sorry for all these reports, James. And thank you so much for your work on this! Just tell me when I should stop to file more reports, hehe.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 06, 2017, 06:14:41 PM
Thank you for the report. I think that I have been able to fix this. Would you be able to re-test? I should be most grateful.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 08, 2017, 12:35:43 PM
Good news first: trains waiting for full load now load cargo that becomes available while the train is waiting.

Bad news too: this does not necessarily mean that the train will depart with this full load. Have seen trains sitting at station with full load not departing. Trying to catch a situation where I can reproduce this for a save game.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 08, 2017, 01:14:10 PM
Yes, please do: I will need that in order to fix this. Thank you.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 08, 2017, 01:16:36 PM
Here is a saved game where I can reproduce this bug: http://files.simutrans.com/index.php/s/a5mwqLMrmYynLyL

I think it's related to the use of a maximum wait time while waiting for full load because in this saved game the bug only happens when maximum wait time is used. To see this I suggest:

1. Load the saved game.
2. Hit pause. You see train #5 pulling into station Staffpike Colliery West. Train is configured as waiting for full load with a maximum wait time of 6h24m. Train will need to wait at the station because there's not enough cargo available.
3. Unpause. Train will pull into station and wait. Within a few minutes new cargo will become available and the train will correctly load the new cargo. However train will not depart after it has reached full cargo (192 tons).
4. Load the saved game again.
5. Hit pause.
6. Manually edit the schedule of train #5 and remove the maximum wait time.
7. Unpause. Train will pull into station, wait and load cargo and depart when full load has been reached.

Thanks again, James!
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 11, 2017, 12:07:09 AM
Thank you for the report. I think that I have managed to fix this. Would you be able to re-test? I should be most grateful.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 12, 2017, 08:22:58 PM
Have seen another case of the not-departing at 100% load with the new nightly but not yet been able to reproduce it, will try again.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 13, 2017, 08:45:38 AM
Odd, here is a saved game where I can observe the not-loading when cargo becomes available bug again: http://files.simutrans.com/index.php/s/ElO7lCjhqLTId6n

You see train #8 waiting for full load at Staffpike Colliery South, cargo is available at the station that the train has not loaded. Fast forward, more cargo will become available that the train will not load. Train will load cargo (and depart if full load) when you either open and close the train's schedule window or when the waiting count-down timer has reached 3h12m00s. I reckon that's not by chance. But other trains on that same map seem to be doing fine.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 13, 2017, 11:14:43 AM
Thank you for the report. The immediate cause of the problem seems to be that the variable telling the train how long to wait before checking whether it needs to do anything again is set to the time when the wait until max. load expires. This was the immediate cause of the other bugs above, too.

Unfortunately, from the state in which the saved game is available, there is no way of telling how that incorrect number came to be set, and allowing the game to run on so does not show this problem as being reproducible for the next two occasions on which trains of that line stop at that colliery. Are you able to reproduce a situation in which this bug arises in respect of a train which is just about to stop at the station where it occurs?
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 13, 2017, 11:18:46 AM
Quote from: jamespetts on May 13, 2017, 11:14:43 AM
... Are you able to reproduce a situation in which this bug arises in respect of a train which is just about to stop at the station where it occurs?

I'll try over the weekend. :)
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 13, 2017, 12:00:56 PM
Thank you.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 14, 2017, 10:31:21 PM
Tough job, have seen one more occurrence of this bug, at another line, had a saved game from 15 minutes before that, reloaded saved game, watched the train/station where it happened, didn't happen again after reloading though. 

I'm almost thinking the bug happens (or rather how the wrong data gets into the variable) through some sort of player interaction, like editing schedule or sending away a train early. I did nothing of that after reloading the saved game. Will keep looking for something that can be reproduced.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 15, 2017, 12:40:32 AM
Thank you very much for your investigations: this is much appreciated.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on May 17, 2017, 10:52:27 PM
I retract the earlier opinion that it may be related to editing the schedule of the train/line.

Observed a train now not loading any new cargo on a line that I did not edit/modify for several play sessions.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on May 17, 2017, 10:57:29 PM
Thank you for your testing of this. If you can set out a method reliably to reproduce this, I should be very grateful.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on June 01, 2017, 11:39:05 PM
Hello All! :)

Sadly still no reliable way found to reproduce this error, but thought I should mention that this bug is not related to reversing stops. because it can also happen on non-reversing stops.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on June 02, 2017, 05:56:12 PM
Thank you for reporting back. It is more or less impossible to fix a bug without being able to reproduce it reliably (at least it is for me: a more experienced coder might have better luck). If you or anyone else is able to find a means of reproducing this reliably, I should be most grateful.

It often happens that bugs like these are eventually fixed by fixing other bugs that are caused by the same coding error.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on June 04, 2017, 01:38:40 PM
I now have a saved game where I can reproduce this bug. I'm not sure it's the only way how the bug can happen, but at least it's a start. Saved game is here: http://files.simutrans.com/index.php/s/fRQE87y4bPGWgTC

It's a map I made a few weeks ago but didn't play yet. I kept the map because it has an interesting distribution of towns and industries, with an easy start for a train line transporting coal. That's where I started now, one train transporting coal from two colleries to a gasworks and a coal merchant.

When you load the saved game you see the train (the only one) approaching Carnburn Colliery. Industries have just demanded coal and the coal is in the process of transferring from the colleries to the station. No cargo will be available at the station when the train stops, thus the train correctly goes into wait for full load. After a few minutes the process of transferring coal to the station will be finished but the train will not load that cargo and instead continue to wait for full load.

The train will pick up the cargo when half of the specified maximum wait for full load time has passed or when the player opens the train's schedule information window.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: jamespetts on June 04, 2017, 03:12:30 PM
I think that I have managed to fix this; would you be able to re-check when the next nightly build is available? I should be most grateful.
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on June 04, 2017, 04:20:20 PM
Thank you very much, James. I will give the new version a good spin tomorrow. :)
Title: Re: Train waiting for full load won't depart when full load available at station
Post by: Jando on June 05, 2017, 09:23:17 PM
So far no occurrence of this bug seen with the new build. Good job!