mirror of
https://github.com/overte-org/overte.git
synced 2025-04-15 11:08:06 +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 "EntitiesLogging.h"
|
||||
#include "RecurseOctreeToMapOperator.h"
|
||||
#include "RecurseOctreeToJsonOperator.h"
|
||||
#include "RecurseOctreeToJSONOperator.h"
|
||||
#include "LogHandler.h"
|
||||
#include "EntityEditFilters.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
|
||||
// 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()) {
|
||||
QJsonDocument newDoc;
|
||||
QJsonObject rootObj = doc.object();
|
||||
QJsonArray newEntitiesArray;
|
||||
QVariantList newEntitiesArray;
|
||||
|
||||
// build a new entities array
|
||||
auto entitiesArray = rootObj["Entities"].toArray();
|
||||
for(auto it = entitiesArray.begin(); it != entitiesArray.end(); it++) {
|
||||
auto entity = (*it).toObject();
|
||||
auto entitiesArray = doc["Entities"].toList();
|
||||
for (auto it = entitiesArray.begin(); it != entitiesArray.end(); it++) {
|
||||
auto entity = (*it).toMap();
|
||||
entity["marketplaceID"] = marketplaceID;
|
||||
newEntitiesArray.append(entity);
|
||||
}
|
||||
rootObj["Entities"] = newEntitiesArray;
|
||||
newDoc.setObject(rootObj);
|
||||
return newDoc;
|
||||
doc["Entities"] = newEntitiesArray;
|
||||
}
|
||||
return doc;
|
||||
}
|
||||
|
||||
} // Unnamed namepsace
|
||||
const int READ_JSON_BUFFER_SIZE = 2048;
|
||||
|
||||
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;
|
||||
octreeParser.setEntitiesString(jsonBuffer);
|
||||
QVariantMap asMap;
|
||||
bool parseSuccess = octreeParser.parseEntities(asMap);
|
||||
|
||||
/*
|
||||
QJsonDocument asDocument = QJsonDocument::fromJson(jsonBuffer);
|
||||
if (!marketplaceID.isEmpty()) {
|
||||
asDocument = addMarketplaceIDToDocumentEntities(asDocument, marketplaceID);
|
||||
if (!octreeParser.parseEntities(asMap)) {
|
||||
qCritical() << "Couldn't parse Entities JSON:" << octreeParser.getErrorString().c_str();
|
||||
return false;
|
||||
}
|
||||
QVariant asVariant = asDocument.toVariant();
|
||||
QVariantMap asMap = asVariant.toMap();
|
||||
*/
|
||||
|
||||
if (!marketplaceID.isEmpty()) {
|
||||
addMarketplaceIDToDocumentEntities(asMap, marketplaceID);
|
||||
}
|
||||
|
||||
bool success = readFromMap(asMap);
|
||||
delete[] rawData;
|
||||
return success;
|
||||
|
|
|
@ -10,10 +10,10 @@
|
|||
//
|
||||
|
||||
#include <sstream>
|
||||
#include <cctype>
|
||||
#include <QUuid>
|
||||
#include <QJsonDocument>
|
||||
#include <QJsonObject>
|
||||
#include <QVariantList>
|
||||
|
||||
#include "OctreeEntitiesFileParser.h"
|
||||
|
||||
|
@ -171,12 +171,12 @@ string OctreeEntitiesFileParser::readString() {
|
|||
|
||||
int OctreeEntitiesFileParser::readInteger() {
|
||||
const char* currentPosition = _entitiesContents.constData() + _position;
|
||||
int i = atoi(currentPosition);
|
||||
int i = std::atoi(currentPosition);
|
||||
|
||||
int token;
|
||||
do {
|
||||
token = nextToken();
|
||||
} while (token == '-' || token == '+' || (token >= '0' && token <= '9'));
|
||||
} while (token == '-' || token == '+' || std::isdigit(token));
|
||||
|
||||
--_position;
|
||||
return i;
|
||||
|
|
|
@ -14,8 +14,8 @@
|
|||
#ifndef hifi_OctreeEntitiesFileParser_h
|
||||
#define hifi_OctreeEntitiesFileParser_h
|
||||
|
||||
#include <QVariantMap>
|
||||
#include <QByteArray>
|
||||
#include <QVariant>
|
||||
|
||||
class OctreeEntitiesFileParser {
|
||||
public:
|
||||
|
|
|
@ -158,7 +158,7 @@ void OctreePersistThread::handleOctreeDataFileReply(QSharedPointer<ReceivedMessa
|
|||
persistentFileRead = _tree->readFromFile(_filename.toLocal8Bit().constData());
|
||||
} else {
|
||||
QDataStream jsonStream(_cachedJSONData);
|
||||
persistentFileRead = _tree->readFromStream(-1, QDataStream(_cachedJSONData));
|
||||
persistentFileRead = _tree->readFromStream(-1, jsonStream);
|
||||
}
|
||||
_tree->pruneTree();
|
||||
});
|
||||
|
|
Loading…
Reference in a new issue