Implementation of indefinite-length bit vectors.
This implemention requires malloc(), such as this.
Bit vectors can allow a compact representation of multiple binary/flag values.
This bit vector implementation uses an array of words (int), with 31 bits packed per word. The largest word size Q3VM can handle is 32 bits. Only 31 bits were used per word to avoid overflow problems.
One of the first uses in FI was allowing for infinite-pierce rail slugs. The original piercing implementation allows up to 3, and uses an array of 3 integers, each element holding the entity number of entities pierced (3 elements * 4 bytes per element = 12 bytes). Straightforward infinite-pierce extension would mean 1024 elements, each holding a value from 0 to 1024 (1024 elements * 4 bytes per element = 4096 bytes). Since the only state information needed is "pierced or not", a 1024-bit bit vector reduces this to 34 bytes (1024 elements * 1/31 bytes per element = 33.03 bytes).
***blah***
Maximum vector length is about 2_000_000_000 (2**31 - 1), or the maximum size that malloc can support, whichever is less.
***blah***
Drop-in files:
bg_bvec.h,
bg_bvec.c