2013-10-04 07:04:42 -06:00
|
|
|
static const int SIZE = 16;
|
|
|
|
|
2012-04-19 01:03:29 -06:00
|
|
|
inline uint16_t &operator[] (int y)
|
|
|
|
{
|
|
|
|
return bits[y];
|
|
|
|
}
|
|
|
|
void clear()
|
|
|
|
{
|
|
|
|
memset(bits,0,sizeof(bits));
|
|
|
|
}
|
|
|
|
void set_all()
|
|
|
|
{
|
|
|
|
memset(bits,0xFF,sizeof(bits));
|
|
|
|
}
|
|
|
|
inline bool getassignment( const df::coord2d &xy )
|
|
|
|
{
|
|
|
|
return getassignment(xy.x,xy.y);
|
|
|
|
}
|
|
|
|
inline bool getassignment( int x, int y )
|
|
|
|
{
|
2012-10-11 07:34:34 -06:00
|
|
|
return (bits[(y&15)] & (1 << (x&15)));
|
2012-04-19 01:03:29 -06:00
|
|
|
}
|
|
|
|
inline void setassignment( const df::coord2d &xy, bool bit )
|
|
|
|
{
|
|
|
|
return setassignment(xy.x,xy.y, bit);
|
|
|
|
}
|
|
|
|
inline void setassignment( int x, int y, bool bit )
|
|
|
|
{
|
|
|
|
if(bit)
|
2012-10-11 07:34:34 -06:00
|
|
|
bits[(y&15)] |= (1 << (x&15));
|
2012-04-19 01:03:29 -06:00
|
|
|
else
|
2012-10-11 07:34:34 -06:00
|
|
|
bits[(y&15)] &= ~(1 << (x&15));
|
2012-04-19 01:03:29 -06:00
|
|
|
}
|
|
|
|
bool has_assignments()
|
|
|
|
{
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
if (bits[i])
|
|
|
|
return true;
|
|
|
|
return false;
|
|
|
|
}
|
2013-10-04 07:04:42 -06:00
|
|
|
df::tile_bitmask &operator |= (const df::tile_bitmask &b) {
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
bits[i] |= b.bits[i];
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
df::tile_bitmask &operator &= (const df::tile_bitmask &b) {
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
bits[i] &= b.bits[i];
|
|
|
|
return *this;
|
|
|
|
}
|
|
|
|
df::tile_bitmask &operator -= (const df::tile_bitmask &b) {
|
|
|
|
for (int i = 0; i < 16; i++)
|
|
|
|
bits[i] &= ~b.bits[i];
|
|
|
|
return *this;
|
|
|
|
}
|