mirror of
https://github.com/HifiExperiments/overte.git
synced 2025-08-06 07:23:08 +02:00
Restore the addMarketplaceIDToDocumentEntities() hack
Fixes for Linux compiles; other improvements
This commit is contained in:
parent
c031769c67
commit
be279f08dc
5 changed files with 22 additions and 25 deletions
|
@ -35,7 +35,7 @@
|
||||||
#include "QVariantGLM.h"
|
#include "QVariantGLM.h"
|
||||||
#include "EntitiesLogging.h"
|
#include "EntitiesLogging.h"
|
||||||
#include "RecurseOctreeToMapOperator.h"
|
#include "RecurseOctreeToMapOperator.h"
|
||||||
#include "RecurseOctreeToJsonOperator.h"
|
#include "RecurseOctreeToJSONOperator.h"
|
||||||
#include "LogHandler.h"
|
#include "LogHandler.h"
|
||||||
#include "EntityEditFilters.h"
|
#include "EntityEditFilters.h"
|
||||||
#include "EntityDynamicFactoryInterface.h"
|
#include "EntityDynamicFactoryInterface.h"
|
||||||
|
|
|
@ -785,28 +785,26 @@ bool Octree::readFromStream(uint64_t streamLength, QDataStream& inputStream, con
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
namespace {
|
||||||
// hack to get the marketplace id into the entities. We will create a way to get this from a hash of
|
// hack to get the marketplace id into the entities. We will create a way to get this from a hash of
|
||||||
// the entity later, but this helps us move things along for now
|
// the entity later, but this helps us move things along for now
|
||||||
QJsonDocument addMarketplaceIDToDocumentEntities(QJsonDocument& doc, const QString& marketplaceID) {
|
QVariantMap addMarketplaceIDToDocumentEntities(QVariantMap& doc, const QString& marketplaceID) {
|
||||||
if (!marketplaceID.isEmpty()) {
|
if (!marketplaceID.isEmpty()) {
|
||||||
QJsonDocument newDoc;
|
QVariantList newEntitiesArray;
|
||||||
QJsonObject rootObj = doc.object();
|
|
||||||
QJsonArray newEntitiesArray;
|
|
||||||
|
|
||||||
// build a new entities array
|
// build a new entities array
|
||||||
auto entitiesArray = rootObj["Entities"].toArray();
|
auto entitiesArray = doc["Entities"].toList();
|
||||||
for(auto it = entitiesArray.begin(); it != entitiesArray.end(); it++) {
|
for (auto it = entitiesArray.begin(); it != entitiesArray.end(); it++) {
|
||||||
auto entity = (*it).toObject();
|
auto entity = (*it).toMap();
|
||||||
entity["marketplaceID"] = marketplaceID;
|
entity["marketplaceID"] = marketplaceID;
|
||||||
newEntitiesArray.append(entity);
|
newEntitiesArray.append(entity);
|
||||||
}
|
}
|
||||||
rootObj["Entities"] = newEntitiesArray;
|
doc["Entities"] = newEntitiesArray;
|
||||||
newDoc.setObject(rootObj);
|
|
||||||
return newDoc;
|
|
||||||
}
|
}
|
||||||
return doc;
|
return doc;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
} // Unnamed namepsace
|
||||||
const int READ_JSON_BUFFER_SIZE = 2048;
|
const int READ_JSON_BUFFER_SIZE = 2048;
|
||||||
|
|
||||||
bool Octree::readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID /*=""*/) {
|
bool Octree::readJSONFromStream(uint64_t streamLength, QDataStream& inputStream, const QString& marketplaceID /*=""*/) {
|
||||||
|
@ -831,16 +829,15 @@ bool Octree::readJSONFromStream(uint64_t streamLength, QDataStream& inputStream,
|
||||||
OctreeEntitiesFileParser octreeParser;
|
OctreeEntitiesFileParser octreeParser;
|
||||||
octreeParser.setEntitiesString(jsonBuffer);
|
octreeParser.setEntitiesString(jsonBuffer);
|
||||||
QVariantMap asMap;
|
QVariantMap asMap;
|
||||||
bool parseSuccess = octreeParser.parseEntities(asMap);
|
if (!octreeParser.parseEntities(asMap)) {
|
||||||
|
qCritical() << "Couldn't parse Entities JSON:" << octreeParser.getErrorString().c_str();
|
||||||
/*
|
return false;
|
||||||
QJsonDocument asDocument = QJsonDocument::fromJson(jsonBuffer);
|
|
||||||
if (!marketplaceID.isEmpty()) {
|
|
||||||
asDocument = addMarketplaceIDToDocumentEntities(asDocument, marketplaceID);
|
|
||||||
}
|
}
|
||||||
QVariant asVariant = asDocument.toVariant();
|
|
||||||
QVariantMap asMap = asVariant.toMap();
|
if (!marketplaceID.isEmpty()) {
|
||||||
*/
|
addMarketplaceIDToDocumentEntities(asMap, marketplaceID);
|
||||||
|
}
|
||||||
|
|
||||||
bool success = readFromMap(asMap);
|
bool success = readFromMap(asMap);
|
||||||
delete[] rawData;
|
delete[] rawData;
|
||||||
return success;
|
return success;
|
||||||
|
|
|
@ -10,10 +10,10 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
#include <sstream>
|
#include <sstream>
|
||||||
|
#include <cctype>
|
||||||
#include <QUuid>
|
#include <QUuid>
|
||||||
#include <QJsonDocument>
|
#include <QJsonDocument>
|
||||||
#include <QJsonObject>
|
#include <QJsonObject>
|
||||||
#include <QVariantList>
|
|
||||||
|
|
||||||
#include "OctreeEntitiesFileParser.h"
|
#include "OctreeEntitiesFileParser.h"
|
||||||
|
|
||||||
|
@ -171,12 +171,12 @@ string OctreeEntitiesFileParser::readString() {
|
||||||
|
|
||||||
int OctreeEntitiesFileParser::readInteger() {
|
int OctreeEntitiesFileParser::readInteger() {
|
||||||
const char* currentPosition = _entitiesContents.constData() + _position;
|
const char* currentPosition = _entitiesContents.constData() + _position;
|
||||||
int i = atoi(currentPosition);
|
int i = std::atoi(currentPosition);
|
||||||
|
|
||||||
int token;
|
int token;
|
||||||
do {
|
do {
|
||||||
token = nextToken();
|
token = nextToken();
|
||||||
} while (token == '-' || token == '+' || (token >= '0' && token <= '9'));
|
} while (token == '-' || token == '+' || std::isdigit(token));
|
||||||
|
|
||||||
--_position;
|
--_position;
|
||||||
return i;
|
return i;
|
||||||
|
|
|
@ -14,8 +14,8 @@
|
||||||
#ifndef hifi_OctreeEntitiesFileParser_h
|
#ifndef hifi_OctreeEntitiesFileParser_h
|
||||||
#define hifi_OctreeEntitiesFileParser_h
|
#define hifi_OctreeEntitiesFileParser_h
|
||||||
|
|
||||||
#include <QVariantMap>
|
|
||||||
#include <QByteArray>
|
#include <QByteArray>
|
||||||
|
#include <QVariant>
|
||||||
|
|
||||||
class OctreeEntitiesFileParser {
|
class OctreeEntitiesFileParser {
|
||||||
public:
|
public:
|
||||||
|
|
|
@ -158,7 +158,7 @@ void OctreePersistThread::handleOctreeDataFileReply(QSharedPointer<ReceivedMessa
|
||||||
persistentFileRead = _tree->readFromFile(_filename.toLocal8Bit().constData());
|
persistentFileRead = _tree->readFromFile(_filename.toLocal8Bit().constData());
|
||||||
} else {
|
} else {
|
||||||
QDataStream jsonStream(_cachedJSONData);
|
QDataStream jsonStream(_cachedJSONData);
|
||||||
persistentFileRead = _tree->readFromStream(-1, QDataStream(_cachedJSONData));
|
persistentFileRead = _tree->readFromStream(-1, jsonStream);
|
||||||
}
|
}
|
||||||
_tree->pruneTree();
|
_tree->pruneTree();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in a new issue