mirror of
https://github.com/overte-org/overte.git
synced 2025-04-23 18:13:29 +02:00
cleanup for coding standard
This commit is contained in:
parent
94584d4ead
commit
25511f99ec
6 changed files with 30 additions and 26 deletions
|
@ -599,8 +599,10 @@ int VoxelSystem::parseData(unsigned char* sourceBuffer, int numBytes) {
|
|||
lockTree();
|
||||
VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT);
|
||||
int compressedSize = numBytes - numBytesPacketHeader;
|
||||
packet.loadCompressedContent(voxelData, compressedSize);
|
||||
printf("got packet numBytes=%d compressed size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize());
|
||||
packet.loadFinalizedContent(voxelData, compressedSize);
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
|
||||
qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize());
|
||||
}
|
||||
_tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args);
|
||||
unlockTree();
|
||||
}
|
||||
|
@ -613,8 +615,10 @@ printf("got packet numBytes=%d compressed size %d uncompressed size %d\n",numByt
|
|||
lockTree();
|
||||
VoxelPacket packet(VOXEL_PACKET_COMPRESSION_DEFAULT);
|
||||
int compressedSize = numBytes - numBytesPacketHeader;
|
||||
packet.loadCompressedContent(voxelData, compressedSize);
|
||||
printf("got packet numBytes=%d compressed size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize());
|
||||
packet.loadFinalizedContent(voxelData, compressedSize);
|
||||
if (Menu::getInstance()->isOptionChecked(MenuOption::ExtraDebugging)) {
|
||||
qDebug("got packet numBytes=%d finalized size %d uncompressed size %d\n",numBytes, compressedSize, packet.getUncompressedSize());
|
||||
}
|
||||
_tree->readBitstreamToTree(packet.getUncompressedData(), packet.getUncompressedSize(), args);
|
||||
unlockTree();
|
||||
}
|
||||
|
|
|
@ -32,12 +32,12 @@ int numberOfThreeBitSectionsInCode(const unsigned char* octalCode, int maxBytes)
|
|||
|
||||
void printOctalCode(const unsigned char* octalCode) {
|
||||
if (!octalCode) {
|
||||
printf("NULL\n");
|
||||
qDebug("NULL\n");
|
||||
} else {
|
||||
for (int i = 0; i < bytesRequiredForCodeLength(numberOfThreeBitSectionsInCode(octalCode)); i++) {
|
||||
outputBits(octalCode[i],false);
|
||||
}
|
||||
printf("\n");
|
||||
qDebug("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -71,18 +71,18 @@ void outputBufferBits(const unsigned char* buffer, int length, bool withNewLine)
|
|||
|
||||
void outputBits(unsigned char byte, bool withNewLine) {
|
||||
if (isalnum(byte)) {
|
||||
printf("[ %d (%c): ", byte, byte);
|
||||
qDebug("[ %d (%c): ", byte, byte);
|
||||
} else {
|
||||
printf("[ %d (0x%x): ", byte, byte);
|
||||
qDebug("[ %d (0x%x): ", byte, byte);
|
||||
}
|
||||
|
||||
for (int i = 0; i < 8; i++) {
|
||||
printf("%d", byte >> (7 - i) & 1);
|
||||
qDebug("%d", byte >> (7 - i) & 1);
|
||||
}
|
||||
printf(" ] ");
|
||||
qDebug(" ] ");
|
||||
|
||||
if (withNewLine) {
|
||||
printf("\n");
|
||||
qDebug("\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -374,15 +374,7 @@ int VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nod
|
|||
|
||||
_myServer->getServerTree().lockForRead();
|
||||
nodeData->stats.encodeStarted();
|
||||
|
||||
//printf("calling nodeBag.count()=%d encode()... subTree=%p \n", nodeData->nodeBag.count(), subTree);
|
||||
//printOctalCode(subTree->getOctalCode());
|
||||
|
||||
bytesWritten = _myServer->getServerTree().encodeTreeBitstream(subTree, &_tempPacket, nodeData->nodeBag, params);
|
||||
|
||||
|
||||
//printf("called encode()... bytesWritten=%d compressedSize=%d uncompressedSize=%d\n",bytesWritten, _tempPacket.getFinalizedSize(), _tempPacket.getUncompressedSize());
|
||||
|
||||
if (bytesWritten > 0) {
|
||||
_encodedSomething = true;
|
||||
}
|
||||
|
@ -399,7 +391,10 @@ int VoxelSendThread::deepestLevelVoxelDistributor(Node* node, VoxelNodeData* nod
|
|||
// mean we should send the previous packet contents and reset it.
|
||||
bool sendNow = (bytesWritten == 0);
|
||||
if (_tempPacket.hasContent() && sendNow) {
|
||||
//printf("calling writeToPacket() compressedSize=%d uncompressedSize=%d\n",_tempPacket.getFinalizedSize(), _tempPacket.getUncompressedSize());
|
||||
if (_myServer->wantsDebugVoxelSending() && _myServer->wantsVerboseDebug()) {
|
||||
printf("calling writeToPacket() compressedSize=%d uncompressedSize=%d\n",
|
||||
_tempPacket.getFinalizedSize(), _tempPacket.getUncompressedSize());
|
||||
}
|
||||
nodeData->writeToPacket(_tempPacket.getFinalizedData(), _tempPacket.getFinalizedSize());
|
||||
packetsSentThisInterval += handlePacketSend(node, nodeData, trueBytesSent, truePacketsSent);
|
||||
_tempPacket.reset();
|
||||
|
|
|
@ -147,15 +147,19 @@ int VoxelPacket::startLevel() {
|
|||
void VoxelPacket::discardLevel(int key) {
|
||||
int bytesInLevel = _bytesInUse - key;
|
||||
|
||||
if (_debug) printf("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
|
||||
if (_debug) {
|
||||
printf("discardLevel() BEFORE _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
|
||||
debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse);
|
||||
}
|
||||
|
||||
_bytesInUse -= bytesInLevel;
|
||||
_bytesAvailable += bytesInLevel;
|
||||
_dirty = true;
|
||||
|
||||
if (_debug) printf("discardLevel() AFTER _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
|
||||
if (_debug) {
|
||||
printf("discardLevel() AFTER _dirty=%s bytesInLevel=%d _compressedBytes=%d _bytesInUse=%d\n",
|
||||
debug::valueOf(_dirty), bytesInLevel, _compressedBytes, _bytesInUse);
|
||||
}
|
||||
}
|
||||
|
||||
bool VoxelPacket::endLevel(int key) {
|
||||
|
@ -235,7 +239,7 @@ bool VoxelPacket::checkCompress() {
|
|||
}
|
||||
|
||||
|
||||
void VoxelPacket::loadCompressedContent(const unsigned char* data, int length) {
|
||||
void VoxelPacket::loadFinalizedContent(const unsigned char* data, int length) {
|
||||
reset(); // by definition we reset upon loading compressed content
|
||||
|
||||
if (length > 0) {
|
||||
|
|
|
@ -6,9 +6,10 @@
|
|||
//
|
||||
// TO DO:
|
||||
//
|
||||
// * improve compression to be less expensive (mostly determine when to test compression...)
|
||||
// * further testing of compression to determine optimal configuration for performance and compression
|
||||
//
|
||||
// * add stats tracking for number of bytes of octal code, bitmasks, and colors in a packet.
|
||||
//
|
||||
// * improve semantics for "reshuffle" - current approach will work for now and with compression
|
||||
// but wouldn't work with RLE because the colors in the levels would get reordered and RLE would need
|
||||
// to be recalculated
|
||||
|
@ -82,8 +83,8 @@ public:
|
|||
/// has some content been written to the packet
|
||||
bool hasContent() const { return (_bytesInUse > 0); }
|
||||
|
||||
/// load compressed content to allow access to decoded content for parsing
|
||||
void loadCompressedContent(const unsigned char* data, int length);
|
||||
/// load finalized content to allow access to decoded content for parsing
|
||||
void loadFinalizedContent(const unsigned char* data, int length);
|
||||
|
||||
void debugContent();
|
||||
|
||||
|
|
Loading…
Reference in a new issue