[1.1.104] Pumps stop working when mod replaces connected wagon

Post Reply
Riven8192
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Mar 15, 2024 9:37 pm
Contact:

[1.1.104] Pumps stop working when mod replaces connected wagon

Post by Riven8192 »

Problem:
When a pump is pumping fluid either to or from a train wagon, and a mod swaps it with another fluid-wagon entity, the pump will stop working. For cargo wagons, the inserters continue to work fine when the cargo-wagon entity is swapped.

Affected mod:
https://mods.factorio.com/mod/TrainMass

How to reproduce:
- Install mod TrainMass
- Put a locomotive + fluid-wagon on rails.
- Pump any fluid into the wagon (at least 1000L, which is guaranteed to trigger the entity-swap).
- The pump remains in the attached-state, but does not pump any fluids.
- The mod currently already implemented a workaround, by swapping the pumps too, which can be disabled by clearing out the implementation of the function recreatePump(...) in control.lua - after that you will see the pump getting stuck.
Reproducability: always.


Workaround:
My mod replaces the connected pumps in the same tick that the wagons are replaced. However, this shows the attaching-animation, and incurs a time delay before the pumping is resumed.

Solution:
A. The pump would continue to transfer fluids into the new fluid-wagon.
B. The pump would detach and re-attach.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [1.1.104] Pumps stop working when mod replaces connected wagon

Post by boskid »

Thanks for the report.

I am not going to fix that issue in 1.1.x because pump logic is quite tricky to not cause performance problems. One of the operations in pump that is relatively expensive due to entity searches is search of fluid wagons so pump tries as much to not do those searches if not necesary. In this case there seem to be a logic error because when pump is connected to fluid wagon it does not try registering on a rail which on second swap causes pump to disconnect from fluid wagon while not being registered on a rail so new fluid wagon placed does not notify pump that it should now perform the relatively expensive entity search.

It looks like i already fixed this issue for 2.0 during a pump logic rework.

For a least intrusive workaround in 1.1.x i can suggest flipping direction twice as direction change forces pump to scan for fluid wagons nearby.

Riven8192
Manual Inserter
Manual Inserter
Posts: 2
Joined: Fri Mar 15, 2024 9:37 pm
Contact:

Re: [1.1.104] Pumps stop working when mod replaces connected wagon

Post by Riven8192 »

Thank you for reply. It's great to hear it's fixed in 2.0, and there is a better workaround in 1.1 than replacing the pump. ;)

Post Reply

Return to “Fixed for 2.0”