History

fix voxel packet corruption

ZappoMan committed 12 years ago

Commit b0c41b01 parent 29af3d76 files · +28 −39Browse files

Showing the changes to interface/src/VoxelSystem.cpp (1 of 6 files). Show all

Unified · Split

interface/src/VoxelSystem.cpp+13−13
@@ -561,30 +561,30 @@ int VoxelSystem::parseData(const QByteArray& packet) { · 560 unmodified lines
561561
562562 const unsigned char* dataAt = reinterpret_cast<const unsigned char*>(packet.data()) + numBytesPacketHeader;
563563
564− VOXEL_PACKET_FLAGS flags = (*(VOXEL_PACKET_FLAGS*)(dataAt));
565− dataAt += sizeof(VOXEL_PACKET_FLAGS);
566− VOXEL_PACKET_SEQUENCE sequence = (*(VOXEL_PACKET_SEQUENCE*)dataAt);
567− dataAt += sizeof(VOXEL_PACKET_SEQUENCE);
564+ OCTREE_PACKET_FLAGS flags = (*(OCTREE_PACKET_FLAGS*)(dataAt));
565+ dataAt += sizeof(OCTREE_PACKET_FLAGS);
566+ OCTREE_PACKET_SEQUENCE sequence = (*(OCTREE_PACKET_SEQUENCE*)dataAt);
567+ dataAt += sizeof(OCTREE_PACKET_SEQUENCE);
568568
569− VOXEL_PACKET_SENT_TIME sentAt = (*(VOXEL_PACKET_SENT_TIME*)dataAt);
570− dataAt += sizeof(VOXEL_PACKET_SENT_TIME);
569+ OCTREE_PACKET_SENT_TIME sentAt = (*(OCTREE_PACKET_SENT_TIME*)dataAt);
570+ dataAt += sizeof(OCTREE_PACKET_SENT_TIME);
571571
572572 bool packetIsColored = oneAtBit(flags, PACKET_IS_COLOR_BIT);
573573 bool packetIsCompressed = oneAtBit(flags, PACKET_IS_COMPRESSED_BIT);
574574
575− VOXEL_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
575+ OCTREE_PACKET_SENT_TIME arrivedAt = usecTimestampNow();
576576 int flightTime = arrivedAt - sentAt;
577577
578− VOXEL_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
579− int dataBytes = packet.size() - VOXEL_PACKET_HEADER_SIZE;
578+ OCTREE_PACKET_INTERNAL_SECTION_SIZE sectionLength = 0;
579+ int dataBytes = packet.size() - (numBytesPacketHeader + OCTREE_PACKET_EXTRA_HEADERS_SIZE);
580580
581581 int subsection = 1;
582582 while (dataBytes > 0) {
583583 if (packetIsCompressed) {
584− if (dataBytes > sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE)) {
585− sectionLength = (*(VOXEL_PACKET_INTERNAL_SECTION_SIZE*)dataAt);
586− dataAt += sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE);
587− dataBytes -= sizeof(VOXEL_PACKET_INTERNAL_SECTION_SIZE);
584+ if (dataBytes > sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE)) {
585+ sectionLength = (*(OCTREE_PACKET_INTERNAL_SECTION_SIZE*)dataAt);
586+ dataAt += sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE);
587+ dataBytes -= sizeof(OCTREE_PACKET_INTERNAL_SECTION_SIZE);
588588 } else {
589589 sectionLength = 0;
590590 dataBytes = 0; // stop looping something is wrong