From d25db099b94619596d975e9024aa5484cd1bbdb7 Mon Sep 17 00:00:00 2001 From: Seth Alves Date: Thu, 4 May 2017 18:49:46 -0700 Subject: [PATCH] be more effecient about ignoring edits to unknown entities --- libraries/entities/src/EntityTree.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index 3ad5cc92a5..76483d0786 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -990,6 +990,17 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c entityItemID, properties); endDecode = usecTimestampNow(); + EntityItemPointer existingEntity; + if (!isAdd) { + // search for the entity by EntityItemID + startLookup = usecTimestampNow(); + existingEntity = findEntityByEntityItemID(entityItemID); + endLookup = usecTimestampNow(); + if (!existingEntity) { + // this is not an add-entity operation, and we don't know about the identified entity. + validEditPacket = false; + } + } if (validEditPacket && !_entityScriptSourceWhitelist.isEmpty() && !properties.getScript().isEmpty()) { bool passedWhiteList = false; @@ -1036,12 +1047,6 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c // If we got a valid edit packet, then it could be a new entity or it could be an update to // an existing entity... handle appropriately if (validEditPacket) { - - // search for the entity by EntityItemID - startLookup = usecTimestampNow(); - EntityItemPointer existingEntity = findEntityByEntityItemID(entityItemID); - endLookup = usecTimestampNow(); - startFilter = usecTimestampNow(); bool wasChanged = false; // Having (un)lock rights bypasses the filter, unless it's a physics result.