Fluid Trains deprecated


Adds functionality for locomotives to use fluids as fuel. This mod does not add any locomoties on its own but enables other mods to do so

Content
4 years ago
0.18 - 1.1
11.3K
Trains

b Non-recoverable error (0.18.5) [fixed]

4 years ago
(updated 4 years ago)

https://imgur.com/a/RV8K1S7

Playing with Steam Locomotives, Factorio version 0.18.5, both mods are latest version. Also using TSM in case that matters.

4 years ago

can you provide a save-file as well as the instructions to reproduce the bug?

4 years ago
(updated 4 years ago)

https://drive.google.com/open?id=1CNCBogtby0ZcnnqKXkMfUgiOlVoxKir6
Here you go, but it's pretty heavily modded.

The bug consistently happens by itself about 5 minutes in, but not if everything else except the two is turned off. I will try turning the mods back on one by one and see what exactly causes it a bit later.

4 years ago

Yup, it's TSM. Whenever a Steam Locomotive gets to a Requester Station, that happens.

4 years ago

thanks for the analysis. I'll look into it tomorrow. should be relatively easy to analyze and at least provide a hotfix for that.

4 years ago

Alright, thanks a lot :)

4 years ago
(updated 4 years ago)

After a little bit more testing, noticed that it also happens when switching a train to manual mode, but only sometimes. Hm.

4 years ago

sorry for the delay - I had a hard time figuring it out, but once I saw it it was obvious...

Turns out that it is not TSM related - the crash was related to the internal IDs of the locomotives and appeared for locomotives that had an ID divisible by 120. all that removing TSM did was preventing the one bad locomotive from moving and that in turn hid the issue.

Should be fixed in fluidTrains 0.18.6

4 years ago

Ah, I see. The ID being divisible by 120 causing problems sounds like a pretty weird bug.

Thanks a lot for the fix tho!

4 years ago

actually it's pretty simple once you see it:

There are some operations that must not be performed in every game tick (not needed for the functionality and has potentially massive performance impact). The "standard" approach is to distribute the updates over multiple ticks, such that each tick only updates some entities. My work queue was divided into 120 groups. The simplest way to distribute the locomotives into these groups is to simply divide the ID by 120 and then take the remainder as the group number: A locomotive with ID 240 would be in group 0, one with ID 256 would be in group 16, etc...

Here the problem was that usually arrays are zero-indexed (i.e. the groups would be numbered 0-119). But LUA arrays are one-indexed, so the group numbers need be 1-120. While my broken calculation usually worked, whenever a locomotive ID was divisible by 120, the calculated group ID would be 0. But 0 is no valid index, and it crashes.

In essence it is a simple off-by-one-error. Trivial to fix, but a pain to spot.

4 years ago

Oh, that's actually pretty interesting. Never knew Lua arrays start at 1.
Btw, if I understand correctly, it takes 2 seconds to check through every train this way? Forgot if Factorio works at 30 or 60 UPS.

4 years ago

factorio runs at 60UPS. my queue worked at 120 ticks (2s) initially but that has since been increased to 300 (5s). it is only needed for tender updates if that is enabled, but always runs in the background.

4 years ago

Alright, I see now

New response