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,17 +88,21 @@
} \ } \
} }
// 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; \
if (length == 0) { \
value = QUuid(); \
} else { \
QByteArray ba((const char*)dataAt, length); \ QByteArray ba((const char*)dataAt, length); \
QUuid value = QUuid::fromRfc4122(ba); \ value = QUuid::fromRfc4122(ba); \
dataAt += length; \ dataAt += length; \
bytesRead += length; \ bytesRead += length; \
} \
if (overwriteLocalData) { \ if (overwriteLocalData) { \
O(value); \ O(value); \
} \ } \
@ -144,17 +148,21 @@
} }
// 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; \
if (length == 0) { \
value = QUuid(); \
} else { \
QByteArray ba((const char*)dataAt, length); \ QByteArray ba((const char*)dataAt, length); \
QUuid value = QUuid::fromRfc4122(ba); \ value = QUuid::fromRfc4122(ba); \
dataAt += length; \ dataAt += length; \
processedBytes += length; \ processedBytes += length; \
} \
properties.O(value); \ properties.O(value); \
} }

View file

@ -412,8 +412,10 @@ 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();
if (uuid.isNull()) {
return appendValue((uint16_t)0); // zero length for null uuid
} else {
uint16_t length = bytes.size(); uint16_t length = bytes.size();
bool success = appendValue(length); bool success = appendValue(length);
if (success) { if (success) {
@ -421,6 +423,7 @@ bool OctreePacketData::appendValue(const QUuid& uuid) {
} }
return success; return success;
} }
}
bool OctreePacketData::appendValue(const QByteArray& bytes) { bool OctreePacketData::appendValue(const QByteArray& bytes) {
bool success = appendRawData((const unsigned char*)bytes.constData(), bytes.size()); bool success = appendRawData((const unsigned char*)bytes.constData(), bytes.size());