From a1ad496772caf0fcd2fb34fb530228464ae1f629 Mon Sep 17 00:00:00 2001 From: Stephen Birarda Date: Tue, 17 Jan 2017 17:19:47 -0800 Subject: [PATCH] handle match on non-default serverScripts property during entity send --- libraries/entities/src/EntityItem.cpp | 26 +++++++++++++++++--------- 1 file changed, 17 insertions(+), 9 deletions(-) diff --git a/libraries/entities/src/EntityItem.cpp b/libraries/entities/src/EntityItem.cpp index cd9f31d887..f9038fd547 100644 --- a/libraries/entities/src/EntityItem.cpp +++ b/libraries/entities/src/EntityItem.cpp @@ -2236,19 +2236,27 @@ void EntityItem::globalizeProperties(EntityItemProperties& properties, const QSt bool EntityItem::matchesJSONFilters(const QJsonObject& jsonFilters) const { - // currently the only property filter we handle is '+' which means that query is only asking for entities - // where the given property is non-default - // enumerate the filter object - for each key present check if the filter (which we only expect to be '+' right now) - // tells us that we should include this entity or not - bool matchedAllFilters = true; + // The intention for the query JSON filter and this method is to be flexible to handle a variety of filters for + // ALL entity properties. Some work will need to be done to the property system so that it can be more flexible + // (to grab the value and default value of a property given the string representation of that property, for example) + + // currently the only property filter we handle is '+' for serverScripts + // which means that we only handle a filtered query asking for entities where the serverScripts property is non-default + + static const QString SERVER_SCRIPTS_PROPERTY = "serverScripts"; for (auto& property : jsonFilters.keys()) { - if (jsonFilters[property] == EntityQueryFilterSymbol::NonDefault) { - // check if this entity has a non-default value for the given property - + if (property == SERVER_SCRIPTS_PROPERTY && jsonFilters[property] == EntityQueryFilterSymbol::NonDefault) { + // check if this entity has a non-default value for serverScripts + if (_serverScripts != ENTITY_ITEM_DEFAULT_SERVER_SCRIPTS) { + return true; + } else { + return false; + } } } - return matchedAllFilters; + // the json filter syntax did not match what we expected, return a match + return true; }