[2.0.77] Calling `set_blueprint_entities` with the (unmodified) result of `get_blueprint_entities` can corrupt BPs

Post your bugs and problems so we can fix them.
The_LORD_thy_GOD
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sun Nov 10, 2024 5:23 pm
Contact:

[2.0.77] Calling `set_blueprint_entities` with the (unmodified) result of `get_blueprint_entities` can corrupt BPs

Post by The_LORD_thy_GOD »

The Issue
When "Select New Contents For This Blueprint" is used, during the corresponding `on_player_setup_blueprint` event, calling `.set_blueprint_entities()` with the (unmodified) return result from `.get_blueprint_entities()`, corrupts the blueprint. Specifically it appears to shift rail entities down and to the right by one tile from where they should be, causing strange overlaps and impossible entity stacks in the blueprint.

I would expect this operation to be the identity operation, leaving an unmodified blueprint.

This does not appear to occur when creating a fresh blueprint; only when replacing contents.
Reproduction Steps
1) Load this BP into inventory:

2) Stamp it down in the world somewhere.

3) Create and enable a mod with the attached `control.lua` script.
control.lua
(724 Bytes) Downloaded 18 times
4) Open the blueprint from (1), choose Select New Contents, and select everything that was stamped down in (2).

5) Observe that the blueprint appears to have been corrupted. (the rail signal on the bottom is now impossibly stacked with its rail and the rails have shifted to the right of their original positions)
The_LORD_thy_GOD
Burner Inserter
Burner Inserter
Posts: 16
Joined: Sun Nov 10, 2024 5:23 pm
Contact:

Re: [2.0.77] Calling `set_blueprint_entities` with the (unmodified) result of `get_blueprint_entities` can corrupt BPs

Post by The_LORD_thy_GOD »

I believe I may have further isolated the cause from further testing:

- If the "Snap to Grid" options for the BP being replaced are disabled altogether, the issue does not occur.

- When "Snap to Grid" is enabled, the various grid-snapping values contribute to the issue, with different values either causing or not causing it. I believe the cause may be an "odd+odd=even" offset from the global grid.

This Bp (Snap to 10x10, no adjustments) DOES NOT exhibit the issue:


This BP (Snap to 10x10, odd+odd=even tile offset from absolute + local grid shifts) DOES exhibit the issue:


So to sum up findings, blueprints with rails (or probably other build-grid-2 things) that have "odd+odd=even" positioning relative to the global grid are, specifically, getting corrupted by this operation. (This also probably explains why creating a new BP doesn't exhibit the issue, because there's no snapping by default)
Post Reply

Return to “Bug Reports”