cleaned up const semantics and DRYed up appendBitMask

This commit is contained in:
ZappoMan 2013-11-23 16:28:21 -08:00
parent 0f66f4c1bd
commit cd1d3765a9
6 changed files with 6 additions and 13 deletions

View file

@ -60,7 +60,7 @@ bool shouldDo(float desiredInterval, float deltaTime) {
return randFloat() < deltaTime / desiredInterval;
}
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine) {
void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine) {
for (int i = 0; i < length; i++) {
outputBits(buffer[i], false);
}

View file

@ -52,7 +52,7 @@ bool randomBoolean();
bool shouldDo(float desiredInterval, float deltaTime);
void outputBufferBits(unsigned char* buffer, int length, bool withNewLine = true);
void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine = true);
void outputBits(unsigned char byte, bool withNewLine = true);
void printVoxelCode(unsigned char* voxelCode);
int numberOfOnes(unsigned char byte);

View file

@ -105,7 +105,7 @@ void VoxelNodeData::resetVoxelPacket() {
_voxelPacketWaiting = false;
}
void VoxelNodeData::writeToPacket(unsigned char* buffer, int bytes) {
void VoxelNodeData::writeToPacket(const unsigned char* buffer, int bytes) {
memcpy(_voxelPacketAt, buffer, bytes);
_voxelPacketAvailableBytes -= bytes;
_voxelPacketAt += bytes;

View file

@ -28,7 +28,7 @@ public:
void resetVoxelPacket(); // resets voxel packet to after "V" header
void writeToPacket(unsigned char* buffer, int bytes); // writes to end of packet
void writeToPacket(const unsigned char* buffer, int bytes); // writes to end of packet
const unsigned char* getPacket() const { return _voxelPacket; }
int getPacketLength() const { return (MAX_VOXEL_PACKET_SIZE - _voxelPacketAvailableBytes); }

View file

@ -106,14 +106,7 @@ void VoxelPacket::endLevel() {
}
bool VoxelPacket::appendBitMask(unsigned char bitmask) {
bool success = false;
if (_bytesAvailable > 0) {
_buffer[_bytesInUse] = bitmask;
_bytesInUse++;
_bytesAvailable--;
success = true;
}
return success;
return append(bitmask);
}
bool VoxelPacket::appendColor(const nodeColor& color) {

View file

@ -66,7 +66,7 @@ public:
int getUncompressedByteOffset(int offsetFromEnd = 0) const { return _bytesInUse - offsetFromEnd; }
/// get access to the finalized data (it may be compressed or rewritten into optimal form)
unsigned char* getFinalizedData() { return &_buffer[0]; }
const unsigned char* getFinalizedData() { return &_buffer[0]; }
/// get size of the finalized data (it may be compressed or rewritten into optimal form)
int getFinalizedSize() const { return _bytesInUse; }