[2.1.8][modded] Crash when placing two locomotive on top of each other inbetween tracks

Things that has been reported already before.
User avatar
jurgy
Inserter
Inserter
Posts: 48
Joined: Wed Feb 27, 2019 5:55 pm
Contact:

[2.1.8][modded] Crash when placing two locomotive on top of each other inbetween tracks

Post by jurgy »

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:

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, 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:
06-26-2026, 20-25-35.png
06-26-2026, 20-25-35.png (1.93 MiB) Viewed 121 times
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:
06-26-2026, 20-30-03.png
06-26-2026, 20-30-03.png (501.88 KiB) Viewed 121 times
Attachments
mod-list.zip
(1.12 KiB) Downloaded 6 times
factorio-current.log
(12.7 KiB) Downloaded 6 times
User avatar
jurgy
Inserter
Inserter
Posts: 48
Joined: Wed Feb 27, 2019 5:55 pm
Contact:

Re: [2.1.8][modded] Crash when placing two locomotive on top of each other inbetween tracks

Post by jurgy »

Not sure if this is the same bug. I'm specifically not fast-replacing the loco for my bug.

E: Probably it is, it crashes on the same line:
Error Rail.cpp:182: this->state == RailConnectionDirection::None was not true
Post Reply

Return to “Duplicates”