[kovarex] [1.1.37] Blueprint book in library does not update active_index when removing BPs

Post Reply
robot256
Filter Inserter
Filter Inserter
Posts: 596
Joined: Sun Mar 17, 2019 1:52 am
Contact:

[kovarex] [1.1.37] Blueprint book in library does not update active_index when removing BPs

Post by robot256 »

This bug was reported to me by a user of my "Space Exploration Blueprint Fix" mod. It is related to 88427.

When a blueprint book is stored in inventory and the active blueprint is deleted or picked up by the player, LuaItemStack::active_index (and the green highlighting square) is immediately moved to the next populated slot in the item_inventory.

However, when a blueprint book is stored in the blueprint library, this update does not happen. Instead, active_index remains stale until the player picks up the book and manually shift-scrolls. Until then, active_index can return a the index of an empty slot or even outside the current size of the item_inventory. This is in spite of the fact that you can still pick up the blueprint book and place a blueprint, without shift-scrolling to properly select it.

For example, the following sequence of actions can reproduce the stale active_index condition:
  1. Create a new empty blueprint book. Place it in the My Blueprints library. when picked up, item_inventory size is 0. active_index returns nil.
  2. Create a new blueprint and place it in slot 3 of the empty book. when picked up, item_inventory size is 3, slots 1 and 2 are empty. active_index returns 1. This can be confirmed by the absence of a green square around the blueprint. Blueprint inventory[1] returns nil but does not cause an error.
  3. Pick up the blueprint book and shift-scroll. active_index is set to 3 and the green square appears around the blueprint.
  4. Open the blueprint book and move the blueprint from slot 3 to slot 2. inventory size changes to 2, slot 1 is empty. active_index still returns 3, which will cause an out-of-bounds error. Green box disappears.
  5. Pick up the blueprint book and see that you can still place the blueprint, even though the green square is not shown.
  6. Pick up the blueprint book and shift-scroll again. active_index is set to 2 and the green square reappears around the blueprint.
Hopefully this is a simple oversight and fix. I understand the BP library is not fully mod-supported, so this may be a won't fix issue. But it confused me enough that it would be nice to mention in the documentation if active_index is allowed to be outside the bounds of item_inventory.

Post Reply

Return to “Assigned”