[boskid][2.0.23] Entity prototypes are missing "layers" information, leading to collision_mask_util.masks_collide crash

Bugs which we just recently fixed in our development version and will reach you in the next release.
User avatar
hgschmie
Inserter
Inserter
Posts: 48
Joined: Tue Feb 06, 2024 5:18 am
Contact:

[boskid][2.0.23] Entity prototypes are missing "layers" information, leading to collision_mask_util.masks_collide crash

Post by hgschmie »

I have a prototype definition for an entity that contains a collision mask. The collision mask has an empty "layers" definition:
Screenshot 2024-11-29 at 17.00.07.png
Screenshot 2024-11-29 at 17.00.07.png (184.37 KiB) Viewed 170 times
Note that the prototype does define layers as empty (it can not be omitted; more about that in a second).

Now when I create an entity using LuaSurface::create_entity, this is what I receive:
Screenshot 2024-11-29 at 17.08.18.png
Screenshot 2024-11-29 at 17.08.18.png (316.97 KiB) Viewed 170 times


The prototype for this entity does NOT contain the layer information. I want to use collision_mask_util.masks_collide from the lualib to check whether any of these entities collides with others and that crashes my mod because the function assumes that any collision mask *does* contain a "layers" attribute.

Either any entity created by the game should contain the layers attribute even if it is empty (do not omit when there is no layer defined) *OR* the lualib needs to be tolerant of the layers attribute missing. The current state seems to be a bug.
User avatar
boskid
Factorio Staff
Factorio Staff
Posts: 3092
Joined: Thu Dec 14, 2017 6:56 pm
Contact:

Re: [boskid][2.0.23] Entity prototypes are missing "layers" information, leading to collision_mask_util.masks_collide cr

Post by boskid »

Thanks for the report. Issue is now fixed for 2.0.24. My intention was to have "layers" be mandatory in all cases using the "make modders happy by reducing amount of formats data can be given" and this code was also structured in a way that was supposed to guarantee layers is given, however there is an intermediate step here when giving collision mask: it is first saved as one of the internal types, a PropertyTree where a "layers" was constructed however because it was not given any items it was considered as "unknown type" and as such it was not causing table to be pushed. I forced the type of this inner variable to explicitly say it is a table even if there are no items inside of it which fixes the issue.
Post Reply

Return to “Resolved for the next release”