if a uuid is null, don't send a uuid of all zeros

This commit is contained in:
Seth Alves 2015-04-17 09:55:49 -07:00
parent f77038c52d
commit c69aaa806b
2 changed files with 43 additions and 32 deletions

View file

@ -88,20 +88,24 @@
} \ } \
} }
// TODO: this doesn't need a length. See OctreePacketData::appendValue(const QUuid& uuid) #define READ_ENTITY_PROPERTY_UUID(P,O) \
#define READ_ENTITY_PROPERTY_UUID(P,O) \ if (propertyFlags.getHasProperty(P)) { \
if (propertyFlags.getHasProperty(P)) { \ uint16_t length; \
uint16_t length; \ memcpy(&length, dataAt, sizeof(length)); \
memcpy(&length, dataAt, sizeof(length)); \ dataAt += sizeof(length); \
dataAt += sizeof(length); \ bytesRead += sizeof(length); \
bytesRead += sizeof(length); \ QUuid value; \
QByteArray ba((const char*)dataAt, length); \ if (length == 0) { \
QUuid value = QUuid::fromRfc4122(ba); \ value = QUuid(); \
dataAt += length; \ } else { \
bytesRead += length; \ QByteArray ba((const char*)dataAt, length); \
if (overwriteLocalData) { \ value = QUuid::fromRfc4122(ba); \
O(value); \ dataAt += length; \
} \ bytesRead += length; \
} \
if (overwriteLocalData) { \
O(value); \
} \
} }
#define READ_ENTITY_PROPERTY_COLOR(P,M) \ #define READ_ENTITY_PROPERTY_COLOR(P,M) \
@ -144,18 +148,22 @@
} }
// TODO: this doesn't need a length. See OctreePacketData::appendValue(const QUuid& uuid) #define READ_ENTITY_PROPERTY_UUID_TO_PROPERTIES(P,O) \
#define READ_ENTITY_PROPERTY_UUID_TO_PROPERTIES(P,O) \ if (propertyFlags.getHasProperty(P)) { \
if (propertyFlags.getHasProperty(P)) { \ uint16_t length; \
uint16_t length; \ memcpy(&length, dataAt, sizeof(length)); \
memcpy(&length, dataAt, sizeof(length)); \ dataAt += sizeof(length); \
dataAt += sizeof(length); \ processedBytes += sizeof(length); \
processedBytes += sizeof(length); \ QUuid value; \
QByteArray ba((const char*)dataAt, length); \ if (length == 0) { \
QUuid value = QUuid::fromRfc4122(ba); \ value = QUuid(); \
dataAt += length; \ } else { \
processedBytes += length; \ QByteArray ba((const char*)dataAt, length); \
properties.O(value); \ value = QUuid::fromRfc4122(ba); \
dataAt += length; \
processedBytes += length; \
} \
properties.O(value); \
} }
#define READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(P,O) \ #define READ_ENTITY_PROPERTY_COLOR_TO_PROPERTIES(P,O) \

View file

@ -412,14 +412,17 @@ bool OctreePacketData::appendValue(const QString& string) {
} }
bool OctreePacketData::appendValue(const QUuid& uuid) { bool OctreePacketData::appendValue(const QUuid& uuid) {
// TODO: this doesn't need a length
QByteArray bytes = uuid.toRfc4122(); QByteArray bytes = uuid.toRfc4122();
uint16_t length = bytes.size(); if (uuid.isNull()) {
bool success = appendValue(length); return appendValue((uint16_t)0); // zero length for null uuid
if (success) { } else {
success = appendRawData((const unsigned char*)bytes.constData(), bytes.size()); uint16_t length = bytes.size();
bool success = appendValue(length);
if (success) {
success = appendRawData((const unsigned char*)bytes.constData(), bytes.size());
}
return success;
} }
return success;
} }
bool OctreePacketData::appendValue(const QByteArray& bytes) { bool OctreePacketData::appendValue(const QByteArray& bytes) {