Brighter Shores

Brighter Shores

How to represent stackable items without exploding the registry or player save
Computers address 64 bits at a time, so with that in mind we can represent the entire inventory within one address value. With each inventory slot getting 2 bits (and 8 bonus slots left over) you only need to load one value to the (program) stack to see the entire inventory of stack sizes.

Representation will go as follows
00 = Default behavior: How it is now
01 = Item stacks to two
10 = Item stacks to three
11 = Item stacks to four

Because a vast majority of items will be represented as 00 it will leave almost no impact on the player save since long runs of zeros can be very easily compressed, however it will allow any item regardless of status to stack up to 4 while leaving the existing stacking systems completely untouched. Want to a bigger max stack? Use more addresses rather than one, now items can stack up to 16, or higher.

This representation is efficient, scales, and has almost no overhead as it is only called when needed and will be optimized away when it is not, and would allow any item in the game to be able to stack up to arbitrary amounts. One only needs to make a "stackable" interface to automatically handle any item one could possibly want to make stackable, making it extremely easy for developers to add a new stacking item.

EDIT: If you use 3 addresses for 24 inventory slots, you can give each slot 8 bits without any waste, which would allow items to stack up to 256. This isn't particularly useful but it is interesting enough to bring up.
Last edited by Omega Haxors; May 6 @ 9:24am
< >
Showing 1-1 of 1 comments
>when you're 2 days into a computer science course and you think you sound intelligent
< >
Showing 1-1 of 1 comments
Per page: 1530 50