mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:42:53 +02:00
Merge pull request #13270 from dback2/cloneables
Use version from JSON on domain restore
This commit is contained in:
commit
9a7e199528
3 changed files with 10 additions and 9 deletions
|
@ -40,9 +40,10 @@ bool readOctreeFile(QString path, QJsonDocument* doc) {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool OctreeUtils::RawOctreeData::readOctreeDataInfoFromJSON(QJsonObject root) {
|
bool OctreeUtils::RawOctreeData::readOctreeDataInfoFromJSON(QJsonObject root) {
|
||||||
if (root.contains("Id") && root.contains("DataVersion")) {
|
if (root.contains("Id") && root.contains("DataVersion") && root.contains("Version")) {
|
||||||
id = root["Id"].toVariant().toUuid();
|
id = root["Id"].toVariant().toUuid();
|
||||||
version = root["DataVersion"].toInt();
|
dataVersion = root["DataVersion"].toInt();
|
||||||
|
version = root["Version"].toInt();
|
||||||
}
|
}
|
||||||
readSubclassData(root);
|
readSubclassData(root);
|
||||||
return true;
|
return true;
|
||||||
|
@ -76,11 +77,10 @@ bool OctreeUtils::RawOctreeData::readOctreeDataInfoFromFile(QString path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QByteArray OctreeUtils::RawOctreeData::toByteArray() {
|
QByteArray OctreeUtils::RawOctreeData::toByteArray() {
|
||||||
const auto protocolVersion = (int)versionForPacketType((PacketTypeEnum::Value)dataPacketType());
|
|
||||||
QJsonObject obj {
|
QJsonObject obj {
|
||||||
{ "DataVersion", QJsonValue((qint64)version) },
|
{ "DataVersion", QJsonValue((qint64)dataVersion) },
|
||||||
{ "Id", QJsonValue(id.toString()) },
|
{ "Id", QJsonValue(id.toString()) },
|
||||||
{ "Version", protocolVersion },
|
{ "Version", QJsonValue((qint64)version) },
|
||||||
};
|
};
|
||||||
|
|
||||||
writeSubclassData(obj);
|
writeSubclassData(obj);
|
||||||
|
@ -111,8 +111,8 @@ PacketType OctreeUtils::RawOctreeData::dataPacketType() const {
|
||||||
|
|
||||||
void OctreeUtils::RawOctreeData::resetIdAndVersion() {
|
void OctreeUtils::RawOctreeData::resetIdAndVersion() {
|
||||||
id = QUuid::createUuid();
|
id = QUuid::createUuid();
|
||||||
version = OctreeUtils::INITIAL_VERSION;
|
dataVersion = OctreeUtils::INITIAL_VERSION;
|
||||||
qDebug() << "Reset octree data to: " << id << version;
|
qDebug() << "Reset octree data to: " << id << dataVersion;
|
||||||
}
|
}
|
||||||
|
|
||||||
void OctreeUtils::RawEntityData::readSubclassData(const QJsonObject& root) {
|
void OctreeUtils::RawEntityData::readSubclassData(const QJsonObject& root) {
|
||||||
|
|
|
@ -28,6 +28,7 @@ constexpr Version INITIAL_VERSION = 0;
|
||||||
class RawOctreeData {
|
class RawOctreeData {
|
||||||
public:
|
public:
|
||||||
QUuid id { QUuid() };
|
QUuid id { QUuid() };
|
||||||
|
Version dataVersion { -1 };
|
||||||
Version version { -1 };
|
Version version { -1 };
|
||||||
|
|
||||||
virtual PacketType dataPacketType() const;
|
virtual PacketType dataPacketType() const;
|
||||||
|
|
|
@ -179,8 +179,8 @@ bool OctreePersistThread::process() {
|
||||||
|
|
||||||
OctreeUtils::RawOctreeData data;
|
OctreeUtils::RawOctreeData data;
|
||||||
if (data.readOctreeDataInfoFromFile(_filename)) {
|
if (data.readOctreeDataInfoFromFile(_filename)) {
|
||||||
qDebug() << "Setting entity version info to: " << data.id << data.version;
|
qDebug() << "Setting entity version info to: " << data.id << data.dataVersion;
|
||||||
_tree->setOctreeVersionInfo(data.id, data.version);
|
_tree->setOctreeVersionInfo(data.id, data.dataVersion);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool persistentFileRead;
|
bool persistentFileRead;
|
||||||
|
|
Loading…
Reference in a new issue