LuaSurface::entity_prototype_collides incorrect with curved rails

Things that we don't consider worth fixing at this moment.
Post Reply
User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Sat Mar 05, 2022 11:30 am
Contact:

LuaSurface::entity_prototype_collides incorrect with curved rails

Post by _CodeGreen »

I'm assuming this is because of the secondary collision box that curved rails have, but when the curved part collides with something and the straight part does not, the method returns the incorrect result.
I don't expect this to be fixed for 1.1.x, but I at least wanted to make sure this was made aware of in case it is relevant for 2.0.

To reproduce, place a curved rail ghost like this:
curved-rail-ghost.png
curved-rail-ghost.png (356.51 KiB) Viewed 436 times

Then, run the following command while selecting the curved rail with your mouse cursor:

Code: Select all

/c local entity = game.player.selected
game.print(game.player.surface.entity_prototype_collides(entity.ghost_prototype, entity.position, false, entity.direction))
-- false
There is a workaround for this specific scenario, which is the LuaSurface::can_place_entity method instead, however I have been told that the underlying c++ function is used for autoplace, so if anyone ever tries to give curved rails an autoplace then this would be a real issue.

Code: Select all

/c local entity = game.player.selected
game.print(not game.player.surface.can_place_entity{name = entity.ghost_name, position = entity.position, direction = entity.direction})
-- true
My Mods | If you can't make it perfect, make it adjustable

Rseding91
Factorio Staff
Factorio Staff
Posts: 13209
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: LuaSurface::entity_prototype_collides incorrect with curved rails

Post by Rseding91 »

Thanks for the report. We're specifically doing away with the secondary-bounding-box logic in 2.0 at some point so this will resolve itself. The new rails in 2.0 do not use the logic and once we have allowed a sufficient amount of time for saves to be migrated to 2.0 we will be removing the feature entirely in a then-future update.
If you want to get ahold of me I'm almost always on Discord.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaSurface::entity_prototype_collides incorrect with curved rails

Post by boskid »

This is not relevant for 2.0 since we are trying to get rid of secondary collision box logic, however this function seems to be far more broken when considering rails given that rails have custom set of collision box orientations for each direction and this specific check directly takes bounding box from prototype and rotates it to the provided direction.

User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 2250
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: LuaSurface::entity_prototype_collides incorrect with curved rails

Post by boskid »

I am considering this to be a wont fix. Those checks are primarily for being compatible with map generator and we never assumed rails would be placable by map generator.

User avatar
_CodeGreen
Long Handed Inserter
Long Handed Inserter
Posts: 61
Joined: Sat Mar 05, 2022 11:30 am
Contact:

Re: LuaSurface::entity_prototype_collides incorrect with curved rails

Post by _CodeGreen »

As I suspected, just wanted to put it here for public record.
For clarification, would the custom collision box orientations still be an issue in 2.0 with rails having hard coded collision boxes, or is that part irrelevant as well due to the new rails?
My Mods | If you can't make it perfect, make it adjustable

Post Reply

Return to “Won't fix.”