fix entity packet send from interface client

This commit is contained in:
Stephen Birarda 2015-07-16 12:09:35 -07:00
parent 61f23f6a5e
commit 8921f59e23
5 changed files with 10 additions and 13 deletions

View file

@ -128,7 +128,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
}
if (debugProcessPacket) {
qDebug() << " numBytesPacketHeader=" << packet->localHeaderSize();
qDebug() << " numBytesPacketHeader=" << packet->totalHeadersSize();
qDebug() << " sizeof(sequence)=" << sizeof(sequence);
qDebug() << " sizeof(sentAt)=" << sizeof(sentAt);
}
@ -143,7 +143,7 @@ void OctreeInboundPacketProcessor::processPacket(QSharedPointer<NLPacket> packet
}
const unsigned char* editData = nullptr;
while (packet->bytesLeftToRead() > 0) {
editData = reinterpret_cast<const unsigned char*>(packet->getPayload() + packet->pos());

View file

@ -900,14 +900,11 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType::Value command, Ent
//
// TODO: Implement support for script and visible properties.
//
bool EntityItemProperties::decodeEntityEditPacket(NLPacket& packet, int& processedBytes,
bool EntityItemProperties::decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
EntityItemID& entityID, EntityItemProperties& properties) {
bool valid = false;
const unsigned char* data = reinterpret_cast<const unsigned char*>(packet.getPayload());
const unsigned char* dataAt = data;
int bytesToRead = packet.getPayloadSize();
processedBytes = 0;
// the first part of the data is an octcode, this is a required element of the edit packet format, but we don't
@ -933,10 +930,9 @@ bool EntityItemProperties::decodeEntityEditPacket(NLPacket& packet, int& process
// 2) if the edit is to a new entity, the created time is the last edited time
// encoded id
QByteArray encodedID((const char*)dataAt, NUM_BYTES_RFC4122_UUID); // maximum possible size
QUuid editID = QUuid::fromRfc4122(encodedID);
dataAt += encodedID.size();
processedBytes += encodedID.size();
QUuid editID = QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char*>(dataAt), NUM_BYTES_RFC4122_UUID));
dataAt += NUM_BYTES_RFC4122_UUID;
processedBytes += NUM_BYTES_RFC4122_UUID;
entityID = editID;
valid = true;

View file

@ -179,7 +179,7 @@ public:
static bool encodeEraseEntityMessage(const EntityItemID& entityItemID, QByteArray& buffer);
static bool decodeEntityEditPacket(NLPacket& packet, int& processedBytes,
static bool decodeEntityEditPacket(const unsigned char* data, int bytesToRead, int& processedBytes,
EntityItemID& entityID, EntityItemProperties& properties);
bool glowLevelChanged() const { return _glowLevelChanged; }

View file

@ -598,7 +598,8 @@ int EntityTree::processEditPacketData(NLPacket& packet, const unsigned char* edi
EntityItemID entityItemID;
EntityItemProperties properties;
startDecode = usecTimestampNow();
bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(packet, processedBytes,
bool validEditPacket = EntityItemProperties::decodeEntityEditPacket(editData, maxLength, processedBytes,
entityItemID, properties);
endDecode = usecTimestampNow();

View file

@ -251,7 +251,7 @@ void OctreeEditPacketSender::queueOctreeEditMessage(PacketType::Value type, QByt
std::unique_ptr<NLPacket>& bufferedPacket = _pendingEditPackets[nodeUUID];
if (!bufferedPacket) {
bufferedPacket = std::move(NLPacket::create(type));
bufferedPacket = initializePacket(type, node->getClockSkewUsec());
} else {
// If we're switching type, then we send the last one and start over
if ((type != bufferedPacket->getType() && bufferedPacket->getPayloadSize() > 0) ||