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) \
if (propertyFlags.getHasProperty(P)) { \
uint16_t length; \
memcpy(&length, dataAt, sizeof(length)); \
dataAt += sizeof(length); \
bytesRead += sizeof(length); \
QByteArray ba((const char*)dataAt, length); \
QUuid value = QUuid::fromRfc4122(ba); \
dataAt += length; \
bytesRead += length; \
if (overwriteLocalData) { \
O(value); \
} \
#define READ_ENTITY_PROPERTY_UUID(P,O) \
if (propertyFlags.getHasProperty(P)) { \
uint16_t length; \
memcpy(&length, dataAt, sizeof(length)); \
dataAt += sizeof(length); \
bytesRead += sizeof(length); \
QUuid value; \
if (length == 0) { \
value = QUuid(); \
} else { \
QByteArray ba((const char*)dataAt, length); \
value = QUuid::fromRfc4122(ba); \
dataAt += length; \
bytesRead += length; \
} \
if (overwriteLocalData) { \
O(value); \
} \
}
#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) \
if (propertyFlags.getHasProperty(P)) { \
uint16_t length; \
memcpy(&length, dataAt, sizeof(length)); \
dataAt += sizeof(length); \
processedBytes += sizeof(length); \
QByteArray ba((const char*)dataAt, length); \
QUuid value = QUuid::fromRfc4122(ba); \
dataAt += length; \
processedBytes += length; \
properties.O(value); \
#define READ_ENTITY_PROPERTY_UUID_TO_PROPERTIES(P,O) \
if (propertyFlags.getHasProperty(P)) { \
uint16_t length; \
memcpy(&length, dataAt, sizeof(length)); \
dataAt += sizeof(length); \
processedBytes += sizeof(length); \
QUuid value; \
if (length == 0) { \
value = QUuid(); \
} else { \
QByteArray ba((const char*)dataAt, length); \
value = QUuid::fromRfc4122(ba); \
dataAt += length; \
processedBytes += length; \
} \
properties.O(value); \
}
#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) {
// TODO: this doesn't need a length
QByteArray bytes = uuid.toRfc4122();
uint16_t length = bytes.size();
bool success = appendValue(length);
if (success) {
success = appendRawData((const unsigned char*)bytes.constData(), bytes.size());
if (uuid.isNull()) {
return appendValue((uint16_t)0); // zero length for null uuid
} else {
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) {