mirror of
https://github.com/overte-org/overte.git
synced 2025-08-07 20:35:04 +02:00
Merge pull request #4586 from ZappoMan/svoImportFixes
BUG FIX - Import entities sometimes fails
This commit is contained in:
commit
cc7cda39f1
2 changed files with 21 additions and 5 deletions
|
@ -662,11 +662,23 @@ int EntityTree::processEditPacketData(PacketType packetType, const unsigned char
|
||||||
if (senderNode->getCanRez()) {
|
if (senderNode->getCanRez()) {
|
||||||
// this is a new entity... assign a new entityID
|
// this is a new entity... assign a new entityID
|
||||||
entityItemID = assignEntityID(entityItemID);
|
entityItemID = assignEntityID(entityItemID);
|
||||||
|
if (wantEditLogging()) {
|
||||||
|
qDebug() << "User [" << senderNode->getUUID() << "] adding entity.";
|
||||||
|
qDebug() << " properties:" << properties;
|
||||||
|
}
|
||||||
EntityItem* newEntity = addEntity(entityItemID, properties);
|
EntityItem* newEntity = addEntity(entityItemID, properties);
|
||||||
if (newEntity) {
|
if (newEntity) {
|
||||||
newEntity->markAsChangedOnServer();
|
newEntity->markAsChangedOnServer();
|
||||||
notifyNewlyCreatedEntity(*newEntity, senderNode);
|
notifyNewlyCreatedEntity(*newEntity, senderNode);
|
||||||
|
if (wantEditLogging()) {
|
||||||
|
qDebug() << "User [" << senderNode->getUUID() << "] added entity. ID:"
|
||||||
|
<< newEntity->getEntityItemID();
|
||||||
|
qDebug() << " properties:" << properties;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
qDebug() << "User without 'rez rights' [" << senderNode->getUUID() << "] attempted to add an entity.";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1916,8 +1916,10 @@ bool Octree::readFromStream(unsigned long streamLength, QDataStream& inputStream
|
||||||
device->ungetChar(firstChar);
|
device->ungetChar(firstChar);
|
||||||
|
|
||||||
if (firstChar == (char) PacketTypeEntityData) {
|
if (firstChar == (char) PacketTypeEntityData) {
|
||||||
|
qDebug() << "Reading from SVO Stream length:" << streamLength;
|
||||||
return readSVOFromStream(streamLength, inputStream);
|
return readSVOFromStream(streamLength, inputStream);
|
||||||
} else {
|
} else {
|
||||||
|
qDebug() << "Reading from JSON Stream length:" << streamLength;
|
||||||
return readJSONFromStream(streamLength, inputStream);
|
return readJSONFromStream(streamLength, inputStream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2053,12 +2055,14 @@ bool Octree::readSVOFromStream(unsigned long streamLength, QDataStream& inputStr
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Octree::readJSONFromStream(unsigned long streamLength, QDataStream& inputStream) {
|
bool Octree::readJSONFromStream(unsigned long streamLength, QDataStream& inputStream) {
|
||||||
char *rawData = new char[streamLength];
|
char* rawData = new char[streamLength + 1]; // allocate enough room to null terminate
|
||||||
inputStream.readRawData(rawData, streamLength);
|
inputStream.readRawData(rawData, streamLength);
|
||||||
QJsonDocument d = QJsonDocument::fromJson(rawData);
|
rawData[streamLength] = 0; // make sure we null terminate this string
|
||||||
QVariant v = d.toVariant();
|
|
||||||
QVariantMap m = v.toMap();
|
QJsonDocument asDocument = QJsonDocument::fromJson(rawData);
|
||||||
readFromMap(m);
|
QVariant asVariant = asDocument.toVariant();
|
||||||
|
QVariantMap asMap = asVariant.toMap();
|
||||||
|
readFromMap(asMap);
|
||||||
delete rawData;
|
delete rawData;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue