[2.1.8][modded] Crash when placing two locomotive on top of each other inbetween tracks
Posted: Fri Jun 26, 2026 6:31 pm
I found this crash-to-desktop when placing a locomotive on top of another locomotive right in between two tracks.
I came across the issue when messing with the new fast_replace option for rollingstock, but as it turns out that isn't the root cause.
It's kind of a weird scenario since the solution should just be "don't do that" but wanted to report it anyway since it crashes to desktop.
I've attached a small mod that can quickly identify the issue.
The main thing for the repro is this event:
As you can see, in the on_built of a locomotive, I place another at exactly the same position which I expect to fail. But to my suprise they do get placed on top of each other if it's not place right between two tracks, or crashes if it is:
The white lines are from the debug option "show-rail-connection".
As you can see I was able to place a locomotive in the curve by carefully centering it between two rail pieces, but placing another afterwards crashes the game.
Also, like I said, the create_entity doesn't fail when the train is actually placed which is kinda odd:
I came across the issue when messing with the new fast_replace option for rollingstock, but as it turns out that isn't the root cause.
It's kind of a weird scenario since the solution should just be "don't do that" but wanted to report it anyway since it crashes to desktop.
I've attached a small mod that can quickly identify the issue.
The main thing for the repro is this event:
Code: Select all
script.on_event(defines.events.on_built_entity, function(event)
local entity = event.entity
local surface = entity.surface
local entity_data = {
name = "locomotive",
position = entity.position,
direction = entity.direction,
force = entity.force,
raise_built = false,
fast_replace = false,
create_build_effect_smoke = false,
orientation = entity.orientation,
enable_logistics_while_moving = entity.enable_logistics_while_moving,
grid = entity.grid,
color = entity.color,
copy_color_from_train_stop = entity.copy_color_from_train_stop
}
surface.create_entity(entity_data)
end, {{filter = "rolling-stock"}})
As you can see I was able to place a locomotive in the curve by carefully centering it between two rail pieces, but placing another afterwards crashes the game.
Also, like I said, the create_entity doesn't fail when the train is actually placed which is kinda odd: