mirror of
https://github.com/overte-org/overte.git
synced 2025-04-22 17:13:31 +02:00
fix entity packet send from interface client
This commit is contained in:
parent
61f23f6a5e
commit
8921f59e23
5 changed files with 10 additions and 13 deletions
assignment-client/src/octree
libraries
entities/src
octree/src
|
@ -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());
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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; }
|
||||
|
|
|
@ -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();
|
||||
|
||||
|
|
|
@ -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) ||
|
||||
|
|
Loading…
Reference in a new issue