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

TransferCargo can load more cargo than (new) capacity #4912

Closed
DorpsGek opened this issue Dec 26, 2011 · 4 comments
Closed

TransferCargo can load more cargo than (new) capacity #4912

DorpsGek opened this issue Dec 26, 2011 · 4 comments
Labels
flyspray This issue is imported from FlySpray (https://bugs.openttd.org/)

Comments

@DorpsGek
Copy link
Member

fonsinchen opened the ticket and wrote:

The function TransferCargo in autoreplace_cmd.cpp:98 is called when a train is autoreplaced and its cargo is transferred. It first transfers the cargo based on some initial value of cargo_cap for the new vehicles and then calls ConsistChanged on the new train which can alter cargo_cap without calling CargoList::Truncate (see train_cmd.cpp:220). Thus the resulting cargo can be higher than the final capacity for a vehicle.

This doesn't cause any immediate problems in trunk, but makes it difficult to record capacities and usages for links in cargodist. I think a vehicle having more cargo than capacity contradicts the idea of cargo capacity also in trunk.

Reported version: trunk
Operating system: All


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

fonsinchen wrote:

As you can see in the attached example the only train in the game is clearly overloaded shortly after being autoreplaced. Before the autoreplace it was carrying the same number of passengers; the autoreplace reduced the capacity. There must be an additional problem somewhere as one wagon is carrying 130 passengers while having an old capacity of 60 and a new one of 50.

Attachments


This comment was imported from FlySpray: https://bugs.openttd.org/task/4912#comment10611

@DorpsGek
Copy link
Member Author

Rubidium wrote:

The problem is slightly more complicated. TransferCargo is, if the train is 'correct', working as it should. It will just add cargo to the wagons that have free space. However, due to the wagons getting another capacity based on the leading engine the train is in essence 'incorrect'. These wagons are not replaced and thus do not 'need' to get their cargo transfered from another vehicle.

I'd be simplest to just truncate the cargo in ConsistChanged... however, those lovely wagons reduce their capacity to 1 when they are free so most of their cargo gets lost.

This brings us to doing the replace manually, where you move the chain from one engine to another. Then you'd have the same problem, so it should be done in CmdMoveWagon... however, then you get the same problem as ConsistChanged as autoreplace calls CmdMoveWagon to move everything around. And again you'd end up with mostly empty wagons upon replacing (automatic and manual).


This comment was imported from FlySpray: https://bugs.openttd.org/task/4912#comment10615

@DorpsGek
Copy link
Member Author

peter1138 wrote:

  1. Unload all the cargo into temporary storage somehow
  2. Perform the replace
  3. Load all the cargo from temporary storage

Maybe?


This comment was imported from FlySpray: https://bugs.openttd.org/task/4912#comment10620

@DorpsGek
Copy link
Member Author

Rubidium closed the ticket.

Reason for closing: Fixed

In r23683


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

@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