mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-25 18:55:01 +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) {
|
||||
if (root.contains("Id") && root.contains("DataVersion")) {
|
||||
if (root.contains("Id") && root.contains("DataVersion") && root.contains("Version")) {
|
||||
id = root["Id"].toVariant().toUuid();
|
||||
version = root["DataVersion"].toInt();
|
||||
dataVersion = root["DataVersion"].toInt();
|
||||
version = root["Version"].toInt();
|
||||
}
|
||||
readSubclassData(root);
|
||||
return true;
|
||||
|
@ -76,11 +77,10 @@ bool OctreeUtils::RawOctreeData::readOctreeDataInfoFromFile(QString path) {
|
|||
}
|
||||
|
||||
QByteArray OctreeUtils::RawOctreeData::toByteArray() {
|
||||
const auto protocolVersion = (int)versionForPacketType((PacketTypeEnum::Value)dataPacketType());
|
||||
QJsonObject obj {
|
||||
{ "DataVersion", QJsonValue((qint64)version) },
|
||||
{ "DataVersion", QJsonValue((qint64)dataVersion) },
|
||||
{ "Id", QJsonValue(id.toString()) },
|
||||
{ "Version", protocolVersion },
|
||||
{ "Version", QJsonValue((qint64)version) },
|
||||
};
|
||||
|
||||
writeSubclassData(obj);
|
||||
|
@ -111,8 +111,8 @@ PacketType OctreeUtils::RawOctreeData::dataPacketType() const {
|
|||
|
||||
void OctreeUtils::RawOctreeData::resetIdAndVersion() {
|
||||
id = QUuid::createUuid();
|
||||
version = OctreeUtils::INITIAL_VERSION;
|
||||
qDebug() << "Reset octree data to: " << id << version;
|
||||
dataVersion = OctreeUtils::INITIAL_VERSION;
|
||||
qDebug() << "Reset octree data to: " << id << dataVersion;
|
||||
}
|
||||
|
||||
void OctreeUtils::RawEntityData::readSubclassData(const QJsonObject& root) {
|
||||
|
|
|
@ -28,6 +28,7 @@ constexpr Version INITIAL_VERSION = 0;
|
|||
class RawOctreeData {
|
||||
public:
|
||||
QUuid id { QUuid() };
|
||||
Version dataVersion { -1 };
|
||||
Version version { -1 };
|
||||
|
||||
virtual PacketType dataPacketType() const;
|
||||
|
|
|
@ -179,8 +179,8 @@ bool OctreePersistThread::process() {
|
|||
|
||||
OctreeUtils::RawOctreeData data;
|
||||
if (data.readOctreeDataInfoFromFile(_filename)) {
|
||||
qDebug() << "Setting entity version info to: " << data.id << data.version;
|
||||
_tree->setOctreeVersionInfo(data.id, data.version);
|
||||
qDebug() << "Setting entity version info to: " << data.id << data.dataVersion;
|
||||
_tree->setOctreeVersionInfo(data.id, data.dataVersion);
|
||||
}
|
||||
|
||||
bool persistentFileRead;
|
||||
|
|
Loading…
Reference in a new issue