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) { if (debugProcessPacket) {
qDebug() << " numBytesPacketHeader=" << packet->localHeaderSize(); qDebug() << " numBytesPacketHeader=" << packet->totalHeadersSize();
qDebug() << " sizeof(sequence)=" << sizeof(sequence); qDebug() << " sizeof(sequence)=" << sizeof(sequence);
qDebug() << " sizeof(sentAt)=" << sizeof(sentAt); qDebug() << " sizeof(sentAt)=" << sizeof(sentAt);
} }

View file

@ -900,14 +900,11 @@ bool EntityItemProperties::encodeEntityEditPacket(PacketType::Value command, Ent
// //
// TODO: Implement support for script and visible properties. // 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) { EntityItemID& entityID, EntityItemProperties& properties) {
bool valid = false; bool valid = false;
const unsigned char* data = reinterpret_cast<const unsigned char*>(packet.getPayload());
const unsigned char* dataAt = data; const unsigned char* dataAt = data;
int bytesToRead = packet.getPayloadSize();
processedBytes = 0; 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 // 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 // 2) if the edit is to a new entity, the created time is the last edited time
// encoded id // encoded id
QByteArray encodedID((const char*)dataAt, NUM_BYTES_RFC4122_UUID); // maximum possible size QUuid editID = QUuid::fromRfc4122(QByteArray::fromRawData(reinterpret_cast<const char*>(dataAt), NUM_BYTES_RFC4122_UUID));
QUuid editID = QUuid::fromRfc4122(encodedID); dataAt += NUM_BYTES_RFC4122_UUID;
dataAt += encodedID.size(); processedBytes += NUM_BYTES_RFC4122_UUID;
processedBytes += encodedID.size();
entityID = editID; entityID = editID;
valid = true; valid = true;

View file

@ -179,7 +179,7 @@ public:
static bool encodeEraseEntityMessage(const EntityItemID& entityItemID, QByteArray& buffer); 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); EntityItemID& entityID, EntityItemProperties& properties);
bool glowLevelChanged() const { return _glowLevelChanged; } bool glowLevelChanged() const { return _glowLevelChanged; }

View file

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

View file

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