mirror of
https://github.com/overte-org/overte.git
synced 2025-07-23 10:44:31 +02:00
getting there, but not yet complete
This commit is contained in:
parent
f6446c6806
commit
121d79ef36
3 changed files with 9 additions and 8 deletions
|
@ -346,11 +346,11 @@ EntityPropertyFlags EntityItemProperties::getChangedProperties() const {
|
||||||
return changedProperties;
|
return changedProperties;
|
||||||
}
|
}
|
||||||
|
|
||||||
QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool skipDefaults) const {
|
QScriptValue EntityItemProperties::copyToScriptValue(QScriptEngine* engine, bool skipDefaults, bool allowUknownCreateTime) const {
|
||||||
QScriptValue properties = engine->newObject();
|
QScriptValue properties = engine->newObject();
|
||||||
EntityItemProperties defaultEntityProperties;
|
EntityItemProperties defaultEntityProperties;
|
||||||
|
|
||||||
if (_created == UNKNOWN_CREATED_TIME) {
|
if (_created == UNKNOWN_CREATED_TIME && !allowUknownCreateTime) {
|
||||||
// No entity properties can have been set so return without setting any default, zero property values.
|
// No entity properties can have been set so return without setting any default, zero property values.
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
|
@ -73,7 +73,7 @@ public:
|
||||||
EntityTypes::EntityType getType() const { return _type; }
|
EntityTypes::EntityType getType() const { return _type; }
|
||||||
void setType(EntityTypes::EntityType type) { _type = type; }
|
void setType(EntityTypes::EntityType type) { _type = type; }
|
||||||
|
|
||||||
virtual QScriptValue copyToScriptValue(QScriptEngine* engine, bool skipDefaults) const;
|
virtual QScriptValue copyToScriptValue(QScriptEngine* engine, bool skipDefaults, bool allowUknownCreateTime = false) const;
|
||||||
virtual void copyFromScriptValue(const QScriptValue& object, bool honorReadOnly);
|
virtual void copyFromScriptValue(const QScriptValue& object, bool honorReadOnly);
|
||||||
|
|
||||||
static QScriptValue entityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags);
|
static QScriptValue entityPropertyFlagsToScriptValue(QScriptEngine* engine, const EntityPropertyFlags& flags);
|
||||||
|
|
|
@ -931,7 +931,7 @@ bool EntityTree::filterProperties(const EntityItemProperties& propertiesIn, Enti
|
||||||
wasChanged = false; // not changed
|
wasChanged = false; // not changed
|
||||||
return true; // allowed
|
return true; // allowed
|
||||||
}
|
}
|
||||||
QScriptValue inputValues = propertiesIn.copyToScriptValue(&_entityEditFilterEngine, false);
|
QScriptValue inputValues = propertiesIn.copyToScriptValue(&_entityEditFilterEngine, true, true);
|
||||||
QScriptValueList args;
|
QScriptValueList args;
|
||||||
args << inputValues;
|
args << inputValues;
|
||||||
|
|
||||||
|
@ -940,6 +940,7 @@ bool EntityTree::filterProperties(const EntityItemProperties& propertiesIn, Enti
|
||||||
|
|
||||||
propertiesOut.copyFromScriptValue(result, false);
|
propertiesOut.copyFromScriptValue(result, false);
|
||||||
wasChanged = result.equals(inputValues); // not changed
|
wasChanged = result.equals(inputValues); // not changed
|
||||||
|
qDebug() << "result" << propertiesOut << result.toVariant() << wasChanged;
|
||||||
return result.isObject(); // filters should return null or false to completely reject edit or add
|
return result.isObject(); // filters should return null or false to completely reject edit or add
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1028,17 +1029,17 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c
|
||||||
if (validEditPacket) {
|
if (validEditPacket) {
|
||||||
|
|
||||||
startFilter = usecTimestampNow();
|
startFilter = usecTimestampNow();
|
||||||
QScriptValue originalValues = properties.copyToScriptValue(&_entityEditFilterEngine, true);
|
|
||||||
bool wasChanged = false;
|
bool wasChanged = false;
|
||||||
bool allowed = filterProperties(properties, properties, wasChanged);
|
bool allowed = filterProperties(properties, properties, wasChanged);
|
||||||
QScriptValue filteredResult = properties.copyToScriptValue(&_entityEditFilterEngine, true);
|
if (!allowed) {
|
||||||
if (wasChanged) {
|
properties = EntityItemProperties(); // Maybe other behavior
|
||||||
|
} else if (wasChanged) {
|
||||||
if (properties.getLastEdited() == UNKNOWN_CREATED_TIME) {
|
if (properties.getLastEdited() == UNKNOWN_CREATED_TIME) {
|
||||||
properties.setLastEdited(usecTimestampNow());
|
properties.setLastEdited(usecTimestampNow());
|
||||||
}
|
}
|
||||||
properties.setLastEdited(properties.getLastEdited() + LAST_EDITED_SERVERSIDE_BUMP);
|
properties.setLastEdited(properties.getLastEdited() + LAST_EDITED_SERVERSIDE_BUMP);
|
||||||
}
|
}
|
||||||
qDebug() << "FIXME changed/allowed" << wasChanged << allowed;
|
qDebug() << "filtered:" << properties;
|
||||||
endFilter = usecTimestampNow();
|
endFilter = usecTimestampNow();
|
||||||
|
|
||||||
// search for the entity by EntityItemID
|
// search for the entity by EntityItemID
|
||||||
|
|
Loading…
Reference in a new issue