|
|
@ -50,6 +50,18 @@ namespace DFHack
|
|
|
|
if(bits)
|
|
|
|
if(bits)
|
|
|
|
memset(bits, 0, size);
|
|
|
|
memset(bits, 0, size);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
void extend (T index)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
uint32_t newsize = (index / 8) + 1;
|
|
|
|
|
|
|
|
if (newsize <= size)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
uint8_t *newbits = new uint8_t[newsize];
|
|
|
|
|
|
|
|
memset(newbits, 0, newsize);
|
|
|
|
|
|
|
|
memcpy(newbits, bits, size);
|
|
|
|
|
|
|
|
delete[] bits;
|
|
|
|
|
|
|
|
bits = newbits;
|
|
|
|
|
|
|
|
size = newsize;
|
|
|
|
|
|
|
|
}
|
|
|
|
void set (T index, bool value = true)
|
|
|
|
void set (T index, bool value = true)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
if(!value)
|
|
|
|
if(!value)
|
|
|
@ -58,7 +70,8 @@ namespace DFHack
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
uint32_t byte = index / 8;
|
|
|
|
uint32_t byte = index / 8;
|
|
|
|
if(byte < size)
|
|
|
|
extend(index);
|
|
|
|
|
|
|
|
//if(byte < size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t bit = 1 << (index % 8);
|
|
|
|
uint8_t bit = 1 << (index % 8);
|
|
|
|
bits[byte] |= bit;
|
|
|
|
bits[byte] |= bit;
|
|
|
@ -76,7 +89,8 @@ namespace DFHack
|
|
|
|
void toggle (T index)
|
|
|
|
void toggle (T index)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint32_t byte = index / 8;
|
|
|
|
uint32_t byte = index / 8;
|
|
|
|
if(byte < size)
|
|
|
|
extend(index);
|
|
|
|
|
|
|
|
//if(byte < size)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
uint8_t bit = 1 << (index % 8);
|
|
|
|
uint8_t bit = 1 << (index % 8);
|
|
|
|
bits[byte] ^= bit;
|
|
|
|
bits[byte] ^= bit;
|
|
|
|