[2.1.11] building_grid_bit_shift returns garbage

Place to report issues and suggest improvements to the API documentation.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 663
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

[2.1.11] building_grid_bit_shift returns garbage

Post by Gergely »

LuaEntityPrototype::building_grid_bit_shift does not behave as documented.
The log2 of grid size of the building.
My interpretation of this: building_grid_bit_shift == log2(build_grid_size).
Expected:
  • build_grid_size == 1 => building_grid_bit_shift == 0
  • build_grid_size == 2 => building_grid_bit_shift == 1
  • build_grid_size == 256 => building_grid_bit_shift == 8
Actual:
The observed return value is equal to build_grid_size itself.
Rseding91
Factorio Staff
Factorio Staff
Posts: 17202
Joined: Wed Jun 11, 2014 5:23 am
Contact:

Re: [2.1.11] building_grid_bit_shift returns garbage

Post by Rseding91 »

I’ll need to do some git blame but from looking a that code it seems the doc comment is just wrong these days.

Git blame will tell if it was ever correct.
If you want to get ahold of me I'm almost always on Discord.
User avatar
Gergely
Filter Inserter
Filter Inserter
Posts: 663
Joined: Sun Apr 10, 2016 8:31 pm
Contact:

Re: [2.1.11] building_grid_bit_shift returns garbage

Post by Gergely »

Rseding91 wrote: Thu Jul 16, 2026 10:05 am I’ll need to do some git blame but from looking a that code it seems the doc comment is just wrong these days.
The name would also be wrong then. If it returns the exact same thing as build_grid_size, why is it not called build_grid_size? (Which is otherwise not readable off of prototypes in control stage.)
Post Reply

Return to “Documentation Improvement Requests”