Page 1 of 1

[2.1.11] building_grid_bit_shift returns garbage

Posted: Thu Jul 16, 2026 8:50 am
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.

Re: [2.1.11] building_grid_bit_shift returns garbage

Posted: Thu Jul 16, 2026 10:05 am
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.

Re: [2.1.11] building_grid_bit_shift returns garbage

Posted: Thu Jul 16, 2026 11:20 am
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.)