0ptera / Logistic-Train-Network

Factorio mod adding logistic network for trains.
Other
155 stars 55 forks source link

Incorrect calculation of train slots available with mixed item types + double-headed trains #315

Open amckinley opened 1 year ago

amckinley commented 1 year ago

Error message or bug description While trying to use LTN with mixed-item shipments, I'm pretty sure I found a bug where LTN is incorrectly calculating a train's total stack size. I have a <CCL> train that was dispatched to pickup this load:

Screenshot from LTN Manager interface: unnamed

Screenshot of signals coming from the LTN station's constant combinator output: unnamed (1)

This load requires the following assignment of stacks:

This is 83 stacks, which does not fit in the 2 wagons available on the train (80 stacks). It would "fit", however, if LTN was counting the final locomotive as having a 3-stack cargo, even though it's actually just the inventory.

I tried to trace through the code to see if I could find something suspicious, and I got as far as here. I wonder if some recent Factorio update started putting the non-head locomotives in the cargo_wagons variable?

I'm playing SE so my save file is like 400MB, but I'm happy to find a place to upload it if that would help.

To Reproduce Request a complicated mixed wagon and have it filled by a train with locomotives at both ends.

LTN version 1.18.1

Log file

factorio-current.log

0ptera commented 1 year ago

This is 83 stacks, which does not fit in the 2 wagons available on the train (80 stacks). It would "fit", however, if LTN was counting the final locomotive as having a 3-stack cargo, even though it's actually just the inventory.

I tried to trace through the code to see if I could find something suspicious, and I got as far as here. I wonder if some recent Factorio update started putting the non-head locomotives in the cargo_wagons variable?

I highly doubt Wube made changes like that without mentioning it in their changelogs. However some mods create locomotives with integrated cargo wagons.

I don't have time to download a heavily modded 400MB save and filter out all mod interactions. To start analyzing I need the following: 1) factorio-current.log with LTN's debug log enabled. The logfile must be complete and have the logging option enabled for a few seconds before the delivery was created and include everything until the train arrives at the provider. 2) Names of stops between which the delivery was created

Even better would be if you can reproduce the error on a newly created map with only LTN running.

amckinley commented 1 year ago

Thanks for the quick response! I'll start working on a more compact repro.