From dacaa3df1d98b0a687f611484b9157f2483e4d57 Mon Sep 17 00:00:00 2001 From: howard-stearns Date: Mon, 6 Feb 2017 11:12:18 -0800 Subject: [PATCH] Send new entity physics packet from physics simulation, accept in server, and make it go through filter (when supplied) regardless of lock rights. --- libraries/entities/src/EntityTree.cpp | 13 ++++++++----- libraries/physics/src/EntityMotionState.cpp | 4 ++-- 2 files changed, 10 insertions(+), 7 deletions(-) diff --git a/libraries/entities/src/EntityTree.cpp b/libraries/entities/src/EntityTree.cpp index b7a8841772..60e05c75e0 100644 --- a/libraries/entities/src/EntityTree.cpp +++ b/libraries/entities/src/EntityTree.cpp @@ -104,6 +104,7 @@ bool EntityTree::handlesEditPacketType(PacketType packetType) const { case PacketType::EntityAdd: case PacketType::EntityEdit: case PacketType::EntityErase: + case PacketType::EntityPhysics: return true; default: return false; @@ -1001,6 +1002,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c case PacketType::EntityAdd: isAdd = true; // fall through to next case + case PacketType::EntityPhysics: case PacketType::EntityEdit: { quint64 startDecode = 0, endDecode = 0; quint64 startLookup = 0, endLookup = 0; @@ -1010,6 +1012,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c quint64 startLogging = 0, endLogging = 0; bool suppressDisallowedScript = false; + bool isPhysics = message.getType() == PacketType::EntityPhysics; _totalEditMessages++; @@ -1021,6 +1024,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c entityItemID, properties); endDecode = usecTimestampNow(); + if (validEditPacket && !_entityScriptSourceWhitelist.isEmpty() && !properties.getScript().isEmpty()) { bool passedWhiteList = false; @@ -1053,8 +1057,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c } } - if ((isAdd || - (message.getType() == PacketType::EntityEdit && properties.lifetimeChanged())) && + if ((isAdd || properties.lifetimeChanged()) && !senderNode->getCanRez() && senderNode->getCanRezTmp()) { // this node is only allowed to rez temporary entities. if need be, cap the lifetime. if (properties.getLifetime() == ENTITY_ITEM_IMMORTAL_LIFETIME || @@ -1070,8 +1073,8 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c startFilter = usecTimestampNow(); bool wasChanged = false; - // Having (un)lock rights bypasses the filter. - bool allowed = senderNode->isAllowedEditor() || filterProperties(properties, properties, wasChanged, isAdd); + // Having (un)lock rights bypasses the filter, unless it's a physics result. + bool allowed = (!isPhysics && senderNode->isAllowedEditor()) || filterProperties(properties, properties, wasChanged, isAdd); if (!allowed) { auto timestamp = properties.getLastEdited(); properties = EntityItemProperties(); @@ -1088,7 +1091,7 @@ int EntityTree::processEditPacketData(ReceivedMessage& message, const unsigned c startLookup = usecTimestampNow(); EntityItemPointer existingEntity = findEntityByEntityItemID(entityItemID); endLookup = usecTimestampNow(); - if (existingEntity && message.getType() == PacketType::EntityEdit) { + if (existingEntity && !isAdd) { if (suppressDisallowedScript) { bumpTimestamp(properties); diff --git a/libraries/physics/src/EntityMotionState.cpp b/libraries/physics/src/EntityMotionState.cpp index e9891020b3..eb75718d92 100644 --- a/libraries/physics/src/EntityMotionState.cpp +++ b/libraries/physics/src/EntityMotionState.cpp @@ -614,7 +614,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ properties.setClientOnly(_entity->getClientOnly()); properties.setOwningAvatarID(_entity->getOwningAvatarID()); - entityPacketSender->queueEditEntityMessage(PacketType::EntityEdit, tree, id, properties); + entityPacketSender->queueEditEntityMessage(PacketType::EntityPhysics, tree, id, properties); _entity->setLastBroadcast(now); // if we've moved an entity with children, check/update the queryAACube of all descendents and tell the server @@ -630,7 +630,7 @@ void EntityMotionState::sendUpdate(OctreeEditPacketSender* packetSender, uint32_ newQueryCubeProperties.setClientOnly(entityDescendant->getClientOnly()); newQueryCubeProperties.setOwningAvatarID(entityDescendant->getOwningAvatarID()); - entityPacketSender->queueEditEntityMessage(PacketType::EntityEdit, tree, + entityPacketSender->queueEditEntityMessage(PacketType::EntityPhysics, tree, descendant->getID(), newQueryCubeProperties); entityDescendant->setLastBroadcast(now); }