Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improved loading can load consists in parallel even though there isn't enough cargo #5438

Closed
DorpsGek opened this issue Jan 6, 2013 · 2 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

DorpsGek commented Jan 6, 2013

fonsinchen opened the ticket and wrote:

The "improved loading" setting should have the effect that multiple "full load" consists loading at the same station should only load in parallel if there is enough cargo to fill them all. Otherwise the consists arriving later should wait with their loading until more cargo is available. However, there are certain corner cases where this doesn't work. See the attached savegame as example. If you just load it and let it run you will notice train 2 and 3 arriving at Duston North in quick succession, unloading there and starting to load. However, instead of filling one of them completely and one only partly the game will fill one to 98% and one to 35%. Obviously the improved loading fails.

This is due to an inconsistency in how cargo is "reserved" in the cargo_left array in SaveUnloadVehicle. When unloading cargo, as we don't know how much cargo will be unloaded, only the free capacity is reserved. The free capacity can grow as more cargo is unloaded, but the available cargo which should be loaded into the additional free capacity, can in the mean time (as it's not reserved, yet) be loaded by a different consist.

Furthermore, the reservation is only performed in ticks where no loading or unloading is done ("if (front->load_unload_ticks != 0)" in economy.cpp:1250). This means in ticks where a consist actually unloads, any later consist is free to "steal" cargo from it.

Attachments

Reported version: trunk
Operating system: All


This issue was imported from FlySpray: https://bugs.openttd.org/task/5438
@DorpsGek
Copy link
Member Author

DorpsGek commented Jan 6, 2013

fonsinchen wrote:

step1.sav actually shows a different effect. Due to station rating cargo can disappear while vehicles are loading. 333.sav shows the real thing. And there is a trivial fix for it, too. While a vehicle is unloading we can just reserve for its full capacity. If the reservation is decreased later not much harm is done. It will look to any following consist like new cargo appearing at the station.

The comment about not reserving while unloading is not true, as we're running the same reservation thing again in economy.cpp:1568ff. However, there we only run it if not autorefitting, which could potentially create other funny corner cases. The attached patch runs that part also in autorefit and still reserves for the vehicle in case it's unloading.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/5438#comment11855

@DorpsGek
Copy link
Member Author

DorpsGek commented Feb 3, 2013

Rubidium closed the ticket.

Reason for closing: Fixed

In r24962. Thanks for the patch


This comment was imported from FlySpray: https://bugs.openttd.org/task/5438

@DorpsGek DorpsGek closed this as completed Feb 3, 2013
@DorpsGek DorpsGek added Core flyspray This issue is imported from FlySpray (https://bugs.openttd.org/) labels Apr 7, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)
Projects
None yet
Development

No branches or pull requests

1 participant