[2.0.72] can_place_entity can be incorrect due to train pushback after collision

Post your bugs and problems so we can fix them.
BurninSun
Long Handed Inserter
Long Handed Inserter
Posts: 78
Joined: Fri Mar 16, 2018 4:54 am
Contact:

[2.0.72] can_place_entity can be incorrect due to train pushback after collision

Post by BurninSun »

Load save, run:
/c script.on_event(defines.events.on_entity_died, function(e) local entity_info = {force="player", name="car", position = {x=storage.loco.position.x, y = storage.loco.bounding_box.right_bottom.y+1.05}} if game.surfaces[1].can_place_entity(entity_info) then game.surfaces[1].create_entity(entity_info) end end)
Set train to automatic mode and watch.

Whats going on here:
There is a locked gate with low health that the train will run into after it is set to automatic mode. This will fire the on_entity_died event in the code above. That code is checking can_place_entity to see if the car entity can be placed. The car's collision_box has a height of 1 from its center and we're checking the position of the locomotives rear + 1.05 which should give us 0.05 of clearance. can_place_entity returns true because of the clearance, and we successfully create_entity for the car. The problem is, after this is done, the train is pushed back due to the collision with the gate. The pushback places the locomotive back far enough that its collision box is now well within the collision box of the car.

Expectation is that can_place_entity always ensures create_entity works without collision issues. The train's position due to collision pushback should be updated prior to firing on_entity_died.

While I did run into this while doing some specific testing in a more convoluted modded setup, this issue doesn't actually affect me if this ends up as a "won't fix".
Attachments
test 11.zip
(897.23 KiB) Downloaded 9 times
Post Reply

Return to “Bug Reports”