dewiniaid / BlueprintExtensions

Useful blueprinting tools for Factorio
Other
4 stars 8 forks source link

Landfill interaction with Rails #14

Closed PiggyWhiskey closed 5 years ago

PiggyWhiskey commented 5 years ago

The Landfill Button and Rails don't interact nicely.

It will generally place a single piece of landfill under the rail piece, but then will not allow the rail to be placed.

Forcing spam clicking the Landfill/Blueprint to actually place it

dewiniaid commented 5 years ago

Please update to 0.4.4 and let me know if that fixes the issue.

There's some particular wonkiness with rail entity prototypes and collision boxes, Blueprint Extensions actually has to do some trickery to figure out what the real collision boxes are (since the information is not available on prototypes but only on real in-the-world rails) and it should do so on the first time loading a save or whenever your mod configuration changes (including... updating to 0.4.4). If, for some reason, this information is not present you might get the behavior you're describing.

Just to confirm: You are aware that you cannot build entity ghosts (including rails!) on a ghost of landfill, so you have to wait for the landfill to be built and then place the blueprint again to get the entities correct? This is a limitation of vanilla Factorio; BlueprintExtensions does nothing to work around that.

Also, are you using any modded rail entities? They should be supported but that hasn't been extensively tested.

PiggyWhiskey commented 5 years ago

So I'm testing with https://pastebin.com/3aWAjDTC

Pressing Landfill results in https://pastebin.com/rpxKH0MT

Shift Clicking BP (1) results in image The Poles and Signals have been modified by a separate mod to allow placement on Water (Beautiful Bridges)

Shift Clicking (2) results in image

Shift Clicking (3) results in image

Further Shift Clicks don't place the 8 missing diagonal rails and require manual Landfill.

Shadefang commented 5 years ago

Using 0.4.4 I'm getting the same missing landfill issues on (as far as I can tell) unmodded rails, but not getting the issue shown in PiggyWhiskey's first image. Specifically it seems rail signals, and the first diagonal rail after a curved rail don't get landfilled properly.

Examples: https://pastebin.com/3Yyk7Q4H

dewiniaid commented 5 years ago

TL;DR: Fixed in 0.4.5 once it is released.

I tracked down what's happening regarding rails and signals:

Factorio provides some not-entirely-useful information on collision boxes for certain entity prototypes (rails, mostly), though the information on an actual entity in-world is correct. BPEX works around this by creating a dummy surface, placing each entity in each orientation on that surface, noting the bounding box, and ultimately destroying the surface. (This only happens once per map unless your startup settings or mod loadout changes)

However, BPEX was filtering down the list of entities that needs this to too small a set of entities. The original intent was for it to catch straight and curved rails, but it was only catching curved rails. It turns out rail signals are also affected. Since straight rails and signals weren't in the table, the code for actually determining where landfill was required was using the (wrong) information provided by Factorio which resulted in the wrong tiles being landfilled.

In your blueprint, it just happened that this would only affected the diagonal rails immediately after a curve because the wrongly-landfilled bits from that diagonal rail would 'fix' the issue for the next rail down the line and so on. I did my own testing with a circle of rail with straight rails between each quarter, which also masked the issue.

The new logic, available in 0.4.5 when it becomes available, now considers any entity that has 8 directions and cannot be built on water for this calculation (other than a blacklist of entities that shouldn't ever appear in blueprints and cannot be created on-the-fly without more information than just a position and a direction)

As far as the multiple clicks for landfill placement goes (i.e. your first screenshot): BPEX doesn't change anything about how blueprints are actually placed, so I can't say what's going on there and suspect another mod may be contributing to that somehow.